[osg-users] Pb with Render To Texture

2007-09-07 Thread Benoit bossavit
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(&nv);
   cv->pushStateSet(shader1_stateset);
   osg::Group::traverse(nv);
   cv->popStateSet();

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

   osgUtil::CullVisitor *cv = dynamic_cast(&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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Pb with Render To Texture

2007-09-07 Thread Robert Osfield
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 <[EMAIL PROTECTED]> 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(&nv);
>cv->pushStateSet(shader1_stateset);
>osg::Group::traverse(nv);
>cv->popStateSet();
>
>osgUtil::CullVisitor *cv =
> dynamic_cast(&nv);
> cv->pushStateSet(shader2_stateset);
> osg::Group::traverse(nv);
> cv->popStateSet();
>
>osgUtil::CullVisitor *cv =
> dynamic_cast(&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@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org