The main problem you'll have with the update callback approach is that it won't
work in a multi-view mode (where one view is split across multiple
displays/windows). In a multi-view mode, the view half of the modelview matrix
is potentially different for each window.
If this is an issue, then the CullVisitor approach (as Sergey suggests) is the
right thing to do. You'll need to store the modelview matrix in an array indexed
by the context ID. This gets a little complicated, but it's possible.
If you have a simpler single-window rendering scenario, then using the update
callback seems like it would be much simpler. The main problem is accessing the
root Camera node; each update callback needs access to the Camera in order to
get the view matrix.
Assuming you can solve that small problem, then each update callback would have
logic like this:
Take last frame's modelview from member variable,
and set as the value of a Uniform for use by your shader.
Get current view matrix from Camera
Get current model matrix ("local to world") from NodeVisitor
Multiply them together to get current frame's modelview matrix
Store in member variable for use during next frame
Hope that helps.
-Paul
On 8/24/2012 4:07 AM, Sebastian Messerschmidt wrote:
Hello,
I'm trying to implement per object motion blur in my deferred pipeline.
In order to get this right, I need the modelview matrix from the previous frame
per node.
To get it I was thinking about using an updateCallback per node that should
contribute to the motion blur. Unfortunately I think this will get too
expensive, as I have to compute the local to world per call.
Also is the updateCallback called if the camera moves? If not I have to install
an callback that is called per frame ..
Any suggestions how to get the last frames modelview matrix?
cheers
Sebastian
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org