-1

When you display in OpenGL thin parts with edges, zooming away these edges become visible.

How can we avoid this?

Recently some CAD systems added an option for this. A final pass, after dynamic movements, that cleans these leaked edges away. This demonstrates that implementing this is possible, what approach should I used?

Thanks.

enter image description here

References:

abenci
  • 8,422
  • 19
  • 69
  • 134
  • 2
    Maybe the answer to ["Depth offset in OpenGL"](https://stackoverflow.com/questions/45314290/depth-offset-in-opengl/45317626#45317626) will help. – Rabbid76 Sep 04 '17 at 11:08

1 Answers1

0

This can happen when your inner and outer mesh doesn't share exactly the same vertices where they touch each other. It's hard to describe it by words but I'll try.

Imagine the simplest version of capital 'T' letter - just two lines, horizontal and vertical. They touch each other but don't share any geometry, they are just two separate lines.

When you render those lines in 3D then all 4 end points go through some transforms and end up at some points on the screen.

At some camera angles it's possible that (due to rounding errors) the center of your horizontal line won't exactly match the top of your vertical line. This causes 1 pixel wide holes popping out on your rendering.

To solve it you should split the top line in half, making sure that all lines (now 3 instead of 2) share the vertex at the center of top line. This way all your lines will always end up at the same place on the screen.

I hope this helps but if you still have problems with it I can draw you some pictures.

kolenda
  • 2,741
  • 2
  • 19
  • 30
  • You are right but SolidWorks can clean these artifacts in one extra pass, what I am trying to figure out is how do they do it. – abenci Sep 12 '17 at 07:51
  • Basically you're looking for vertices that lie on an edge of another triangle or polygon. If you find such then you split the edge at this point and share the vertex between all resulting triangles/polys. For triangles it should be quite simple but for polys it may get complicated very fast because you need to triangulate them correctly. – kolenda Sep 12 '17 at 08:02