Snook's terrain algo on a GPU

Published April 08, 2009
Advertisement
Evening all,

I'm still alive. Finally moving from West London to North West London appears complete - boxes sorted, broadband switched on.

Was quite productive living in this "offline" world.



The above is generated from a simple 8x8 grid of quads (81 vertices @ 972 bytes / 768 indices @ 1536 bytes) and the GPU renders me a total of 1572 triangles. All in a single draw call and without the CPU creating any look-up tables or constant buffers with pre-computed LOD values. Cool, huh? [cool]

I always quite liked Greg Snook's "Simplified Terrain Using Interlocking Tiles" that first featured in Game Programming Gems vol. 2 (to my knowledge, there is no digital version available for free).

Back when that text was up-to-date it had many of the quality properties of the more favourable ROAM-like algorithms whilst also mapping very nicely to GPU's. If you didn't mind storing extra indices (tiny - uint16's!) you could get very good results without having to constantly update your raw data (one of the main problems with the more CPU-centric LOD algorithms).

In a nutshell Greg's algorithm divided a terrain tile into 5 sections - the inner area and the 4 edges:

+-----+|\___/|||___|||/   \|+-----+


Basically the inner section would be the main LOD and the 4 'skirts' would map between that inner LOD and whatever the neighbouring tile was using.

So I realised a week or so back that the above (crappy) diagram matches the Direct3D 11 quad patch tessellation model. Pretty much 100% exactly as well.

The initial screen-shot shows my current implementation of this algorithm (less height data). As a slightly clearer alternative:



So the above is a 3x3 grid of quads - you can get a feel for how big they are by looking at the top-middle quad. That's the lowest detail, a quad divided into two triangles only.

The LOD increases as the mid-point of the tile gets closer to the camera.

Now consider the right-most corner quad. This has two neighbours, diagonally up-left and down-left. The up-left has an LOD of 2 and the down-left has an LOD of 5 whereas the tile in question has an LOD of 4. Notice how the edges, the bits with the odd patterns, blend between all 3 of the LOD's such that there aren't any 'stray' vertices - if this were a solid rendering and not wireframe there would be NO gaps in this surface.

I'm writing this up for my main article, so I'll have some better diagrams soon!

After this I want to try and render it into a YouTube video so you can see how it works and, more importantly, how damned ugly the popping is [wink]
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement