Thanks guys. I figured this one out. Here was the issue:

Turns out I fibbed about not sharing data: I assigned a common stateset to
both cameras prior to configuring each one for RTT.

    osg::StateSet* common = new osg::StateSet();
    ...
    cam1->setStateSet(common);
    cam2->setStateSet(common);
    ...
    // do the RTT setup here

Nothing interesting in the common StateSet itself, but I'm guessing that
osg::Camera under the hood uses that StateSet for some of the FBO
attachment information, which then ended up being shared.

I can move that common StateSet up to a parent group and all it well.
Thanks again for the comments.

Glenn Waldron / @glennwaldron


On Thu, Feb 21, 2013 at 7:20 AM, Robert Osfield <[email protected]>wrote:

> Hi Glenn,
>
> I haven't seen problems with multiple RTT Camera's unintentionally
> sharing their attachments, use of multiple RTT Camera's is pretty
> common  so I would have thought that others would have seen the same
> problem.   The best I can suggest to step through the traversal of
> CullVisitor::apply(Camera&) to see what the flow of control  is doing
> and what data is it applying.
>
> Robert.
>
>
> On 21 February 2013 01:22, Glenn Waldron <[email protected]> wrote:
> > Hi folks. I'm stumped by an RTT problem and looking for help!
> >
> > I have two RTT cameras that share the same subgraph. My goal is to render
> > the subgraph with two different projection matrices (not unlike in the
> PSSM
> > example). But I'm having a weird problem.
> >
> > Each RTT camera is created separately, and each bound to its own
> Texture2D.
> > Otherwise they are identical, and they share no data. Then in the CULL
> > traversal I do this:
> >
> >    cam1->setViewMatrix( viewMatrix );
> >    cam1->setProjectionMatrix( projMatrix1);
> >    cam1->accept( nv );
> >
> >    cam2->setViewMatrix( viewMatrix );
> >    cam2->setProjectionMatrix( projMatrix2 );
> >    cam2->accept( nv );
> >
> > The problem: both cameras render to the SAME texture (the texture
> attached
> > to cam1), one right over top of the other. I confirmed this by attaching
> an
> > osg::Image and writing it to disk.
> >
> > If I traverse just ONE of the cameras, everything works correctly. But
> if I
> > traverse them both (as in the snippet above), both cameras render to the
> > FIRST camera's texture. If I reverse the order of traversal, both cameras
> > render to cam2's texture. (As I said, each camera was created separately
> and
> > each has its own Texture2D instance.)
> >
> > Any ideas? What's my mistake?
> >
> >
> > Glenn Waldron / @glennwaldron
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to