Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: occlusion culling causes flickering

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    occlusion culling causes flickering

    this is my (unorganized, unoptimitzed and ugly i know) occlusion culling code. it works fine - except for some frames in which meshes that cover a large portion of the screen seem to flicker.

    <vector> m_vpkVisibleGroups contains meshes that passed view frustum culling.
    <vector> m_vpkVisibleNotOccludedGroups contains the meshes from the first array that passed occlusion culling.

    Code :
    	// generate query id's
    	unsigned int uiCount = m_vpkVisibleGroups.size();
    	unsigned int *uiQueryIds = new unsigned int[uiCount];
     
    	glGenQueries( uiCount, &amp;uiQueryIds[0] );
     
    	for( unsigned int i = 0; i < m_vpkVisibleGroups.size(); i++ )
    	{
    		// get group
    		Group *pkGroup = m_vpkVisibleGroups[i];
     
    		// begin query
    		glBeginQuery( GL_SAMPLES_PASSED, uiQueryIds[i] );
     
    		// render bounding box
    		pkGroup->GetBoundingBox()->Render( false );
     
    		// end query
    		glEndQuery( GL_SAMPLES_PASSED );
    	}
     
    	unsigned int uiResult = 0;
     
    	do
    	{
    		glGetQueryObjectuiv( uiQueryIds[uiCount-1], GL_QUERY_RESULT_AVAILABLE, &amp;uiResult );
    	}
    	while( !uiResult );
     
    	m_vpkVisibleNotOccludedGroups.clear();
    	for( unsigned int i = 0; i < uiCount; i++ )
    	{
    		// get result
    		unsigned int uiResult;
    		glGetQueryObjectuiv( uiQueryIds[i], GL_QUERY_RESULT, &amp;uiResult );
     
    		if( uiResult )
    		{
    			m_vpkVisibleNotOccludedGroups.push_back( m_vpkVisibleGroups[i] );
    		}
    	}
     
    	// delete query id's
    	glDeleteQueries( uiCount, &amp;uiQueryIds[0] );
    any idea what's wrong? glFlush() didn't help.

  2. #2
    Intern Contributor
    Join Date
    Jul 2004
    Location
    Weimar /Germany
    Posts
    59

    Re: occlusion culling causes flickering

    Hi,

    the problem is quite easy to explain - you render all the BBs into the depth buffer - so it might appear that one of the BBs (call it A) is completely occluded by another one (B) - BUT - the actual object (B) which lies inside its BB might not occlude the actual object (A)!
    Your code will not work in a 100% conservative way of you do it like this, but there are other ways to do it correctly with occlusion queries.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •