I'm having a couple of issues with FBO RTT cameras and shaders. 

Firstly if I pass a texture that is bound to an FBO camera into a shader, I can 
only use the texture within the shader if it's bound to texture unit 0 when I 
set up the stateset, if it's not I get black pixels.

The second problem is that I can't seem to get two FBO cameras to work 
together. I create two FBO RTT camera's using the code below. I attach both 
camera's to the root, however the last RTT camera to render always overwrites 
the previous texture despite having to completely seperate textures bound to 
them. Individually they work fine.

Have I misunderstood FBOs? am I only permitted to have one? Or have I set up 
the camera's incorrectly?

Any help would be greatly appreciated.

Regards,

Kim.

//------ CAMERA 1

 osg::ref_ptr<osg::Camera> camera = new osg::Camera;
 camera->setClearColor( p_clearColor );
 camera->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

 camera->setReferenceFrame( osg::Transform::RELATIVE_RF );
 camera->setProjectionMatrix( osg::Matrixd::identity() );
 camera->setViewMatrix( camMatrix * reflection);

 camera->setViewport(x, y, width, height );
 camera->setRenderOrder(osg::Camera::PRE_RENDER, 1);

 camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
 camera->attach( osg::Camera::COLOR_BUFFER, p_texture1 );

// ------ CAMERA 2

 osg::ref_ptr<osg::Camera> camera = new osg::Camera;
 camera->setClearColor( p_clearColor );
 camera->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

 camera->setReferenceFrame( osg::Transform::RELATIVE_RF );
 camera->setProjectionMatrix( osg::Matrixd::identity() );
 camera->setViewMatrix( osg::Matrixd::identity() );

 camera->setViewport(x, y, width, height );
 camera->setRenderOrder(osg::Camera::PRE_RENDER, 2);

 camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
 camera->attach( osg::Camera::COLOR_BUFFER, p_texture2 );

 

*****************************************************************************************
To view the terms under which this email is distributed, please go to 
http://www.hull.ac.uk/legal/email_disclaimer.html
*****************************************************************************************
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to