Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 08:52:56 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)OpenGL weird "edge bleeding"...?
Pages: [1]
Print
Author Topic: OpenGL weird "edge bleeding"...?  (Read 1591 times)
Jagnat
Level 0
**



View Profile WWW
« on: August 31, 2015, 11:45:55 AM »

I'm getting a weird visual bug, where perpendicular colored polygons seem to "bleed" through their neighbors. I did some research, and found that it might have been an issue with the near and far values of my FOV matrix. Following this: http://outerra.blogspot.com/2012/11/maximizing-depth-buffer-range-and.html article, I implemented a logarithmic depth calculation in my vertex shader which helped the issue, but didn't completely fix it. I'm using C++ and SDL2 with glew, if that matters.

In this example I'm rendering four cubes in a larger cube, without any culling, which clearly shows the problem.

Before the depth buffer fix:


After:


As you can see, however, I'm still getting pretty noticeable seams showing through. Has anybody else dealt with this?
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #1 on: August 31, 2015, 12:15:41 PM »

Classic z-fighting. A few things come to mind that could help:

- Make sure the vertex positions for the corners that meet are identical. If you're applying a transform to each cube individually, they might not meet perfectly - seams like this happen when vertices that are supposed to be in the same position differ just slightly, or when a vertex is placed along an edge instead of at the position of another vertex.

- Try setting your depth func to GL_LEQUAL instead of GL_LESS and see how it changes the result. You might need to manipulate draw order to get this to work properly (as in, sort the cubes so they draw back to front).

- In this particular example, it wouldn't be a bad idea to eliminate the inner faces of each cube before submitting the geometry to GL. If they're never going to be seen anyway, you might as well not draw them, and it will prevent this problem from happening (though it might just mean you see the clear color through the seams instead of the color of the hidden face). I assume this is an isolated test case, so this might not be applicable to the situation where you've first observed the problem, but culling unseen geometry if you can do it is usually a good idea.

Edit: Since I can see green bleeding through the bottom of the blue face, it looks like you're drawing with backface culling disabled. Probably not a bad idea to turn that on too.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic