Facing information accessible by fragment shader

With built-in culling disabled, it might be useful to have something like a read-only “bool front_facing” passed from the projection/culling stage into the fragment shader.
With ‘kill’, culling could easily be replicated in the fragment shader, so this should not be an issue.
This could be useful for
1)reducing pass count for shadow generation
2)two-sided lighting
3)other things that haven’t come to my mind yet

An alternate approach might as well be to offer two distinct fragment shaders for backfaces and frontfaces, though this would greatly complicate the hardware implementation. This could also be handled automatically by the API and wouldn’t have to be exposed to the client application.

Any thoughts?

It may not be obvious, but it’s already there. See p. 43 and p. 46 of the OpenGL 2.0 Shading Language White Paper (1.2).

(Only in the fragment processor, of course. Vertices don’t know their facing, though a programmer could of course pass in a user-defined myFacetNormal attribute to each vertex.)

-mr. bill

Oh my, I must have been blind! And better yet, it’s exactly the way I would have wanted it … err … if it weren’t already there!
Thanks for the heads up!