Object/poly removal

I am at a point in my 3d engine where I need to start clipping polygons from the pipeline before I call glDrawElements. I know that OpenGL will take care of back face culling, but will it take care of not drawing polygons that are not in the viewing volume?

If I create a huge object, say a landscape, and draw it, will open gl NOT draw the polys behind me if I draw the entire object as a glDrawelements call?

Should I myself build the indexes for glDrawElements on the fly dependent on which poly’s are visible, or will OpenGL take care of that for me?

It seems that my engine is the same speed even when 99% of the object are behind me out of sight.

If I do indeed need to do my own polygon removal ahead of time, THEN build the index tables ahead of time for glDrawElements, I’ll need to multiply the points in my 3d world by the viewing matrix. How do I get that?

split your landscape up into areas (a quadtree helps), + then test to see each area can be seen, even if only one triangle of the area is able to be seen draw the whole area triangles.
i believe this is called gross culling

Yes, you need to implement your own gross culling. OpenGL will not cull triangles outside the frustum, it will only clip them to the frustum, that means it has to do the transforms for a triangle even if it lies completely outside the frustum. And from what I’ve been reading, gross culling is sufficient on hardware T&L cards. On non-T&L cards, you may benefit from an even finer level of culling.

[This message has been edited by DFrey (edited 07-23-2001).]

im not even to sure about that ive been experimenting on my vanta (non harware t+l)using landscape blocks of 16x16 (seems to be the quickest ie quicker than 32x32 + 8x8) + have been able to do 1.5mil textured tris (no light but coloured) a second @640x480. removing a tri from a block would stuff the whole thing up ie the strips. of course this concerns landscapes which tend to lend themselves well to fast drawing unlike say trees.

Good information. Thank you all.

Ok, in order for me to cull things myself, I need the matrix so I can muliply the points of my objects and check those values against the hither and zon clipping plane etc, etc.

How does one get that matrix. I assume I do the regular camera translations, and rotations, then I need that matrix. How do I get to it?

You may want to try quadtrees or octrees, where you can simply check wether boxes are at least partially inside the pyramid of the fov. Just build up a fine octree for testing purposes, and test to a certain changeable level to see at which point it becomes slower to cull small parts of geometry.

Ok, so no one knows how to get the current matrix into a form that can be multiplied by 3d points?

I’ll need to do that if I am to check them againt the fulcrum.

Here is a link to a tutorial on how to get the viewing frustum from opengl and how to clip volumes against it:

Hope it helps

Thank you Brent. That is EXACTLY what I was looking for. =)

theres also code in the faq + also john ratcliff + someone else released a paper about it recently

Its not that hard to work out the frustrum, you just need the viewing angle… Then its all simple algebra to work out if a certain vertex is within the frustrum or not…

Originally posted by zed:
theres also code in the faq + also john ratcliff + someone else released a paper about it recently

edit sorry the writers of the mentioned paper were gil gribb + klaus hartmann not j ratcliff. nice paper btw