|
Terrain Demo Page |
|
A scene graph is only so interesting without a Demo. Therefore, here is a page discussing
a demo application using the scene graph. Both external capabilities and internal coding
of the demo will be discussed.
Terrain Demo Application The user can control how the terrain is rendered by using a few arguments to the program. These arguments allow the user to select one of the following methods to load/render the terrain:
The key being that the code for these algorithms is not in the demo application, but an inherent part of the scene graph and its associated libraries. For example, the demo application uses a heightmap loader, which processes the data producing the required scene graph nodes. The heightmap loader relies upon supplied objects for triangle stripping and delaunay triangulation. The loader produces a graph of scene graph nodes, which can contain basic geometry nodes like triangle strip sets, and triangle sets or it can contain more complex nodes like ROAM rendering nodes.
|
|
Help Screen The demo application begins with a help screen overlaid on the scene being rendered from the current eye point. The help screen is represented by a scene graph which is rendered as an overlay on the out the window view. An image of the help screen is to the right.
|
|
|
Stats Screen The scene graph has a built-in object for collecting and display statistics about the rendering. The demo uses this object to display a stats overlay. The stats overlay includes: average frames per second, polygons per frame, and polygons per second. It also provides a graph of the past values of FPS and polygons per second to allow gauging the consistency of the load on the scene graph. This can be particularly useful when setting up the switch-in values for one's LODs. An image of the stats scren is to the right. |
|
|
Terrain Following What good would a scene graph and terrain demo be without terrain following? The demo allows the user to activate or deactive the terrain following by pressing the 'f' key. The intersection with the terrain is done on-the-fly by the scene graph. A terrain following object is provided to do all the work for the user, making life even easier for the programmer. No trickery is used, like sampling the heightmap for the terrain following. It is all done via polygon intersections.
|
|
|
Level of Detail The loader can generate scene graphs containing LODs. The Heightmap loader currently supports doing this for both the Triangle Stripped cells and the Delaunay triangulated cells. For the triangle stripped cells, the demo supplies the height map loader with a parameters specifying the relative number of polygons each LOD of the cell should contain (expressed as a percentage of the highest level of detail) and the switch-in values. The loader does the rest. For the delaunay cells, the demos supplies the height map loader with different simplification levels for each of the LODs. For those interested, cracking issues in the Triangle Stripped Cells case is currently solved by building a type "apron" around the edges of the cells, obscuring the cracks. ( This is a quick and simple solution. There are plans for more complicated/higher quality LOD techniques now that the basic demo is complete.) The delaunay cells currently keep all boundary vertices which prevents cracking. This will be changed once I have time to do some constraint work on the Delaunay triangulator. An image of the scene rendered using LOD is to the right. Notice in the stats display, the reduced polygon load. Currently the demo uses LODs for each cell at 100%, 50% and 20% of the original polygon count of the cell. The second image is a wireframe display of the LOD delaunay cells. Notice a little ways away from the camera, how the cells become simpler.
|
Basic Triangle Stripped Terrain with LODs. |
|
Camera Path Animation The demo provides a couple camera animation paths. Terrain following may be enabled for each of them. The demo doesn't do any of the work, it provides the path points to an object provided by the scene graph libraries. The CameraPath object tracks the progress, moves the eyepoint and moves the COI, all based upon the time. Velocity along the paths can be controlled by the user.
|
|
|
Terrain Data
As mentioned in the start, the terrain demo loads a raw heightmap file created from a DEM file.
To give you a better idea about the size of the data, the DEM file is ~10 Megs and the raw height map, which is just the height values stored as shorts in a binary file is ~2 Megs. It is
a 1000 x 1000 grid which is 1 million samples.
To explore the size of the data we are discussing rendering, the following will be a bit theoretical but will apply to understanding the general magnitude of the file we are rendering. If no simplification is performed and no LODs are generated, this results in just short of 2 million triangles. If stored as perfect triangle strips (no cells generated for culling), this would be 999 triangle strips of 2000 vertices a piece. Each vertex will probably have XYZ coordinates, a normal, a color, and 2 sets of texture coordinates which totals 10 floats plus 4 unsigned chars, or 44 bytes. So each triangle strip will be approximately 2000x44 bytes, or 88k. 999 Triangle Strips x 88k = ~88 Megs! If we leave the theoretical and return to reality, 88 megs doesn't cover the fact that we will divide the terrain into cells for culling and LOD purposes. It doesn't cover that we will generate a couple level of LODs for each cell. You will now see why so much work goes into doing such a "simple" thing as rendering terrain. You will also see why the scene graph's heightmap loader supports simplification objects which are run over the terrain when doing delaunay triangulations. They greatly reduce the number of samples needed to represent the terrain with only a minimal loss of quality in the represented terrain. (For more information on the simplification objects, and their effects on the terrain, click here.) |
|
Summary This demo illustrates a number of pieces of the scene graph. Loaders, renderers, traversals, terrain following, overlay objects, triangulation, triangle stripping, etc. The important point is that the actual demo is only a couple hundred lines of code. These are mostly for window creation, and setup. All of these features you see mentioned on this page are generic items that have been put together to produce this demo.
Back to the main Scene Graph page.