[osg-users] Off screen image capture distorted

Derek Quam osg at email.derekquam.com
Mon Aug 1 11:00:42 PDT 2016


Hi Sebastian,

I looked more into this and I think it has to do with the projection matrix of the slave camera. updateTraversal() calls updateSlaves() which sets the slave camera's projection matrix to the master cameras projection matrix multiplied by the slave's _projectionOffset.

So I added the following code to the if (pbuffer.valid()) block:


Code:
double fovy, aspect, near, far;
viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, near, far);
osg::Matrixd masterPerspective = viewer.getCamera()->getProjectionMatrix();
osg::Matrixd slavePerspective = osg::Matrixd::perspective(fovy, double(width) / double(height), near, far);
slavePerspective = slavePerspective * osg::Matrixd::inverse(masterPerspective);

...

viewer.addSlave(camera.get(), slavePerspective, osg::Matrixd());



This seemed to work for me, but I don't know how 'good' or resilient of a solution it is.

Thanks,
Derek

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68241#68241








More information about the osg-users mailing list