PDA

View Full Version : Fragment face data



AvCol
01-20-2011, 03:32 PM
Hi everyone,

I am wondering if there is any quick access to information on whether or not a fragment is the back or front face of a polygon from within the pixel shader?

I suspect that there isn't and that something like culling happens in the primitive assembly stage.

Could I get face information by calculating a cross product per primitive in the geometry shader, and then pass it to the pixel shader as an out?

Any advice would be much appreciated.

Alfonse Reinheart
01-20-2011, 03:51 PM
I am wondering if there is any quick access to information on whether or not a fragment is the back or front face of a polygon from within the pixel shader?

The built-in boolean fragment shader input: gl_FrontFacing.


I suspect that there isn't and that something like culling happens in the primitive assembly stage.

Yes. But if you're not doing backface culling, you can simply tell OpenGL which side is the front, and gl_FrontFacing will be false for fragments of the back triangle.

AvCol
01-20-2011, 08:31 PM
Thank you very much for the reply.

I am playing around with the stencil and depth buffers for volumetric shadows / crepuscular rays.

I actually have another question, which I will post in another thread.