What is Face Culling? :wtf:
I can't get it working right on my cube !
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.
hmm, i should learn to read...
or did i understand correctly that you meant back-face culling ?
: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 ?
I mean which face to be drawn first and which one next? :nervous:
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
you will get a normal that is the exact oposite to the normal you would get if you did this
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.
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 ...
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.
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
:yes: OK, thanks, I will try when I'll reach home ...