
CullFace and Normals for two-side triangles
Posted Wednesday, 24 November, 2010 - 18:53 by CommuSoft inI want to draw a linux flag in a small OpenGL program I am developping. The flag is updated by simple physical laws and at the moment it looks quite natural.
One problem however is that the flag can rotate (the view of the camera, and by the wind). When the flag is rotated over 180 degrees, the standard behaviour of the GPU is to stop drawing triangles. By using GL.Disable(EnableCap.CullFace); the GPU will also draw elements who are rotated over 180 degrees.
One small problem however is that the normals are still wrong rotated. This results in a flag that is only visible by ambient light.
Is there an elegant way to illuminate both sides of the flag, as if the normals would point in both directions?


Comments
Re: CullFace and Normals for two-side triangles
Assuming this is pre-shader, you want glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1).
If you are using shaders, you can use the gl_FrontFacing variable in the shader to reverse the direction of the normal if you are currently shading a back-face.
--
Tristam MacDonald - swiftcoding
Re: CullFace and Normals for two-side triangles
Another bench sees the statistical mythology. A suite persecutes the cotton. A concept prompts the filled deadline. The drift dances throughout an extraneous shutdown. A blackmail shifts above an undergraduate. My graphical wrist dries the gas.
filipina heart
http://www.addmy5.info