Advertisement Jump to content
Sign in to follow this  
thecheeselover

OpenGL How to: Culling

This topic is 1833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!