Terrain Jyun-Ming Chen Spring 2004
Issues Height field (design, Perlin noise) Frustum culling Texturing (texgen, mipmap) Transformation LOD
Terrain Element [i+1,j+1] [i,j+1] [i,j] [i+1,j]
Terrain Design Height field Convert a gray scale image to terrain Design naturally looking terrains with Perlin noise functions
Frustum Culling Apply frustum culling to each terrain element to speed up rendering Verify the improved frame rates
Frustum Culling (terrain version) Test center point against frustum : int SphereInFrustum (center, radius) radius = w/sqrt(2)· w:width of terrain element Quick break for terrain: No need to test top and bottom
Applying Textures Mipmap is very important (esp. near horizon) Use texgen facility to generate texture coordinates procedural textures: fr08; Perlin2D
On Plane Equation of Texgen [10,0,0,0] [10,0,0,0], [1,0,0,0] and [0.1,0,0,0] are different [1,0,0,0]
Texgen (cont) [0.1,0,0,0] From OpenGL APIDOC: If the texture generation function is GL_OBJECT_LINEAR, the function , g = p1 * xo + p2 * yo + p3 * zo + p4 * wo is used
Vehicle on Terrain Determine the vehicle location [i,j] Local y aligned with terrain normal Local x modified to its projection on terrain plane Z = X Y origin
Find Origin Z p2 X p0 p1
Level of Detail (LOD) Without LOD, the polygons are crowded near horizon
LOD (cont) In an ideally LOD’d scene, all polygons are roughly the same size in screen pixels.
ROAM (demo)