Is there any way to draw the front face of a polygon solid and the back face stippled? Or to draw the front face one color and the back face a different color? I don’t want to draw the front face filled and the back face with just lines because it might make it look like I have missing elements in my mesh. I just want a good way to visually identify if an element is facing the wrong direction in my model.
glMaterialfv( GL_FRONT, …
glMaterialfv( GL_BACK, …
[This message has been edited by CatAtWork (edited 10-25-2003).]
I don’t think he wants that Eric.
“I don’t want to draw the front face filled and the back face with just lines because it might make it look like I have missing elements in my mesh.”
Oh yeah, a little OT, but do you still get royalties by buying your books through your website? (instead of Borders, etc.) Tempted to buy your Mathematics for Games 2nd ed. in December.
Ah – you’re right. Sorry, I didn’t read the question carefully enough. Different suggestion below.
Yes, the website is:
The book is actually being printed now and will be out in November. Thanks!
[This message has been edited by Eric Lengyel (edited 10-25-2003).]
If you’re using vertex programs, try enabling GL_VERTEX_PROGRAM_TWO_SIDE_ARB and writing different colors to result.color.front and result.color.back. Then the primary color during rasterization will be different for front/back faces.
Another way that hasn’t been mentioned:
Draw your geometry twice; first using CullFace( BACK ) and regular materials, and the second time using CullFace( FRONT ) and some other material (or perhaps 50% alpha blending, or whatever).
LIGHT_MODEL_TWO_SIDE isn’t what jmikhael wants, because lighting looks at the position of lights versus the direction of normals, whereas he wants to compare the winding of the face (not normal) to the camera position.
The only decision needed for front or back faces is the winding order of screen coordinates.
Normals are are inverted for back faces.
There’s also ambient lighting which doesn’t need normals at all.
To use the glMaterial(GL_BACK) settings you need to enable LIGHT_MODEL_TWO_SIDE.
Allright; you are correct; setting different ambient terms (for example) would accomplish what the poster wants. Doing two passes may be more efficient on hardware that doesn’t support two-sided lighting, although pretty much all modern hardware should support that.