[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:

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.


Read this topic online here:

More information about the osg-users mailing list