Hi Hartwig,

By default the OSG automatically adjust the near and far planes on
each new frame, so I'm surprised you are trying to do this yourself.
The controls for this can be found in include/osg/CullSettings:

        enum ComputeNearFarMode
            DO_NOT_COMPUTE_NEAR_FAR = 0,

        void setComputeNearFarMode(ComputeNearFarMode cnfm) {
_computeNearFar=cnfm; applyMaskAction(COMPUTE_NEAR_FAR_MODE); }
        ComputeNearFarMode getComputeNearFarMode() const { return

osg::Camera subclasses from osg::CullSettings so you use this

Another area I think is useful to clarify is that there is difference
between culling and clipping:

    Culling is done by the scene graph during the cull traversal and
is done be testing the view frustum against the bounding sphere's of
nodes in the scene.

    Clipping is done by the GPU during rasterization of primitives,
this is where the near/far values affect the result, so clipping
happens at a per fragment basis.

If whole objects disappear at once when they shouldn't be then this is
likely an issue with Culling, most likely due to a bounding volume for
a subgraph being incorrect for some reason.  Using vertex shaders to
move objects might be the cause this issue.  Using
Drawable::setInitBound() or better a
Drawable::ComputeBoundingBoxCallback to provide the dimensions that
the drawable will have once the vertex shader is taken into account.

If objects get clipping out fragment by fragment then it's an issue of
near or far plane clipping.  Again it can be caused by bounding volume
issues as the the OSG compute near/far code needs valid bounding
volume sizes to do it's compute work.  However, the near plane can
only be pulled in so far before the near/far ratio grows too high to
cause depth precision problems. so has to be clamped. The
osg::CullSettings::setNearFar() ratio can be adjusted to make this
clamping more or less conservative.   The default ratio is 0.0005.

If you have a scene with a massive near/far range (think space sims)
then it be necessary to use a non linear depth buffer or depth


osg-users mailing list

Reply via email to