Sword7
Active member
I read a book called "3D Engine Design for Virtual Globes". I learned a lot about globe rendering. Read page 164-169 about RTC (relative to center) in the chapter 5 (Vertex Transform Precision). I noticed that Orbiter uses RTC method to eliminate jittering. With RTC method, geometry object size must be within a boundary radius of 131,071 meters to avoid jittering. Orbiter's tiles are much smaller than 131km radius. Re-calculate RTC matrix each tile and apply it to model matrix uniform. Good.
That world matrix function call is using RTC method similar like in that book explains. Move a center (origin (0,0,0)) to the tile corner from the sphere center. Ony problem is could render "exploded" planet because moved eye center pushed tile position out from a center. That book did not explain about "exploded" planet.
Many flight simulators and games with massive worlds use RTC or RTE methods. Microsoft Flight Simulator use RTE (relative to eye) method.
Tim
C++:
MATRIX4 TileManager2Base::WorldMatrix (int ilng, int nlng, int ilat, int nlat)
{
if (nlat < 2) { // render full sphere
return prm.dwmat;
}
double lat, lng = PI2 * (double)ilng/(double)nlng + PI; // add pi so texture wraps at +-180�
double slng = sin(lng), clng = cos(lng);
MATRIX4 lrot = {clng,0,slng,0, 0,1.0,0,0, -slng,0,clng,0, 0,0,0,1.0};
if (nlat <= 8) { // rotate patch into place
return mul(lrot,prm.dwmat);
} else { // shift, scale and rotate
bool north = (ilat < nlat/2);
if (north) lat = PI * (double)(nlat/2-ilat-1)/(double)nlat;
else lat = PI * (double)(nlat/2-ilat)/(double)nlat;
double s = obj_size;
double dx = s*cos(lng)*cos(lat); // the offsets between sphere centre and tile corner
double dy = s*sin(lat);
double dz = s*sin(lng)*cos(lat);
prm.dwmat_tmp.m41 = (dx*prm.grot.m11 + dy*prm.grot.m12 + dz*prm.grot.m13 + prm.cpos.x) * (float)prm.scale;
prm.dwmat_tmp.m42 = (dx*prm.grot.m21 + dy*prm.grot.m22 + dz*prm.grot.m23 + prm.cpos.y) * (float)prm.scale;
prm.dwmat_tmp.m43 = (dx*prm.grot.m31 + dy*prm.grot.m32 + dz*prm.grot.m33 + prm.cpos.z) * (float)prm.scale;
return mul(lrot,prm.dwmat_tmp);
}
}
That world matrix function call is using RTC method similar like in that book explains. Move a center (origin (0,0,0)) to the tile corner from the sphere center. Ony problem is could render "exploded" planet because moved eye center pushed tile position out from a center. That book did not explain about "exploded" planet.
Many flight simulators and games with massive worlds use RTC or RTE methods. Microsoft Flight Simulator use RTE (relative to eye) method.
Tim