Jump to content

  • Log In with Google      Sign In   
  • Create Account

Quad tree LOD, but with triangles?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1   Members   -  Reputation: 128


Posted 05 December 2012 - 06:25 PM

If TL;DR then skip past the line...

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. (here) 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?

#2   Crossbones+   -  Reputation: 1986


Posted 05 December 2012 - 07:29 PM

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.

#3   Members   -  Reputation: 128


Posted 05 December 2012 - 07:45 PM

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
is even possible, wouldn't the data be behind by one frame when I go to calculate with it?

Edited by Dr. Krunklehorn, 05 December 2012 - 07:49 PM.

#4   Crossbones+   -  Reputation: 1986


Posted 05 December 2012 - 08:04 PM

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, 05 December 2012 - 08:10 PM.

#5   Members   -  Reputation: 128


Posted 05 December 2012 - 08:41 PM

Oh that's right! I can just use heightmap data for collisions.

Awesome! I'm going to work on moving everything to the GPU right away.

#6   Members   -  Reputation: 128


Posted 06 December 2012 - 02:25 PM

Alright so last night I got hardware tessellation going smoothly, but the actual triangles it creates are not
exactly what I am looking for: http://puu.sh/1xFx7

I would like to change the Tessellator so it generates equilateral triangles like this: http://puu.sh/1xFIx

Could I do this in Hull and Domain shaders?

#7   Crossbones+   -  Reputation: 1986


Posted 06 December 2012 - 07:46 PM

YOU ROCK!!! I can't help much more, since I've never done any of that. I wish there was a way to move the question to DirectX forum or Math Physics forum?

#8   Members   -  Reputation: 128


Posted 06 December 2012 - 08:15 PM

Should I ask for that to happen? I wonder if I could pm a mod or something.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.