Skip to main content
GameDev.net gamedev.net
🔒 Locked

LOD for procedural terrains

Started by trsh Nov 26, 2019 at 6:50 PM 20 replies 11.2k views
Original Post
trsh
trsh

I have been digging into "Chunked LOD" papers and examples. I mean while I want to ask what is really the up-to-date technique for doing LOD's for procedural terrain (calculations on CPU side and also for low end hardware like mobiles)? I don't want to miss something and adopt some maybe out dated strategy. Any suggestions welcome!

Green_Baron
Green_Baron

I would be interested as well in the "up-to-date" aspect, because it seems like there haven't been that many news on the subject in the past years.

I went the other way, going with an algorithm that uses the GPU (i think todays mobiles are pretty well equipped as well) and that doesn't need stitching and too much preparation on the CPU. CDLOD was my choice. For rendering the geometry it only uses a simple regular 2D mesh the size of a node and a displacement map which can be a single channel 16bit texture.

trsh
trsh


Green_Baron said:

I would be interested as well in the "up-to-date" aspect, because it seems like there haven't been that many news on the subject in the past years.

I went the other way, going with an algorithm that uses the GPU (i think todays mobiles are pretty well equipped as well) and that doesn't need stitching and too much preparation on the CPU. CDLOD was my choice. For rendering the geometry it only uses a simple regular 2D mesh the size of a node and a displacement map which can be a single channel 16bit texture.




Would it be possible to manage CLOD on CPU side, from your exp.?

Green_Baron
Green_Baron

You could have a look at the classic roam algorithm and its variants as well.

trsh
trsh


Green_Baron said:

Yes




What sources did you use when developing CDLOD for your project? Maybe can give some pointers?

Green_Baron
Green_Baron

Does it not display the link in my first reply ?

You could search github for "strugar cdlod". Strugar is the developer of that thing :-)

trsh
trsh


Green_Baron said:

Does it not display the link in my first reply ?

You could search github for "strugar cdlod". Strugar is the developer of that thing :-)




Ok. Sorry. Link works. Thanks!

trsh
trsh


Green_Baron said:

Does it not display the link in my first reply ?

You could search github for "strugar cdlod". Strugar is the developer of that thing :-)




Maybe u can give some pointers where to look at first? Its a lot of code :)

Green_Baron
Green_Baron

Yes, but much of it is renderer stuff and not directly connected to the lod algorithm. First read the paper. And you will have to go through this yourself in order to understand what's going on. I did actually take the time for myself to dissect and re-implement it in my environment.

But because i am a nice guy and have some time, here's a high level overview:

Setup:

  • For a given heightmap texture, build a quad tree hierarchy of nodes, calculate their bounding boxes, offsets and sizes.
  • prepare a regular gridmesh the size of a single node
  • calculate lod level ranges and transition areas from higher to lower lod level (this can also be done in the loop).

In the loop:

  • select the nodes that appear in the view frustum, sort them front to back
  • for every selected node, draw the gridmesh
  • for every vertex/grid mesh position:
  • calculate the world position and determine the distance to the camera from the node's offset and size.
  • use lod level ranges to morph the base grid from higher to lower levels, displacing the positions slightly in 2d. Don't forget height displacement (*).

Or use roam or geometry clipmapping, afaik they lend themselves better to cpu based lodding, but need more preparation and gymnastics to optimize meshes, stitch and skirt nodes, can pop between lod levels and so on.

(*) in the vertex shader, this can be done in two steps, a pre- and an exact lookup, so that terrain height is already observed for morphing.

Have fun :-)

trsh
trsh

Tnx

trsh
trsh

Thank you. Nerveless "geometry clipmapping" is a 100% GPU technique :P. Will take look at ROAM also. Seems very complicated.

trsh
trsh


Green_Baron said:

Yes, but much of it is renderer stuff and not directly connected to the lod algorithm. First read the paper. And you will have to go through this yourself in order to understand what's going on. I did actually take the time for myself to dissect and re-implement it in my environment.

But because i am a nice guy and have some time, here's a high level overview:

Setup:

  • For a given heightmap texture, build a quad tree hierarchy of nodes, calculate their bounding boxes, offsets and sizes.
  • prepare a regular gridmesh the size of a single node
  • calculate lod level ranges and transition areas from higher to lower lod level (this can also be done in the loop).

