How do you tell the front or back of a triangle in a shader?

Now I’m going to draw an object, and I’m going to look at it from the front with some holes, and I can see the back through the holes, and I want to draw the back in another color, right?I know one way to do it is to use the face rejection technique, using two piece shaders, the first time to remove the back and draw the front, and the second time to remove the front and draw the back.But it takes twice as long.In addition, I read that the elimination technology can improve the rendering efficiency, but I used the efficiency is the same why?

In the fragment shader, the variable gl_FrontFacing is true if the triangle is front-facing.

Thank you very much for your help!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.