Disable Frustrum Culling Entirly

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Disable Frustrum Culling Entirly

Post by paul424 »

Hello, I wrote the culling code for my application. Now I don't need ogre3d culling anymore. How do I disable frustrum culling entirely ? The createSceneManager() MUST take some arguments which enables some form of culling. Either by type :
  • ST_GENERIC - Generic scene manager (Octree if you load Plugin_OctreeSceneManager, DotScene if you load Plugin_DotSceneManager)
    ST_EXTERIOR_CLOSE - old Terrain Scene Manager
    ST_EXTERIOR_FAR - Nature scene manager (this mode is not present anymore in Ogre 1.0. Use "Terrain", or "Paging Landscape" instead)
    ST_EXTERIOR_REAL_FAR - Paging Scene Manager
    ST_INTERIOR - BSP scene manager
or by name :
  • DefaultSceneManager
    OctreeSceneManager
    BspSceneManager
    PCZSceneManager

How do I get away with that ?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1280
Contact:

Re: Disable Frustrum Culling Entirly

Post by dark_sylinc »

Use the DefaultSceneManager to avoid overhead.

However Ogre is still going to do some Camera vs Aabb culling. How it is coded in v1.x makes it almost impossible to disable. In v2.x the code was refactored, and though we don't support skipping frustum culling out of the box, it would be relatively easy to modify the source code to avoid culling (which shouldn't matter much anyway because it's now below 0.5ms for 64k objects on modern CPUs in Ogre 2.x).

But for Ogre 1.x there is no way I'm afraid.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: Disable Frustrum Culling Entirly

Post by mkultra333 »

I've been using Ogre since 1.6, currently on 1.10, and I was always fighting the culling system since I have my own custom lighting and shadowing system, and a custom zone-based culling system.

What I generally do is set a really huge bounding box for everything so that Ogre always thinks everything is in the frustum. For instance, on manually created meshes, I always do the following.

Code: Select all

m_pDynamicSpotMesh->_setBounds(AxisAlignedBox(-1000000,-1000000,-1000000,1000000,1000000,1000000));
m_pDynamicSpotMesh->_setBoundingSphereRadius(1000000);
For Ogre::Rectangle2D I always use

Code: Select all

miniScreen_VR_L->setBoundingBox(AxisAlignedBox(-100000.0*Vector3::UNIT_SCALE, 100000.0*Vector3::UNIT_SCALE)); 
I had a problem with manually created banks of general purpose triangles (used dynamically every frame for doing blood splats and such) culling, so when I initially create the triangle bank, I set the first 8 triangles to be at the far corners of a massive cube like this, where SPLAT_BANKDISTANCE is 32767 and all my action happens well within the bounds of the cube that creates.

Code: Select all

		for(nLoop=0 ; nLoop<MAXDYNAMICSPOT ; nLoop++)
		{
			// Ogre is incorrectly culling stuff after I modify the mesh, regardless of how I set the bounding boxes.
			// to get around this 8 of the triangles are set to the extreme corners of a massive bounding box.
			// the rest of the triangles are just put in a line off in the distance.
			switch(nLoop)
			{
				case 0: flXPosA= SPLAT_BANKDISTANCE ; flYPosA= SPLAT_BANKDISTANCE ; flZPosA= SPLAT_BANKDISTANCE ; break ;
				case 1: flXPosA=-SPLAT_BANKDISTANCE ; flYPosA= SPLAT_BANKDISTANCE ; flZPosA= SPLAT_BANKDISTANCE ; break ;
				case 2: flXPosA= SPLAT_BANKDISTANCE ; flYPosA=-SPLAT_BANKDISTANCE ; flZPosA= SPLAT_BANKDISTANCE ; break ;
				case 3: flXPosA=-SPLAT_BANKDISTANCE ; flYPosA=-SPLAT_BANKDISTANCE ; flZPosA= SPLAT_BANKDISTANCE ; break ;
				case 4: flXPosA= SPLAT_BANKDISTANCE ; flYPosA= SPLAT_BANKDISTANCE ; flZPosA=-SPLAT_BANKDISTANCE ; break ;
				case 5: flXPosA=-SPLAT_BANKDISTANCE ; flYPosA= SPLAT_BANKDISTANCE ; flZPosA=-SPLAT_BANKDISTANCE ; break ;
				case 6: flXPosA= SPLAT_BANKDISTANCE ; flYPosA=-SPLAT_BANKDISTANCE ; flZPosA=-SPLAT_BANKDISTANCE ; break ;
				case 7: flXPosA=-SPLAT_BANKDISTANCE ; flYPosA=-SPLAT_BANKDISTANCE ; flZPosA=-SPLAT_BANKDISTANCE ; break ;
				default: 
					//flXPosA=nXPos ; flYPosA=-SPLAT_BANKDISTANCE ; flZPosA=0 ;
					flXPosA=nXPos ; flYPosA=0 ; flZPosA=0 ;
			}
Note that this only had to be done on the initial creation, after that I was free to move any of the triangles anywhere and they still wouldn't be culled.

For entities, I do the following

Code: Select all

aabb.setExtents(-SPLAT_BANKDISTANCE, -SPLAT_BANKDISTANCE, -SPLAT_BANKDISTANCE, SPLAT_BANKDISTANCE, SPLAT_BANKDISTANCE, SPLAT_BANKDISTANCE) ;
m_pEntityInfo[nEntity].pEnt->getMesh()->_setBounds(aabb,false);
I have found the above tricks work for circumventing Ogre culling. But I did find it frustrating that there was no easy way just to turn it off.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
Post Reply