[osg-users] Pb with Render To Texture

Benoit bossavit bnuaster at gmail.com
Fri Sep 7 06:04:58 PDT 2007


Hi all,

I have a class overloading an osg::Group. I overload the "traverse" method
to apply 3 shaders passes to draw the scene

create shader1_stateset
create shader2_stateset
create shader3_stateset

void traverse(osg::NodeVisitor& nv)
{
    if(nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR))
    {
       osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
       cv->pushStateSet(shader1_stateset);
       osg::Group::traverse(nv);
       cv->popStateSet();

       osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
       cv->pushStateSet(shader2_stateset);
       osg::Group::traverse(nv);
       cv->popStateSet();

       osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
       cv->pushStateSet(shader3_stateset);
       osg::Group::traverse(nv);
       cv->popStateSet();
     }
}

This algorithm works, but now I want to do Render To Texture in floatting
point. I tried retrieve the camera and set the targetImplementation with a
FBO and attach a floatting texture, but the texture keep empty at the end.
How can I do?
Someone have an idea?

void traverse(osg::NodeVisitor& nv)
{
    if(nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR))
    {
        if(nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR))
        {
            if
(cv->getRenderStage()->getCamera()->getRenderTargetImplementation() !=
osg::Camera::FRAME_BUFFER_OBJECT)
            {

cv->getRenderStage()->getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

cv->getRenderStage()->getCamera()->attach(osg::Camera::COLOR_BUFFER,m_hdrTexture);
            }
            ...
            ....
        }
    }
}


Thanks

bnua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070907/0d05dab7/attachment-0005.htm>


More information about the osg-users mailing list