0

I know there's a similar question with a quasi exact title : Back Face Culling for Line Loop

Actually I want to draw a wireframe containing triangles and quads and consequently, I really have to cull elements drawn as GL_LINE_LOOP.

In the past (when I had only triangles in my wireframe) I used the glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) solution. This way it works but now my quads are crossed by one of their diagonal.

Do you have a solution to this problem?

BDL
  • 21,052
  • 22
  • 49
  • 55
kipgon
  • 131
  • 14
  • The linked question already explains it: There is no way to have backface culling for lines. The only thing you could do is implement it in some shader yourself: https://community.khronos.org/t/backface-culling-gl-lines/68993/7 – BDL Feb 04 '20 at 12:54
  • So shaders are a solution. I'm not good with shaders. I currently use the simplest fragment and vertex shaders possible. Can you give me some explanations about how to use shaders to do this job ? – kipgon Feb 04 '20 at 13:01
  • Basically, you'll have to add the normal of the corresponding face to each line/vertex. In the vertex shader, you calculate the angle between view-vector and normal and discard vertices where the angle is > 90°. – BDL Feb 04 '20 at 13:04
  • Yes, I read your link. Thank you very much. I'm diving into shaders and I'll tell you. – kipgon Feb 04 '20 at 13:17
  • but do not forget to render all shared edges twice (each with different normal) – Spektre Feb 05 '20 at 09:21

0 Answers0