[osg-users] Pb with Render To Texture

Robert Osfield robert.osfield at gmail.com
Fri Sep 7 06:14:52 PDT 2007


Hi Benoit,

I would recommend just creating a small example that just has a single
RTT camera set up with a float point texture and then see how you get
on.  Once you are happy with this move up to more complicated
combinations.

Robert.

On 9/7/07, Benoit bossavit <bnuaster at gmail.com> wrote:
> 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
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>



More information about the osg-users mailing list