[osg-users] how to disable the frustum culling?

700 views
Skip to first unread message

Julio Jerez

unread,
Oct 18, 2013, 11:40:53 AM10/18/13
to osg-...@lists.openscenegraph.org

I am get a lot of frustration trying to disable frustum culling with OSG camera.

I am setting the perspective matrix to  a near plane of 0.1 and a far plane of 1000.0

here is my code.

I explicitly disable frustum culling, however no matter how many time I do it,  each time

viewer.frame() is called, the camera rest the near plane to 0.112 and the far plane to 228.56

 

can someone tells me how to prevent OSG from doing that?

here is my setup code that initialize the camera after the viewer is instantiated. 

 

               SetCameraProjectionMatrix (viewer, 90.0f, dFloat (width) / height, 0.1, 1000.0f);

 

               int cullingMode = cam->getCullingMode();

               cullingMode &= ~osg::CullSettings::VIEW_FRUSTUM_CULLING;

               cam->setCullingMode(cullingMode);

}

 

void SetCameraProjectionMatrix (osgViewer::Viewer& viewer, dFloat viewAngleInDegress, dFloat aspectRatio, dFloat nearPlane, dFloat farPlane)

{

               osg::Camera* const camera = viewer.getCamera();

               camera->setProjectionMatrixAsPerspective (viewAngleInDegress, aspectRatio, nearPlane, farPlane);

 

//            camera->setViewMatrixAsLookAt (osg::Vec3 (3.0f, -5.0f, 2.0f), osg::Vec3 (0.0f, 0.0f, 0.0f), osg::Vec3 (0.0f, 0.0f, 1.0f));

               camera->setViewMatrixAsLookAt (osg::Vec3 (-3.0f, -5.0f, 2.0f), osg::Vec3 (0.0f, 0.0f, 2.0f), osg::Vec3 (0.0f, 0.0f, 1.0f));

}

 

 

Sebastian Messerschmidt

unread,
Oct 18, 2013, 12:00:24 PM10/18/13
to OpenSceneGraph Users
Hi julio,

I guess you are not looking for culling, but for near-far plane calculation.
try:

camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);


why do you want to disable culling, or did you just mixed it up with the near-far mode?

cheers
Sebastian

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Paul Martz

unread,
Oct 18, 2013, 1:03:31 PM10/18/13
to OpenSceneGraph Users
It's often desirable to disable culling for any geometry that is non-spatial in nature. Such geometry is very common in modern graphics programming.

Even after you disable near/far auto-compute, and set culling disabled on your scene graph, the CullVisitor will still cull any geometry that is behind the eye point. This makes rendering non-spatial geometry just a little tricky. You must add such geometry to its own Camera node, and configure the Camera so that the CullVisitor will not discard its child geometry.
   -Paul


Julio Jerez

unread,
Oct 19, 2013, 7:03:42 AM10/19/13
to osg-...@lists.openscenegraph.org

Oh I do no wnat to change the culling, all I want to know is why OSG change the projection matrix to and arbitrary near plain of 0.2 and far plane of 228

 

I set the camera to be projection to

 

SetCameraProjectionMatrix (0.5 * 3.1416f, 1.33f, 0.01, 1000.0f);

 

but when I ge the Plojection matrix on a visitor callback the projection matrix correspond to one of

 

SetCameraProjectionMatrix (0.5 * 3.1416f, 1.33f, 0.2, 225.0f);

 

and that seen to be changed by the cullling system of osg,

all I want is to have camera that I am specifying.

Thanks

 

 

Robert Osfield

unread,
Oct 19, 2013, 8:16:28 AM10/19/13
to OpenSceneGraph Users
Hi Julio,

The OSG by default clamps the near/far planes to the extents of your model.  You can disable this via:

  viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);

This has nothing to do with culling though, you seem to confuse near/far planes and culling in your post.  The methods you mention have nothing to do with the OSG itself too, I can only presume you are writing psuedo code or have other funcitons that only your code has, but are not in the OSG... which kinda makes it hard to other to really understand what you are doing.

It may be best to simply buy one of the OSG books and work through it, it'll help your tremendously with understanding how things all work.

Robert.



Reply all
Reply to author
Forward
0 new messages