Discussion:
Last frames modelview matrix
Pierre Landes
2014-06-20 17:03:47 UTC
Permalink
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
Pierre Landes
2014-06-24 09:34:28 UTC
Permalink
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

Loading...