View Full Version : Polygon Front and Back faces
10-24-2003, 09:26 PM
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.
10-25-2003, 07:24 AM
glMaterialfv( GL_FRONT, ....
glMaterialfv( GL_BACK, ....
[This message has been edited by CatAtWork (edited 10-25-2003).]
10-25-2003, 12:02 PM
10-25-2003, 02:50 PM
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.
10-25-2003, 03:24 PM
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).]
10-25-2003, 03:31 PM
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.
10-25-2003, 03:51 PM
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.
10-27-2003, 05:24 AM
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.
10-27-2003, 04:18 PM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.