What you need to do is use a render to texture (RTT) technique, with
rendering the six scenes to six separate textures or the six scenes to
the six faces of a cube map texture. The OSG supports both approaches
and each approach is essentially the same setup - you create an
osg::Camera to render each scene to a texture/texture face, the only
difference is the assignment of the texture(s) to the various Cameras.
Another decision you need to make is how you want to interact with
each scene - it's a fixed view of each scene, or do you want to treat
it as a separate View with it's own camera manipulator/event handlers?
With a fixed view then you could just set each Camera's View matrix
at setup time, add the scene as a subgraph to the Camera and then add
this Camera to the scene graph. If you want each View to be
interactive then you could do this using CompositeView with each scene
having it's own osgViewer::View.
In all these case the Camera set up, whether it's a render to texture
Camera in the scene graph or a the master Camera of osgVIewer::View
will essential be the same - you just assign the texture/texture face
to each Camera.
Then you'll want to have one last Camera or View (with it's master
Camera) that renders to the window and use all the results from the
RTT Camera's. To ensure that the various RTT Camera's are rendered
before the main Camera you'll want to use
There aren't any OSG examples that do exactly what you want, but you
can have a look at the osgprerender, oreprerendercubemap and
osgdistorion examples to see how RTT can be done in various ways. The
osgcompositeviewer will also give an illustrate of using multiple
Views with multiple Scenes, this example doesn't do an RTT but could
easily be adapted to do so by adding the appropriate texture
attachments and render order settings.
Hopefully once you get familiar with RTT osg::Camera usage it'll all
start to make sense - this part of the OSG is very powerful and
flexible but can be a bit overwhelming the first time you start to
On 18 March 2018 at 10:12, Jochen Maier <> wrote:
I want to do something like offscreen rendering.
What I want to do exactly:
I have one or more scenes (scene graphs) and one final scene.
The final scene contains a cube which has 6 different textures.
Now I have 6 different scenes (scene graphs).
I want to render all these 6 scenes in 6 textures and use this textures for the cube.
My problem is:
How is it possible to render one scene in a texture without render it in a seperatly window?
I hope you can understand my problem... because my english isn't very well^^
I've allready checked the compositeview example... but I don't understand it :/
Read this topic online here:
Post generated by Mail2Forum