3D clipping and gluPerspective()

i am a little confused about 3D clipping using gluPerspective(). from what ive read, i thought that anything out side of the viewable ‘perspective’ should not be rendered (ie. no projection calculations done). but i did a little test and i dont think this is the case…

i added 50 high poly models to an area of the scene. when looking at them (they are inside viewable frustum) the program was slow and choppy as excpected. When i turned the camera away from them (no longer in the viewable perspective/frustum) the program was still slow and choppy which implies rendering calculations are still being done for these non-viewable objects.

my question is: do i have to manually calculate what is viewable and only draw/render that? or can openGL (gluPerspective) do this for me. if it can do the 3D clipping for me, what am i doing wrong??

this is how i set up my perspective…

gluPerspective(55.0f,(GLfloat)width/(GLfloat)height,0.1f,50.0f);

Hey Perspective,

OpenGL clips the polygons outside the view frustum after all the vertex operations in the pipeline. If you want to lower the work done at the vertex operation stage, then you need to do your own clipping at the software level (before data goes into the videocard).

                         - Halcyon

yeah, thats what i figured i would have to do. im thinking i will keep 5 plane equations (representing the view frustrum) and check world coordinates to see if objects are viewable or not. does this sound like a good aproach or are there better ways?

you actually have to keep 6 equations (near, far, left, right, bottom, top). a very nice approach how to compute eqautions from current matrices is here http://www.markmorley.com/opengl/frustumculling.html

i was just promoted to frequent contributor!!! (i know a little less than glVertex but i’m a frequent contributor ) maybe i should stop kidding…

yeah, thats right. but if i calculate the 5 plane equations based on the camera position then the ‘front’ plane (closest to camera) is just orthogonal to the camera direction, so world coordinates of objects behind the camera’s point are behind the front plane. this would save storing the front clipping plane and the camera’s position as 2 different things. i only need the camera position/direction and the left, right, top, bottom, and back planes.

thanx for the link, i will check that out.

www.gametutorials.com has another tut on frustum culling.