In the loop:

  • select the nodes that appear in the view frustum, sort them front to back
  • for every selected node, draw the gridmesh
  • for every vertex/grid mesh position:
  • calculate the world position and determine the distance to the camera from the node's offset and size.
  • use lod level ranges to morph the base grid from higher to lower levels, displacing the positions slightly in 2d. Don't forget height displacement (*).

Or use roam or geometry clipmapping, afaik they lend themselves better to cpu based lodding, but need more preparation and gymnastics to optimize meshes, stitch and skirt nodes, can pop between lod levels and so on.

(*) in the vertex shader, this can be done in two steps, a pre- and an exact lookup, so that terrain height is already observed for morphing.

Have fun :-)




There is one thing I dont understand from the papers and you description. The QuadTree, do I have to Split and and Unsplit the nodes in the loop depending on the distance, before I select the nodes?


Baron said:Yes, but much of it is renderer stuff and not directly connected to the lod algorithm. First read the paper. And you will have to go through this yourself in order to understand what's going on. I did actually take the time for myself to dissect and re-implement it in my environment.But because i am a nice guy and have some time, here's a high level overview:Setup:For a given heightmap texture, build a quad tree hierarchy of nodes, calculate their bounding boxes, offsets and sizes.prepare a regular gridmesh the size of a single nodecalculate lod level ranges and transition areas from higher to lower lod level (this can also be done in the loop).In the loop:select the nodes that appear in the view frustum, sort them front to backfor every selected node, draw the gridmeshfor every vertex/grid mesh position:calculate the world position and determine the distance to the camera from the node's offset and size.use lod level ranges to morph the base grid from higher to lower levels, displacing the positions slightly in 2d. Don't forget height displacement (

trsh
trsh

Actually I just understood that! It tests every time the 4 child's for if it's not in more finest level. Now Im trying to understand (make a picture in my head :D), how cdlod handles when you are vertically away from the mesh (like far away from planet)

trsh
trsh

Ok I think I understood that! Sorry for trolling!

"For a given heightmap texture, build a quad tree hierarchy of nodes, calculate their bounding boxes, offsets and sizes"

I don't understand yet this part. How is the quad tree generated from height-map. What does it mean? How does the height-map effect the quad tree structure?

Green_Baron
Green_Baron

Yeah, ok.

But that is all explained in great detail in the paper linked on the github account, i can't do it any better. And, btw., i had to read it 2 or 3 times as well, if that comforts you :-)

If you want to go with cdlod (which imo is the most straight forward take on terrain lod, others are more complicated), let me suggest that you build a basic version of the algorithm, without normal- and shadow mapping, building a node hierarchy, doing the selection process, and only draw the bounding boxes without terrain yet. You'll need that functionality anyway later for debug purposes.

trsh
trsh


hangchuyenhang said:

good. i like




Whaat?

trsh
trsh


Green_Baron said:

Yeah, ok.

But that is all explained in great detail in the paper linked on the github account, i can't do it any better. And, btw., i had to read it 2 or 3 times as well, if that comforts you :-)

If you want to go with cdlod (which imo is the most straight forward take on terrain lod, others are more complicated), let me suggest that you build a basic version of the algorithm, without normal- and shadow mapping, building a node hierarchy, doing the selection process, and only draw the bounding boxes without terrain yet. You'll need that functionality anyway later for debug purposes.




I opened a thread in https://gamedev.stackexchange.com/questions/177378/question-about-cdlod-quad-tree . Maybe u can look into. I also read the paper 4-5 times. But this questions don't think are answered there

Green_Baron
Green_Baron

Ok, i think i understand your problem.

For this kind of lod technique you need the heightmap texture. That can be a perlin noise generated texture, but it needs to be fully available in its finest grain when the tile is loaded and it's quadtree is generated. Calculating min/max heights for a region of that tile, a node, is then nothing more than a nested loop and a comparison.

Somebody interrupt me if i talk nonsense, but i think that if you use a noise function to generate your terrain "on the fly", you must take a different approach for lodding, e.g. refine the octave or frequency as you come closer and generate your mesh accordingly. All the lod we talked about until now requires the data to be available when the spacial data structure is generated, or that it can be generated or loaded fast enough even at the highest detail level. Which is, if i may say, impossible with todays technique at interactive rates when using noise for a planet's surface at a resolution of let's say 10m.

Hope that wasn't totally nonsensical, if so, maybe a more experienced person helps me out.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.