gl_FrontFacing Mystery

I have a shader that works great on all the machines I’ve tested except for a couple of laptops. There are 4 laptops each with an nVidia Quadro FX Go 1400 card… two of them render fine, the other two don’t.

The reason the shader does not work appears to be related to gl_FrontFacing. If I replace gl_FrontFacing with just a constant bool (like ‘true’) then it works fine… but of course I don’t get the benefit of detecting the face direction.

I’ve installed the latest driver for the card (with assistance from but it still does not work. What else should I be looking for? I’ve looked all over nVidia’s website, but can’t find anything that remotely helps.

Thanks in advance!


This might be a driver issue.

not every quadro supports gl_FrontFacing in fragment shader.

Yes as shelll said not all cards support gl_FrontFacing.
One trick you can use is enable GL_VERTEX_PROGRAM_TWO_SIDE_ARB

Then in your vertex shader write a 1 to gl_FrontSecondaryColor.a and 0 to gl_BackSecondaryColor.a.

In your pixel shader gl_SecondaryColor.a will tell you if your polygon is front or back facing.

Read this:

Thanks for the tips. I got it working using the GL_VERTEX_PROGRAM_TWO_SIDE trick, but is this safe to use? Will it work on all graphics cards?