0
101 Aug 28, 2003 at 11:08

What is Face Culling? :wtf:

I can’t get it working right on my cube :blush: !

#### 8 Replies

0
101 Aug 28, 2003 at 12:31

using face culling you avoid drawing polygons that are invisible because they are facing away from the viewer. in terms of a convex object like a cube these are the faces (and only these) you cannot see (and therefore dont need to draw).

mathematically you can determine back facing polygons by taking the dot product between the (camera-space) normal of the polygon and the camera viewing direction(negative draw/positive cull or vice versa).

but since you are probably using opengl or directx this boils down to setting a flag i.e. glEnable(GL_CULL_FACE); for opengl.

if something looks screwed up now, then opengl may assume a different winding order of the vertices so you have to glCullFace( GL_FRONT/GL_BACK );. If still something looks screwed up your faces have no common winding order in which case you either forget about bf culling or edit your model so that all faces have the same winding order.

0
101 Aug 28, 2003 at 12:38

hmm, i should learn to read…
or did i understand correctly that you meant back-face culling ?

0
101 Aug 28, 2003 at 12:52

:yes: Thanks … but I know what it does. The main problem which I think I should have mentioned in the first place is that how to draw the cube when BACK FACE CULLING is enabled or how to wind up things like you said :blush: ?

I mean which face to be drawn first and which one next? :nervous:

0
101 Aug 28, 2003 at 13:24

you can draw the faces in any order you want…

winding order : opengl must somehow calculate the normal of a face to calculate the dot product between the camera vector and face normal. so opengl uses the std aproach by taking three points of the face and computing a normal with that. the problem here is that the order in which you give opengl the points matters for the normal calculation.
if you do this

p1

p2
|
|
p3

you will get a normal that is the exact oposite to the normal you would get if you did this

p1

p3
|
|
p2

so you have to make sure that all faces have the same winding order.

drawing order :

the order in which you draw the surfaces doesn’t matter because opengl has the so called depth buffer. ever pixel has a depth ( z ) value that get’s written to the depth buffer. when a new pixel is drawn it is first looked up in the depthbuffer and only drawn to the backbuffer if the new pixel’s z value is smaller then the current pixel’s z value.

0
101 Aug 28, 2003 at 14:04

The order in which I draw a surface is as follows :

1) Top Left Point.
2) Top Right Point.
3) Bottom Right Point.
4) Bottom Left Point.

and the surfaces :

1) Front Face.
2) Left Face.
3) Back Face.
4) Right Face.
5) Top Face.
6) Bottom Face.

But it doesn’t seem to work … :confused:

0
101 Aug 28, 2003 at 14:46

hmm, can you explain what actually does not work ?
are some face culled which should not and vice versa ?
if so i have an idea what goes wrong.

0
101 Aug 28, 2003 at 14:57

right now i’m not sure wether opengl’s std windign order is clock- or counterclockwise… anyway… yours is clockwise and so you should tell opengl that with this call :glFrontFace(GL_CW); and then you might also need to tell it to cull back facing polygons like this : glCullFace(GL_BACK). this should solve your problems if they are related to culling.
if not i guess that your probs are depthbuffer related

0
101 Aug 29, 2003 at 02:57

:yes: OK, thanks, I will try when I’ll reach home … :blush: