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?

[ATTACH=CONFIG]1880[/ATTACH]

-Thank you! ^^

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:)

Because of this thread I started reading about depth buffering again. —> https://www.khronos.org/opengl/wiki/Depth_Buffer_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)?

[QUOTE=ProgrammerX;1292920]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)?[/QUOTE]

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…

[ol]
[li]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).[/li][li]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).[/li][/ol]

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.

Thank you for the explanation. Always nice to learn something new here. :slight_smile: