views:

56

answers:

4

I'm new to OpenGL. I'm using it with JOGL.

I'm reading about frustrum culling:

http://www.lighthouse3d.com/opengl/viewfrustum/

http://www.crownandcutlass.com/features/technicaldetails/frustum.html

I'm not sure exactly what it's supposed to do. Doesn't OpenGL cull off-screen objects automatically? (Is this culling significantly slower than just not sending the objects in the first place?)

From what I'm reading, it doesn't look like this will handle avoiding drawing objects that are obscured behind another but are within the viewing frustrum. Does that mean that the only benefit is avoid sending off-screen objects to OpenGL?

+1  A: 

When you do you frustrum checks in code, you do it using simple geometry that encases the object being draw. This can be done much faster than the card trying to cull each triangle.

Torlack
+3  A: 

Yes, you are basically right. Frustum culling cuts off objects that are outside the camera pyramid. OpenGL, when rendering a scene, of course does this as well but on a per vertex basis. Frustum culling works per object and its performance boost potential is therefore much higher.
One of the bottlenecks is transferring the data between CPU and GPU. If you need to transfer for example only 1/4 of all the objects/vertices in an outdoor scene, frustum culling can yield a nice performance boost.

dark_charlie
+3  A: 

The fastest object is the one you don't have to draw at all.

In general, for objects that are not dead simple already, you will provide a simplified, conservative bounding volume. That way, you can do frustum culling without dealing with every triangle in a complex object..

Avoiding drawing objects that are obscured behind each other is called occlusion culling. Occlusion culling is generally more complex than frustum culling; however, note that it can still use the same simplified bounding volume.

comingstorm
+2  A: 

Yes -- frustum culling just removes objects that lie entirely outside the viewing frustum. Nothing more or less. Yes, you can potentially improve performance over OpenGL itself, especially if you can cull a larger number of items at once (e.g., a viewgraph library may be able to chop off entire branches of the graph fairly quickly).

There is also face culling that removes triangles (or whatever) that are facing away from the viewer, but that's separate from frustum culling.

There are a couple of ways of handling objects that are obscured by other objects. Occlusion culling is the simplest, but OpenGL does nothing to support it directly (though some hardware does as an extension). The other is the depth buffer -- which OpenGL does support directly. The difference is that occlusion culling looks at an entire object, and doesn't render it at all if it's completely obscured. The depth buffer works on a fragment-by-fragment basis, so it only takes place after you've (almost) fully rendered an object. Depending on how many objects you're dealing with (and such) doing your own occlusion culling can, therefore, be a pretty big win (since it can avoid doing a lot of rendering that's needed before the depth buffer can do its thing).

Jerry Coffin