Backface culling

Started by
3 comments, last by PH-Neutre 23 years, 11 months ago
hi, what exactly is backface culling, and how to implemente it with OpenGL ? Thanks in advance, PH.
Advertisement
Backface culling is to suppress the backfaces polygons.
Backfacing polygons are pols that are not facing you, that''s the ones that you don''t need to render.

Imagine a plane.
It''s define by 2 quads, one for each face.
Do you really want to compute vertex lighting, mapping... on the side you don''t see ?
No, so you do backface culling.

OpenGL (as well as Direct3D) did it for you I think you must activate it (if it''s not the default value) with the glEnable() command.

Notice that OpenGL (and Direct3D) are doing backface 2D culling at the end of the process (just before displaying), you can save extra operations by doing 3D culling using surface normals before the projection as been computed.

In 3d gfx (like anywhere) you must suppress as much stuff as you can as soon as possible.

Hope it helps.

-* Sounds, music and story makes the difference between good and great games *-
-* So many things to do, so little time to spend. *-
The actual code to do this is:

glCullFace( GL_BACK );
glEnable( GL_CULL_FACE );

Remember that the vertices of your triangles, polygons, etc, must entered counter-clockwise for it to work correctly;

Morgan
Thanks a lot, Ingenu and Morgan !
It helps me a lot.

PH.
To clear up a little thing, you can actually set vertex order any way you want, and you can tell OpenGL which way will be forward.
You can set glCullFace( GL_FRONT ) , for example,
or use glFrontFace( GL_CCW ) or glFrontFace( GL_CW );

So basically, you can pick which way is forward if you want.

What morgan described is the default setting if you don''t change anything.


#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.

This topic is closed to new replies.

Advertisement