Behind the Scenes – Planet LOD
Added 2018-09-04 08:19:22 +0000 UTCHello! I've been working on a level of detail (LOD) system for the procedural planets series. It's still a ways away from completion, but I thought I'd update you on my progress.
The first thing I wanted to get working was a 'spherical quadtree' (SQT) – essentially just 6 quadtrees making up a cube, which can then be mapped to a sphere.
I began by creating an SQT and Quad class. Quad implements a fairly standard quadtree, while SQT is responsible for creating 6 of these quadtrees, and storing which direction they face in 3d space (to form a cube). To verify everything was working correctly (and also with idea of using as a visual aid in the eventual tutorial series) I created a little scene editor where I could click on the faces of a cube and it would update and draw the SQT.

The next thing I wanted was to be able to calculate the 4 neighbouring quads of any given quad. This is because I wanted to enforce adjacent quads to never be more than one division bigger or smaller. This will make it much easier to fix the cracks that will occur between adjacent meshes of a different LOD (something I learned from this KSP Unite talk).
As a starting point, I found this article which described a nice algorithm for finding neighbours on a single quadtree. I just needed to extend the search across adjacent faces for edge/corner quads.
Once implemented, I could right-click on any quad and it would highlight its four neighbours. (Red = North, Orange = East, Yellow = South, Green = North).

However, as you can see from the gif above, neighbours are sometimes incorrect across adjacent faces. This is because (for example) the North edge of the Right face is adjacent to the East edge of the Top face (should be South). This inconsistency between the coordinate systems of different faces is what was messing the algorithm up.

My current solution is to create a 2d array in the SQT that stores the necessary information to convert between the coordinate systems of any two adjacent faces:

Neighbours now work correctly across all adjacent faces. This allows me to keep all adjacent quads within one division level of each other.

The next task will be to spawn meshes based on this SQT, and fix the cracks that occur between them. I'll keep you updated :>
Comments
I would love to hear about it as well. Even using octrees !
2020-05-15 21:14:46 +0000 UTCAny news about the LOD system ? :)
2019-03-20 16:10:32 +0000 UTCi have some questions 1- is your work still in progress with LOD for procedural planet generation ? 2- will you plan any ecs or hybrid aproach for future tutorials or conversion of existant one ?
2019-02-26 21:58:26 +0000 UTChey great job with you're tutorials, you are awesome !
2019-02-26 21:49:56 +0000 UTCCool :-)
2019-01-18 19:01:54 +0000 UTCWhen you will post the tutorial for thtat ?
2018-10-03 13:32:06 +0000 UTCVery smart. I am thinking in a similar solution for a pathfinding system for the planet. Keep the good working.
2018-09-04 12:48:10 +0000 UTCThanks :) The plan atm is to do a separate series just on the LOD system, and then integrate the solution into the current planets series. Definitely interesting to have the amount of detail based on amount of noise. Would like to do a tut on something like ROAM at one point... Not sure what you mean about reversing the process?
Sebastian Lague
2018-09-04 10:43:47 +0000 UTC