Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Chunked LoD cracks

  1. #1
    Intern Contributor
    Join Date
    Dec 2011
    Posts
    54

    Chunks cracks

    Hello,

    I'm here to ask for help.
    I have program for terrain editing, but I went into one problem I can't solve. Between each chunk is crack, how to fix it? I tried google it but I don't understand it.

    I have 4x4 field with class MapChunk. Each chunk has own data for heightmap. I render one by one chunk.

    Img:
    Click image for larger version. 

Name:	explain10.jpg 
Views:	88 
Size:	15.3 KB 
ID:	1350

    And there is my bug result:
    Click image for larger version. 

Name:	KjpGWDi.jpg 
Views:	114 
Size:	102.8 KB 
ID:	1351

    You can see on image red lines which mean end of chunk.

    And now my question... How can I connect first chunk with second? To dissapear these cracks.
    Also I want to note: I'm using 4 different textures per chunk.

    My draw function for chunk looks like:
    Code :
            // Render the quad as a patch
            {
                Mesh.bind(); // bind Vertex Array Object
                Mesh.createAttributeArray(IMesh::Vertices, shader, "vertexPosition", GL_FLOAT, 0, 2); // IMesh::Vertices == 0
     
                shader->setPatchVertexCount(1);
     
                world->getGLFunctions()->glDrawArrays(GL_PATCHES, 0, Mesh.getNumFaces()); // Mesh.getNumFaces() == 1600
            }

    Thanks.
    Last edited by glararan; 06-29-2014 at 03:33 AM.

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,162
    First, let's clear up that your approach is not a chunked LOD, because it is not a LOD scheme at all.
    You have just divided your map into tiles. Are you using quadtree or calculate screen-error metric to choose a proper chunk?
    I guess the answers to both questions are negative, so it is not a LOD scheme.

    Let's back to the question. In order to stitch tiles, you have to:
    - calculate the influence of the modeling transformation (extrusion or whatever you are doing with the vertices) to all neighboring tiles, and modified all vertices influenced by the transformation,
    - add skirts around the perimeter of the tiles if vertices on the edges do not correspond to each other.

  3. #3
    Intern Contributor
    Join Date
    Dec 2011
    Posts
    54
    Yes I divided map into tiles and then to chunks. I thought its called LoD. I'm not using quadtree, using screen-error.

    I read something about skirts but I don't know how to make them. Yesterday I tried to google these "skirts" but no success. So if you can show me some example how to add them I will be glad.

    Thanks.

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,162
    LOD stands for Level-Of-Detail. It serves to manage the complexity of the objects on the scene. I guess you have just a set of tiles which geometry doesn't change as the viewer moves.

    It is quite simple to add skirts. If your tile consists of n x n vertices, just make a tile of (n+2) x (n+2) vertices instead, and move down the vertices at the edge, such that they create a drape. But no skirts can seamlessly stitch adjacent tiles if you change the vertices at one side of the border and not on the other, as you've shown on the fig.2.

  5. #5
    Intern Contributor
    Join Date
    Dec 2011
    Posts
    54
    Okay so, if I have 40x40 vertices = 1600 patches I should have 42x42 vertices = 1764 patches.

    My chunk heightmap is 256x256 (= 6,4 height values per patch). How this should work? If vertice is bigger than 40 then recalculate it somehow?

  6. #6
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,162
    I don't quite understand your math.
    You need 257x257 vertices per heighmap chunk in order to divide it into equal tiles (2x2 tiles of 129x129 vertices, 4x4 tiles of 65x65 vertices, etc.). The vertices on the edges are shared between tiles.
    If there are 4x4 tiles of 65x65 vertices, adding skirts results in 67x67 vertices, where vertex (1,1) corresponds to vertex (0,0) of the original tile. With skirts, not just a single row/column in each tile overlaps, but three. Of course, only a single row/column coincides.Others are lowered down.

  7. #7
    Intern Contributor
    Join Date
    Dec 2011
    Posts
    54
    Hm we don't understand each other

    Whole map (4x4 chunks)
    - Width: 1024
    - Height: 1024
    - Number of patches: 25600 (160 per row/column)

    One chunk
    - Width: 256
    - Height: 256
    - Number of patches: 1600 (40 per row/column)

    I little describe my program architecture...

    class World has 1 class of MapTile. MapTile owns 16 MapChunk classes. I don't draw MapTile, only MapChunk.

    MapChunk class:
    - float mapData[256 * 256] // height storage
    - Mesh contains patches (1600) and buffer with positionData for vertex
    - number of patches is calculated from "trianglesPerHeightSample*MAP_WIDTH/CHUNKS/maxTessellationLevel" (10 * 1024 / 4 / 64 == 40)

    -----
    So I should have number of patches calculated: (trianglesPerHeightSample*MAP_WIDTH/CHUNKS/maxTessellationLevel) + 2

    And should I increase MAP_WIDTH / CHUNKS (256) to 258?

  8. #8
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,162
    It seems that I'm beginning to understand the problem.

    You are using tessellation shaders to add details (you should mention that). The patch is actually a single height and a single vertex position (I don't know why you need a position, but that's probably because you don't have equally spaced vertices). The patches are expanded to 10x10 vertex grid in TS. I'm not aware of what's going on in TS, but let's say it's ok. When you modify a terrain, you actually modify the single vertex representing the patch on the CPU side. GPU moves the other 100 vertices produced by it, and you have no fine control over that. Are those assumptions correct?

    I have no other advice at the moment but to add a single patch wide ring around each chunk (overlapping with adjacent chunks), and modify it when modifying neighbors. More details are required in order to make some better proposal, but adding an outer ring to stitch chunks sounds ok.

  9. #9
    Intern Contributor
    Join Date
    Dec 2011
    Posts
    54
    Oh, sorry about I didn't mentioned tess. shader.

    Yes you're correct, I editing on CPU mapData and sending them to GPU. Yes I have no final control about mentioned vertices produced on GPU.

    -----
    To your advice, add wide ring around chunk should be part of chunk rendering or not? Btw do you know how to fix texture flickering? 2 heightmaps on same height value.

    I can add some video or source code?

  10. #10
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,162
    Well, after reconsidering the problem, it seems it is easier to add a ring around chunk separately, although I'm implementing skirts as a part of blocks (but have totally different approach compared to yours, and using no TS).
    Another approach would be to set tess. level to 12 (instead of 10) and lower down vertices at the edge of the chunk in tessellation evaluation shader.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •