PLOD
The Program
This is getting somewhat old now. It was written around 2001, and is mainly here for posterity’s sake. It’s a program I wrote as part of my final year course at Uni and, like everyone else at the time, I wrote a terrain renderer. This was in the days before you could afford to just put your entire terrain map into a horkin’ great vertex buffer and let the graphics card do all the work for you, so people still cared about LOD systems for cutting down the number of polys that had to be drawn.
It segments up an arbitrarily sized heightmap into smaller squares, and then draws each of these separately. It tries to work out how interesting a square is, based on the height variance over the area covered. If an area is relatively flat, then it’s safe to draw it at a lower level of detail than a more bumpy area.
The program uses a mipmap-like algorithm to draw the centre of each square. simply skipping even numbers of vertices as appropriate to the detail required. When two square of different detail levels join, the program has to automatically generate triangle fans to make the joins seamless. Without this, the differing numbers of drawn vertices at the edges of the squares would cause cracks and T-joins and all kinds of other nastiness.
Texture Generation
To go along with this, I also created a program to automatically generate textures for these areas. Since the heightmaps can get pretty big, it doesn’t make sense to have someone draw unique textures for it. The textures used in the demo are created from a small set of base textures (for snow, grass, rock, sand etc,) which are blended according to the absolute height of the current terrain point, as well as the gradient of the surrounding area (so that sharp changes in height are represented by rocky, cliff-like textures.)
The Demo
This is a small demo of the final system. The full system used a lot more data, and allowed for new data segments to be dynamically loaded in by a low-priority thread, allowing for fully seamless landscapes. To save my bandwidth bill, I have only supplied a small amount of data, so the demo only shows one chunk of land. If you choose to run in windowed mode, you will also get a terminal, showing the keyboard controls.
The whole thing can be downloaded here.
Controls
w, a, s, d: Movement controls
Left Mouse: Rotate the viewpoint
t: Toggle the texturing on and off. Lets you see the LOD changes more clearly
f: Print current framerate to the terminal
m: Increase the maximum polygon budget
l: Decrease the maximum polygon budget
=: Increase camera movement speed
-: Decrease camera movement speed
q/Esc: Quit
Screens


