Re: [osg-users] Last frames modelview matrix
Actually, the modelview matrices I get (from CullVisitor::getModelViewMatrix() inside the operator()(Node*, NodeVisitor*) of a cull callback) do seem correct. It is just that I may not fully grasp what they actually contain at that point in the code. I thus have a couple of additional questions: 1) I have the impression they do not incorporate the viewing transform, and hence are just local-to-world matrices at that point. Could you please confirm this? 2) What would be a desirable way to retrieve the current viewing transform? Would calling Code: cullVisitor->getRenderInfo().getView()->getCamera()->getViewMatrix() be a nice way of doing it? 2) My goal is to send the previous frame's modelview and projection matrices to my vertex shader via uniforms. Would it make any difference to add such uniforms to the stateset of a Geode (via a NodeVisitor) or to add them the stateset of a Drawable (via a Drawable::CullCallback), given the fact the Drawable has been added to the said Geode? Would it affect the way uniforms are uploaded? Thanks in advance. :) Cheers. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59866#59866 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Last frames modelview matrix
Hi, Sorry to resurrect this old topic but I am stuck on the same problem (storing the model-view-projection matrix of the last frame in a uniform for each drawable of my scene). I derived the NodeCallback class and cast the nodevisitor passed to its operator() to a CullVisitor. The said nodecall is then added to a Geode via the addCullCallback() method. However, the matrices I get seem off. For instance, when displaying my uniforms via gDebugger, it appears the coefficients of the CullVisitor::getModelViewMatrix() are quite different from the coefficients of the built-in uniform osg_ModelViewMatrix. For debugging purposes, all transforms (including the camera's) are kept unchanged across frames. What could possibly go wrong? I am using OSG-3.2.1-rc3 on Windows x64 (compiled with Visual Studio 2010). Any insight would be much appreciated. Cheers. :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59837#59837 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Last frames modelview matrix
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
Re: [osg-users] Last frames modelview matrix
Hi Sergey, Hi, Sebastian you can get (already computed by cullvisitor) modelview matrix in cull callback. But i think you are overcomplicating things with this approach. Okay, I hadn't thought of this. So you propose adding a cull-callback to all the nodes that should contribute? And surely I felt that the approach was too complicated, thats why I was asking ;-) cheers Sebastian Cheers, Sergey. 24.08.2012, 14:07, "Sebastian Messerschmidt" : 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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Last frames modelview matrix
Hi, Sebastian you can get (already computed by cullvisitor) modelview matrix in cull callback. But i think you are overcomplicating things with this approach. Cheers, Sergey. 24.08.2012, 14:07, "Sebastian Messerschmidt" : > 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