Sign in to follow this  
Dr. Krunklehorn

Quad tree LOD, but with triangles?

Recommended Posts

[u][b]If TL;DR then skip past the line...[/b][/u]

Hello gamedev! I am a high school student working on a procedural planet engine in my spare time using DirectX 11 and C++.
Four weeks ago I was 100% new to DirectX 11, but I have learned a lot just by reading tutorials and getting inspiration
from tech demos.

So far I'm taking the Icosahedron approach to generating a sphere. There's a lot of blogs, articles and theory on this, but not
much raw code examples specifically for DX11 C++...most of them I have found are for OpenGL. It took me three weeks, but I
managed to write my own version of Andrew True's nifty counterclockwise method. ([url=""]here[/url]) I've created wrapper functions for
properly subdividing and merging these triangles, now I need to work on dynamic LOD.

Unfortunately he doesn't seem to be active anymore, his website is gone, and he never posted anything on LOD with his tactic. :C
So for the last week I've been trying to come up with the best solution to triangle based LOD. I've read up on various methods like
quad trees, RTIN and ROAM, but they all deal with cube quads mapped to the sphere. I obviously need a different approach.

So I need something that works with my subdivided Icosahedron.

The first method I tried was very basic. I check distance on all triangles. If the distance was greater then a certain value I would
subdivide the triangle, and vice versa for merging children back into a parent. At first this method was extreeeeemly expensive.
I wasn't able to get past 3 subdivisions before the number of sqrt() calls per frame was taking a tole on my FPS.

I've optimized it since then by only checking distance on triangles of the current and previous LOD levels, but it's still waayyy
too slow and it's all done on the CPU side.

My goal is to be able to go from planet to surface...seamlessly...but I can't figure out how I would do this.

Am I wrong about chunked LOD? Can RTIN, ROAM, or quad trees work with my triangle setup somehow?

Share this post

Link to post
Share on other sites
If we set aside the problem of the huge amount of heightmap data which you could require, then the problem boils down to growing a single point into a sphere and then zooming in on a vertex of the sphere over and over until you appear to be on the surface of a planet, with appropriate gains and loses of vertex tessellation based on view distance.

This lends itself beautifully to being hardware accelerated with the GPU on DX11. Here's a tutorial to read through, but also check out the sample that comes with your SDK.

Sorry I can't comment about your current algorithm, if it's not GPU accelerated using a geometry shader and the d3d11 tessellators it probably isn't worth pursuing.

Share this post

Link to post
Share on other sites
Thanks! My current LOD system was more of a crude test to just get subdivision working on the fly. By the looks of it
I really should be doing this on the geometry shader like you said.

EDIT: Wait...your saying I can send the base icosahedron data (only 12 vertices) to the GPU and then do tessellation
and heightmap stuff right there? None of this needs actually needs to be on the CPU side?

As far as hardware tessellation goes, how would I get the data back from the GPU to use with collision? Assuming that
[i]is[/i] even possible, wouldn't the data be behind by one frame when I go to calculate with it? Edited by Dr. Krunklehorn

Share this post

Link to post
Share on other sites
You don't need the tessellation data back from the GPU for collision. You can use the heightmap data for collision (assuming you were not intending to procedurally generate height values in the GPU?). The extra vertices are just for eye candy. If you want to allow collision at different LOD resolutions, I recommend doing that work on the CPU with the heightmap data. But it doesn't make much sense to me to have very fine grain triangle collision until you've pretty much reached a set distance to the planet's surface. Further away you can just use a point and radius (sphere) collision.

Here I found this link: Edited by Steve_Segreto

Share this post

Link to post
Share on other sites
Alright so last night I got hardware tessellation going smoothly, but the actual triangles it creates are not
exactly what I am looking for:

I would like to change the Tessellator so it generates equilateral triangles like this:

Could I do this in Hull and Domain shaders?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this