[osg-users] Frame Buffer Objects and Shaders
Kim C Bale
K.Bale at hull.ac.uk
Mon Mar 10 04:03:00 PDT 2008
Scratch that post, I've fixed it. I was misusing ref_ptrs. Strange effect though.
Kim.
________________________________
From: osg-users-bounces at lists.openscenegraph.org on behalf of Kim C Bale
Sent: Fri 07/03/2008 21:55
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] Frame Buffer Objects and Shaders
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 --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 5142 bytes
Desc: not available
Url : http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080310/e89fd12c/attachment.bin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: not available
Url: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080310/e89fd12c/attachment.pot
More information about the osg-users
mailing list