Re: [osg-users] Problem with 2 RTT cameras

2013-02-21 Thread Robert Osfield
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 gwald...@gmail.com 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
 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


[osg-users] initializing the depth buffer with another camera's buffer before rendering

2013-02-21 Thread Christian Buchner
Hi,

I've been modifying the osgoit code sample to allow opaque objects to
occlude the depth peeled layers.

I found that rendering the opaque geometry into the depth buffer of each
peeled layer causes a lot of overhead because of the extra culling and
geometry passes each time.

Instead I would like to render my opaque object just once into the first
slave camera's depth buffer and copy the contents of its depth buffer into
the other slave cameras (or rather FBOs) before performing the depth
peeling passes.

So instead of clearing the z buffer at the start of each frame, would it be
feasible to copy the depth buffer from one FBO into another, and with
reasonable performance?

Christian
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] initializing the depth buffer with another camera's buffer before rendering

2013-02-21 Thread Sebastian Messerschmidt

Hello Christian,

do you need to copy it? Or is it sufficient to re-use it in terms where 
it is allowed to be modified by the second pass?
If later applies, you simply can bind the same depth buffer as input 
texture to your RTT pass.

Hi,

I've been modifying the osgoit code sample to allow opaque objects 
to occlude the depth peeled layers.


I found that rendering the opaque geometry into the depth buffer of 
each peeled layer causes a lot of overhead because of the extra 
culling and geometry passes each time.


Instead I would like to render my opaque object just once into the 
first slave camera's depth buffer and copy the contents of its depth 
buffer into the other slave cameras (or rather FBOs) before performing 
the depth peeling passes.


So instead of clearing the z buffer at the start of each frame, would 
it be feasible to copy the depth buffer from one FBO into another, and 
with reasonable performance?


Christian




___
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


Re: [osg-users] initializing the depth buffer with another camera's buffer before rendering

2013-02-21 Thread Mathias Fröhlich

Hi,

On Thursday, February 21, 2013 14:13:19 Sebastian Messerschmidt wrote:
 do you need to copy it? Or is it sufficient to re-use it in terms where
 it is allowed to be modified by the second pass?
 If later applies, you simply can bind the same depth buffer as input
 texture to your RTT pass.
That would have been my suggestion too. Since you seem to have shaders this is 
probably more efficient than blitting the depth buffer into each camera.

Greetings

Mathias
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with 2 RTT cameras

2013-02-21 Thread Glenn Waldron
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 robert.osfi...@gmail.comwrote:

 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 gwald...@gmail.com 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
  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

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with 2 RTT cameras

2013-02-21 Thread Robert Osfield
Hi Glenn,

On 21 February 2013 13:58, Glenn Waldron gwald...@gmail.com wrote:
 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.

The FBO attachment should be done totally independently from the
Camera's StateSet.  I can't yet think of reason that sharing a
StateSet would cause this problem, so am concerned that there is a bug
lurking somewhere.

Could you modify one of the OSG's osgprerender examples to illustrate
this problem, if we an reproduce the problem then we'll have chance of
finding out what is going on and fix any bug that doesn't reveal
itself.

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

Glad to see you've found a workaround, but what you did does still
sounds like it was reasonable.

Did the StateSet apply any of the textures that are being written to?

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] initializing the depth buffer with another camera's buffer before rendering

2013-02-21 Thread Christian Buchner
Hmm,

im am stuck trying to extract a pointer to an fbo object in the
postDrawCallback of my cameras, allowing me to call

fbo_ext-glBlitFramebuffer(...)

My offscreen render cameras perform their own FBO setup. I am merely
passing the hint to use a frame buffer object as render target by calling
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

And the only point in the osg source code where an accessor is provided to
an osg::FrameBufferObject seems to be in the RenderStage header file.

I haven't yet figured out how to get from an osg.:Camera or an
osg::RenderInfo to an actual fbo pointer.  *sigh*

Christian



2013/2/21 Christian Buchner christian.buch...@gmail.com

 Hi,

 I've been modifying the osgoit code sample to allow opaque objects to
 occlude the depth peeled layers.

 I found that rendering the opaque geometry into the depth buffer of each
 peeled layer causes a lot of overhead because of the extra culling and
 geometry passes each time.

 Instead I would like to render my opaque object just once into the first
 slave camera's depth buffer and copy the contents of its depth buffer into
 the other slave cameras (or rather FBOs) before performing the depth
 peeling passes.

 So instead of clearing the z buffer at the start of each frame, would it
 be feasible to copy the depth buffer from one FBO into another, and with
 reasonable performance?

 Christian



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org