How to do Culling?

Hello,

I have a question about Culling:
a) How can I use Backface-Culling?
b) How can I cull Objects which are behind the Player?

this are 2 sorts of culling

a/ glEnable( GL_CULL_FACE ), u can also do the math yourself but 1/ it might be slower on hardware t+l cards 2/ u’re restricted to using GL_TRIANGLES ie u can use strips
b/ get the near clipplane (info in the faq for this) and test if the objects BB or all polygons are in front of it.

You can write a decent culling function for frustrum culling (dont draw objects outside of the view frustrum). I have an example down the bottom. Note that this is rather slower (alot) than using advanced techniques such as Quadtrees. But it is far better than no culling at all or just “behind the camera” culling.

int cull(float x, float y, float z){
if((z + zoom) >= -1.0 | | -(z + zoom) < 2.4*(x-4.0) | | -(z + zoom) < -2.4*(x-3.5)){
return 1;
}
else{
return 0;
}
}

This assumes 45 degree viewing frustrum…

There another quick way of culling objects and it involves the view volume. Whatever that is not inside it, you remove it.

Today, octrees and BSPs seem to be popular but these don’t apply to some situations.

V-man

BSP’s are getting old fashioned right now. They are too restrictive, and get complicated if you want dynamic scenes. Collision detection may be faster. We also don’t need back to front rendering anymore, since when using stencil test, zbuffer come for free!
I’d try to use a combination of sector/portal and octree.