Hi Mathieu,
Sorry I don't have the time to compile and test your code, but I saw the
screenshot and it looks like your depth texture gets rendered and applied to
the object. What you may need to do is to make sure you set up RTT camera
transform exactly as main camera transforms, and texture coordinates are
properly generated to span the whole window.
In other words I guess that you want to have texcoords match pixel locations
in the final output screen. Ie you want texcorrds on the objects to
span -1..1x-1..1 range on the output window. Right ?
If yes, then you could use simple shader, or add a texgen node to produce
proper texcoords for the output scene. This texgen should use EYE_LINEAR
coords and its transform should be set to projection matrix of RTT camera
and main camera.
I am also not sure if seeting your effect camera to RELATIVE_RF gurantees
using the same projection for RTT camera as for main camera. One could be
sure if he forces this explicitly
eg:
camera->setProjectionMatrix(
viewer->getCamera()->getProjectionMatrix() );
To add texgen node try adding following lines to your code:
camera->setProjectionMatrix(
viewer->getCamera()->getProjectionMatrix() );
osg::TexGenNode * texGenNode = new osg::TexGenNode;
_scene->addChild( texGenNode );
texGenNode->setTextureUnit( 0 );
texGenNode->getTexGen()->setMode( osg::TexGen::EYE_LINEAR );
texGenNode->getTexGen()->setPlanesFromMatrix
(
camera->getProjectionMatrix() *
osg::Matrix::translate(1,1,1) * // remap -1..1x-1..1 range
osg::Matrix::scale(0.5,0.5,0.5) // to 0..1 x 0..1 range
);
One final note, it looks like you use cow.osg model. AFAIK this model
already contains texgen using SPHERE mapping mode. To avoid conflicts for
tests I suggest you use other model.
Hope it helps, and no guarrantees, I have no time to verify if everything
what I wrote is 100% correct.
Cheers,
Wojtek
----- Original Message -----
From: Mathieu Schoutteten
To: [email protected]
Sent: Thursday, June 12, 2008 4:35 PM
Subject: Re: [osg-users] [Depth Buffer rendering]
i post my source code for more clarity.. Maybe someone already try to have
the same effect.
DepthBuffer.cpp include a main method for test.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org