How to: Culling

Started by
2 comments, last by 3TATUK2 10 years, 3 months ago

Hello,

I don't understand how to apply culling in my opengl application. I understand what is the concept, but not the how to. First off, what is the difference betwenn GL_FRONT and GL_CW? To make culling properly, do I need to order my vertices' position clockwise or to order the indices? What is the reference of clockwise (i.e. is it when I face the -z axis or something else?

Thanks a lot,

Thecheeselover

Hide yo cheese! Hide yo wife!

Advertisement

Are you using the fixed-function pipeline? If you're following a tutorial and don't mean to be using outdated concepts, make sure the tutorial is using OpenGL 3 or 4. You can find that when they set major version to either 3 or 4. In SDL, it's SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3 or 4). For WGL, I think it's WGL_CONTEXT_MAJOR_VERSION_ARB. You probably get the idea.

For what clockwise means (from http://www.opengl.org/sdk/docs/man/xhtml/glFrontFace.xml):

"The projection of a polygon to window coordinates is said to have clockwise winding if an imaginary object following the path from its first vertex, its second vertex, and so on, to its last vertex, and finally back to its first vertex, moves in a clockwise direction about the interior of the polygon."

Back face culling is on by default I believe. There is also object culling as well.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

As dpadam450 said, the type of culling you're referring to is handled automatically by GL...

There are other types of culling, like object culling, as he also mentioned.

Implementing these methods are pretty advanced topics...

Object culling is somewhat easier, for example you can simply wrap an object render call with a GL object occlusion query, then use the previous frame's results to either draw the full version of the object (was visible) or a simplified bounding box version (was not visible).

Then there's a system like I've implemented which is basically octree-based occlusion query geometry culling. First you build an octree from your geometry, then use it's nodes with occlusion queries to determine their visibility, similar to the object-based method described above... But instead of a whole object as a single entity, you're basically breaking a very large object (map geometry) into smaller pieces to be handled individually.

Beyond that - there's a system like PVS (Potentially Visible Set) which quake-like engines implement, as well as unity and other mainstream game engines through Umbra. It's similar to the octree-based method above, but different. First off, instead of an octree, it typically uses just a constant (non-recursive) spatial grid. The major difference is that it doesn't use realtime occlusion queries, but instead is precalculated. Basically, for every grid - it determines which other grids are potentially visible, so then when the camera is in a specific grid, it already knows which other ones to render.

This topic is closed to new replies.

Advertisement