There are two ways to update the view matrix dependent data - dynmiacally generate on each frame from within the cull traversal, or to set the data once the update traversal has completed. Doing things dynamically in the cull traversal is the most universal solution as it can cope with multiple camera and graphics contexts.
Robert.
On 8/24/06, Dave Tuft <[EMAIL PROTECTED]> wrote:
This mailing list seems to offer great help, so I thought I'd post my
problem hoping one of the veterans, such as Robert would sound off.
I've modified the osgDepthShadow example to perform the LSPSM warping scheme.
To recap what this example does:
1. creates a new camera that renders to an fbo.
2. updates the scene through a group callback
3. updates the shadow camera through a new callback.
The original project works with a fragment shader, and then fixed
function vertex shader.
For my technique I need a vertex shader and I need some uniforms set
each frame These uniforms are based off of the eye camera. So I went
about setting my uniforms in the camera update callback. This led to a
1 frame disparity. This shows up when the camera is moved, and it
looks like the depth map is just not aligned correctly over the scene.
I can post an image if anyone is interested.
So I dived into OSG and found my call back was being called before the
cameras were updated.
In line 602 of Viewer.cpp we have this code (in the update function):
if (_updateVisitor.valid())
{
_updateVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
// update the scene by traversing it with the the update
visitor which will
// call all node update callbacks and animations.
getTopMostSceneData()->accept(*_updateVisitor);
}
// update the main producer camera
if (_keyswitchManipulator.valid() &&
_keyswitchManipulator->getCurrentMatrixManipulator())
{
osgGA::MatrixManipulator* mm =
_keyswitchManipulator->getCurrentMatrixManipulator();
osg::Matrixd matrix = mm->getInverseMatrix();
CameraGroup::setViewByMatrix(Producer::Matrix(matrix.ptr()));
setFusionDistance(mm->getFusionDistanceMode(),mm->getFusionDistanceValue());
}
I stepped into the first if update block and found out that this is
where the callbacks are called.
The camera is moved in the second if block.
What I need is the ability to have a call back called after the
cameras are moved.
I fixed the problem in my own app with this code:
while (!viewer.done())
{
// wait for all cull and draw threads to complete.
viewer.sync();
// update the scene by traversing it with the the update visitor
which will
// call all node update callbacks and animations.
viewer.update();
viewer.sync();
ucatgcb->call();
// fire off the cull and draw traversals of the scene.
viewer.frame ();
}
I manually call my call back after the update.
I am certain there is a more modular way of doing this, rather than
forcing the call where I need it. Is there something in place in OSG
to get a call-back called after the camera has been moved?
Could OSG be modified to allow for this?
I appreciate your help.
Thanks,
David Tuft
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
