Search Unity

Planetary Terrain Quadtree LOD Problems

Discussion in 'Scripting' started by Chimera3D, Mar 17, 2014.

  1. Chimera3D

    Chimera3D

    Joined:
    Jan 27, 2012
    Posts:
    73
    I am working on a procedural planet generator which generates six quads, that initially resemble a cube, but the vertices are then distorted so that the cube then resembles a sphere. From what I know, many spherical terrain systems use this approach. I also have a quad-tree level of detail system set up that subdivides quads or 'nodes' once the camera nears them or collapses them as the distance between the leaf nodes and the camera increases. Images below showing this process.

    $Screenshot2.png
    This quad of six faces becomes...

    $Screenshot3.png
    There are problems with the normals here, between quads but I know how to fix that.

    $QuadtreeSubdivision.png
    The third picture shows the result of the level of detail subdivision. Below there is a fourth image, a close-up of the first problem.

    $Problem1.png

    The selected quad has four neighbors in the four lateral directions, the east and south neighbors are on the same subdivision level, which is fine. The west neighbor is of one level higher, also fine, however the north neighbor is several subdivision levels higher than the selected quad, I can't figure out why. It is important for the neighbors of a quad to be of the same, one lower, or one higher subdivision level otherwise this creates problems when 'smoothing' the vertices between quads of different subdivision levels. This is the first problem I need to fix.

    The second problem involves why the last problem is really a problem. I have a system in place that can 'smooth' the vertices between quads but first I need to be able to find the neighbors of a quad. The primary complication of finding the neighbors is that I have to be able to find the neighbors of a quad between different, entire quad trees. For example in the third screenshot, the camera is placed at a 'seam' between two quad trees, in these cases I have to be able to find the neighbors between those two quad trees (or even three, if the camera is at a 'corner' of the sphere. This means that I have to use some sort of distance calculation and compare the distances between quads to determine neighbors, however, I suspect that doing this for every node, constantly will be very inefficient.

    This is what I mean by 'smoothing' vertices.
    $SmoothedVertices.png

    The final problem is that once I find the neighbors of a quad I need to be able to determine if that neighbor is north, south, east, or west of the quad. If anybody can help me with any of these problems, then that help would be greatly appreciated, anyhow thanks for your time for reading this.
     
  2. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    222
    Hi. Can you please point me in a dirrection of a tutorial about creating such a quadtree in Unity please?)