Hello all. I've been doing some research and trial and error and am in the process of developing a new terrain engine based on adaptive quadtrees and triangle fans.
I read about it at www.gamasutra.com but didn't think much of it. Well just recently I dumped my old system because it had cracks and crevices between terrain resolution patches and moved to using triangle fans. Each fan is composed of 10, vertices and 9 triangles. The matrix idea from gamasutra actually popped into my head and then I remembered the article. Amazing how trying to achieve the same result leads you to the same conclusions, without you even realizing it.
My goals for the terrain system are:
- View-dependent CLOD. This is not based on height or detail of the land.
- Render from camera to horizon in all directions, regardless of altitude.
- 60 FPS or better, hopefully more like 80 to 100.
- Quad tree-based culling system using p and n vertices, plane coherency, and other similar tests.
- Multiple terrain texture types seamlessly blending from one type to another. Fairly simple texture blending.
- Per pixel diffuse and specular lighting using shaders.
- Ground foliage using textured quads - not billboards.
- Water with reflection properties using cubic environment mapping. Would love to have real-time environment mapping, however, even high end computers with uber cards would have problems in a terrain setting. Will probably update environment map once every 15 frames. Many games use this technique to aid rendering. Check out Need For Speed Underground 2. Environment mapping on cars lags behind actual position of car due to delayed update of environment map. Midnight Madness also uses this technique only it updates once every 6 frames and maintains a cache of the environment map.
Cannot use vertex displacement shaders as my card does not support this. Requires PS 3.0+. Would look good for water, but just cannot do it.
- Shadowing of terrain objects using shaders. No shadows for distant objects. Just not enough FPS for it.
The most important factor in the engine is rendering to the horizon. Many, many games just simply cannot do this which is annoying. This means that CLOD must concentrate on distance from camera rather than density of triangles based on elevation changes. With Rottgers even a resolute terrain patch will render slowly off in the distance because the same number of tri's are used. Might use Rottgers to reduce the tri's on the map and then use adaptive quadtree LOD triangle fans to further reduce the detail levels.
Will have screenshots soon.
If I can render to the horizon with acceptable levels of detail and render <=80000 triangles, I think I can maintain 80 FPS.
I'm going to use geometry clipmaps. Came across an article by Hugues Hoppes who used to be with Microsoft. I'm fairly certain FS9 uses this technique to render to the horizon. I've not been able to create a terrain in world space from data points and get it working right. In order to do a complete coast-to-coast fly over for the U.S. I will need to figure out how to implement this.
I can't really explain what a geo clipmap is except to say that it is much like a texture clipmap and/or a texture mipmap.
To prevent T junctions I have to interpolate the height of the T junction on y to account for the upsampled height value.
For instance if a T junction is occurring on the top side of a quad, then I must take the lower left Y and lower right Y and interpolate using an interpolant of .5f to place the vertex at the correct position to seamlessly connect with it's neighbor.
Once I get this done, it should be able to render to the horizon. It will probably need 11 to 14 resolutions of the terrain to get it done right.
Hopefully pictures soon.
I did get the quad-tree triangle fan-based terrain done, but I'm not happy with it's performance.
This is a screenshot from the engine so far. There are 3 levels of detail here although you cannot clearly see them. The first level uses 8 triangles per 4 quads, second is 4 triangles per 4 quads and third is 2 triangles per 4 quads. There is no terrain popping or morphing with this method. Level 1 and 2 do have seams but I can fix that.
This screenie has the following parameters:
Near/Far clip: 1.0 to 35000.0f
HFOV: 45 degrees
Height map size: 2048x2048
Detail map: 128.0f
Light map 1.0f - one map across terrain, no tiling
Texture map 1.0f - same as light map
Not sure about the number of tri's since each level needs its own data member for number of tri's. I'd say it's close to 100000 triangles in this screenie.