PDA

View Full Version : How to do Culling?



07-24-2001, 08:49 AM
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?

zed
07-24-2001, 12:37 PM
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.

MrShoe
07-24-2001, 11:23 PM
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 &#0124; &#0124; -(z + zoom) < 2.4*(x-4.0) &#0124; &#0124; -(z + zoom) < -2.4*(x-3.5)){
return 1;
}
else{
return 0;
}
}

This assumes 45 degree viewing frustrum...

V--man
07-25-2001, 10:24 AM
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

Michael Steinberg
07-25-2001, 01:45 PM
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! http://www.opengl.org/discussion_boards/ubb/smile.gif
I'd try to use a combination of sector/portal and octree.