PDA

View Full Version : Object/poly removal



OpenGLRox
07-23-2001, 12:32 PM
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?

zed
07-23-2001, 01:13 PM
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

DFrey
07-23-2001, 02:07 PM
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).]

zed
07-23-2001, 04:51 PM
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.

OpenGLRox
07-24-2001, 11:59 AM
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?

Michael Steinberg
07-24-2001, 06:29 PM
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.

OpenGLRox
07-26-2001, 06:31 PM
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.

Brent Fogarty
07-26-2001, 09:43 PM
Here is a link to a tutorial on how to get the viewing frustum from opengl and how to clip volumes against it:
http://www.markmorley.com/opengl/frustumculling.html

Hope it helps

OpenGLRox
07-27-2001, 11:46 AM
Thank you Brent. That is EXACTLY what I was looking for. =)

zed
07-27-2001, 06:59 PM
theres also code in the faq + also john ratcliff + someone else released a paper about it recently

MrShoe
07-27-2001, 07:16 PM
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...

zed
07-27-2001, 11:21 PM
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