[osg-users] Frame Buffer Objects and Shaders
Kim C Bale
K.Bale at hull.ac.uk
Fri Mar 7 13:55:08 PST 2008
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 );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080307/6c352351/attachment.htm
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: not available
Url: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080307/6c352351/attachment.asc
More information about the osg-users
mailing list