Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Two planes with different texture at the same depth - flashing texture

  1. #1
    Newbie Newbie
    Join Date
    Oct 2018
    Posts
    2

    Two planes with different texture at the same depth - flashing texture

    Hi, I'm currently trying to fix this problem where I have two planes with same Y position and their different textures are clipping so it ends up looking bad. How do I approach this problem?

    Click image for larger version. 

Name:	Problem.jpg 
Views:	26 
Size:	15.4 KB 
ID:	2869

    -Thank you! ^^

  2. #2
    Junior Member Regular Contributor
    Join Date
    May 2013
    Posts
    142
    That is called z-fighting. You prevent it by not having overlapping planes like that. E.g. in your case the outer floor would need to be made out of more triangles to have a fitting hole in the center. Or you can "cheat" and just make the small room slightly higher. But that may still cause z-fighting if you get farther away and use classical (read: bad) depth precision.

  3. #3
    Newbie Newbie
    Join Date
    Oct 2018
    Posts
    2
    Quote Originally Posted by Osbios View Post
    That is called z-fighting. You prevent it by not having overlapping planes like that. E.g. in your case the outer floor would need to be made out of more triangles to have a fitting hole in the center. Or you can "cheat" and just make the small room slightly higher. But that may still cause z-fighting if you get farther away and use classical (read: bad) depth precision.

    Thank you, I'll look into it

  4. #4
    Intern Contributor
    Join Date
    Oct 2014
    Posts
    73
    Because of this thread I started reading about depth buffering again. ---> https://www.khronos.org/opengl/wiki/...ffer_Precision

    Now I have an additional question:
    In the posted link they mentioned that it is possible to divide your scene into multiple depth zones and use use the full depth buffer for each zone with a multi pass approach. How does this work? Do I start with the farthest zone and clear the depth buffer each time when I render the next zone (which is closer to the cam)?

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,542
    Quote Originally Posted by ProgrammerX View Post
    In the posted link they mentioned that it is possible to divide your scene into multiple depth zones and use use the full depth buffer for each zone with a multi pass approach.
    How does this work?
    Do I start with the farthest zone and clear the depth buffer each time when I render the next zone (which is closer to the cam)?
    You can do it a couple ways. In both cases, you partition the full frustum eye-space Z depth range into 2 or more pieces.

    On the draw side...

    1. You can partition the full 0..1 depth range into pieces, and then render each pass to its own subset of the full 0..1 depth range (set via glDepthRange).
    2. Alternatively, if you want/need to use the full 0..1 depth range for each piece, for each pass you can just clear the depth buffer and render that partition into the full 0..1 depth range. Then repeat this process for the subsequent pass(es).


    In the 1st technique, you need to use something like Z clip planes to prevent objects from rasterizing outside the Z bounds of their frustum partition (e.g. for the case when objects overlap a partition boundary). This avoids double-draw problems.


    In the 2nd technique, note that each frustum Z partition has its own near and far, so it's got its own projection matrix.

    On the cull (draw prep) side, you would take your full view frustum that you cull objects into and split it along planes of constant eye-space Z. So basically partition it in Z like you would do with Cascaded Shadow Maps. Then when you're culling the world to extract just what intersects with the view frustum, you bin your objects by frustum partitions. This gives you a separate "draw list" to draw for each frustum partition.
    Last edited by Dark Photon; 11-07-2018 at 06:37 AM.

  6. #6
    Intern Contributor
    Join Date
    Oct 2014
    Posts
    73
    Thank you for the explanation. Always nice to learn something new here.

Posting Permissions

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