Howto deal with floating point roundoff Issues in 3d geometry

Hello,

I have a 3D world surrounded by a Skybox. Due to the nature of the geometry it has many floating point coordinates that were rounded off during creation. This leads to undisired small “gaps” in my 3D world appearing as I move around letting some pixels from the 3D Skybox get through. Now the geometry issue is something I cannot fix right now so I started to look for other solutions. Without the skybox I don’t even notice these gaps and that is exactly what I want! Stencil buffer seems to be out of the question since it operates on the pixel layer so it probalby won’t help me to prevent the skybox shining through the pixels that make up the gaps, right?

Does anyone have an Idea how to approach this issue without cahsing too much drawbacks like in performance?

Kind regards
Saski

Your problem seems to be that your geometry is broken. That it has gaps (regardless of where they come from). But you find that you don’t notice the gaps so easily if the background is a solid color.

Well, OpenGL can’t magically know which pixels not being drawn by a triangular model are “gaps” and which pixels are not. After all, a"gap" is simply where no triangle was drawn. How can OpenGL know that one particular area where triangles didn’t draw is a “gap”, while another area is just somewhere around the mesh?

So there’s no way to put something into those gaps, to draw the background differently within those gaps than elsewhere.

The only viable solution is to fix your mesh.

As Alfonse, you need to fix your mesh. Note that round-off of the point coordinates is no problem, so long as all of the triangles referencing each point have the same rounded off value for that point. The simplest way to force this is to use indexed vertices, where the point positions are shared across all triangles.

You may be able to scan the mesh and “snap” points that are close-enough to be the same point. but that’s going to depend on your data (spacing between real points, amount of imprecision in the coordinates, consistency with rounding, etc.) Better to just fix the source data than to try to doctor up broken mesh data on the back-end.

Also, ensure that your mesh has no “T-junctions”. Websearch it if you won’t know what this is. This can lead to rasterization “holes”.

Yeah I was afraid that there is no “magic” and that the “mesh” has to be fixed somehow. I’ve added full float32 precision and used VBO/IBO to fast index the geometry. But the issue still remains. Thanks for mentioning the t-junction issue cause they seem to be in my geometry a lot so I guess there is still some more optimization/cleanup to do! funny thing the gaps are only visible when I roll (i.e. rotate around z-axis). Pitching/Yawing looks fine. How can this be?

Thanks very much for pointing me to the right direction :slight_smile: