[osg-users] FBO render once and display the different buffers in multiple osg viewers

1 view
Skip to first unread message

Mo Flanders

unread,
Aug 30, 2010, 7:08:52 AM8/30/10
to osg-...@lists.openscenegraph.org
Hi,

i'm using FBOs in osg, everything works fine. I can visualize the color buffer i rendered to OR i can visualize the render buffer. Is it possible to use two instances of the viewer one for visualize the color buffer AND the other should render the render buffer of the same scene?

Please tell me if I made an error in reasoning :O. Perhaps there is another way to do this... Any hint?
...

Thank you!

Cheers,
Mo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=31150#31150

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

Robert Osfield

unread,
Aug 30, 2010, 9:14:50 AM8/30/10
to osg-...@lists.openscenegraph.org
Hi Mo,

You wouldn't need to use two viewers, just one
osgViewer::CompositeViewer with two Views. See the osgcompositeviewer
for examples of how to set things up.

When doing render to texture you generally want to keep everything on
the graphics card with no round trips to the main memory, so if you
want to use the result of one render to texture pass in some later
rendering then it's best to do that from the same graphics context,
which in essence means the same graphics window. osgcompositeviewer
supports multiple views sharing the same graphics context so this will
be fine.

You can also use a osgViewer::Viewer with multiple slave Camera to
achieve the same result as using CompositeViewer and multiple Views,
but if you have conceptually separate views that have independent
controls then CompositeView will be more appropriate. If you have a
simple debug render you want to do ontop of the main window then using
a slave can be the most convenient, the osghud example provides code
that does this, using a camera in the scene graph or in the slave
camera in the viewer, as well as a path that composite viewer.

Robert.

Mo Flanders

unread,
Aug 30, 2010, 10:20:43 AM8/30/10
to osg-...@lists.openscenegraph.org
Hi,

First of all, thank you for your prompt response. However another quick question:
Is it also possible to display both buffers based on RTT and stored in the texture memory in different windows or on multiple displays?

What I want to do:
1. Pre-Render the scene using FBOs
2. Store the color buffer and the appropriate render buffer in the texture storage
3. Create 2 Windows with an Orthographic Camera
4. Display the Color Buffer and the Render Buffer on Planes

...

Thank you!

Cheers,
Mo

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=31157#31157

Robert Osfield

unread,
Aug 30, 2010, 11:44:36 AM8/30/10
to osg-...@lists.openscenegraph.org
HI Mo,

If you want to use the result in a separate window/display you'll need
to copy the result back to an osg::Image and then use this image on
another texture on the other windows. osg::Camera supports attaching
an osg::Image to it and will automatically copy the frame buffer(or
FBO) to the image, and osg::Texture* all are able to detect an update
to an osg::Image so will automatically download the result, so it's
possible to do this wiring up relatively easily, but.. performance
won't be great as it requires a round trip to the CPU/main memory.

Robert.

Mo Flanders

unread,
Aug 31, 2010, 8:29:09 AM8/31/10
to osg-...@lists.openscenegraph.org
Hi,

I think i got a solution. Isn't it possible to render two planes, one with the color buffer and the other with the render buffer in one scene. After this add to the normal Viewer two slaves like in the osgcamera example? As result, two windows and no extra copy operations, isn't it?
...

Thank you!

Cheers,
Mo

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=31200#31200

Robert Osfield

unread,
Aug 31, 2010, 8:39:35 AM8/31/10
to osg-...@lists.openscenegraph.org
Hi Mo,

On Tue, Aug 31, 2010 at 1:29 PM, Mo Flanders <drei...@gmail.com> wrote:
> I think i got a solution. Isn't it possible to render two planes, one with the color buffer and the other with the render buffer in one scene. After this add to the normal Viewer two slaves like in the osgcamera example? As result, two windows and no extra copy operations, isn't it?

I'm don't understand what you mean here so can't comment on any of it.

Robert.

Reply all
Reply to author
Forward
0 new messages