PDA

View Full Version : Frustum Culling



Jim Jones
07-18-2005, 02:49 PM
Would like to cull in world space. My artist using 3dmax is able to give me a center point and radius (farthest point) for each scene object. Have tried to extract planes from a variety of matrix mixes. Regardless I end up with values which hover around 1; that suspiciously look like something close to clip values. So, thought I would use the standard clip values and transform them with various combinations of projection and model view. Same results as above.
Finally, I pulled out my game programming math book and calculated the initial world space places. For example, with a far clip of 2000 my side vectors had z values of -1000+, other values were commencerate(sp?). The idea was that I would transform these planes as I moved around the scene. Unfortunately, the transform reverted the planes to the same kind of "hover around 1" values I got before.
I am assuming that the max world space is the same as OpenGL camera/eye/view space, i.e. the space in which if an object has a position in the scene of x,y,z (the place that it is drawn) then it exists at that point.
I've seen the pipeline drawings showing the matrices that convert from one space to another going down the pipeline.
Q1 What are the matrix states that will convert the other way?
Q2 Am I correct that in order to clip in world space I need a frustum with plane values that reflect the far clip value I put in?
Q3 Is it correct that I need to extract the planes each frame or transform some initial set?
Have all the OpenGl standard texts and then some, have foraged through all the forums I can find including this group.
Thanks for consideration,
Jim

CrazyButcher
07-19-2005, 12:01 AM
http://www.flipcode.com/articles/article_frustumculling.shtml

this should help, also links to a raven paper about frustum worldspace plane extraction from gl matrices.

oh and make sure your exported stuff is really in the same coordinates, max does Z up, while GL has Y up, no problem to convert it so, just some camera rotation...

also you dont need to transform those planes, just freshly extract them every frame from your modelviewproj matrix.

another culling optimisation might be not checking against planes, but cone against sphere as a quicker approximation.

hope that tutorial helps a bit, it certainly helped me