[osg-users] Camera question
wyattbsearp1881 at gmail.com
Thu Nov 5 07:01:06 PST 2009
I am working on this now and another question has arisen. How do I apply
different shaders for different render passes.
For example, I want one set of shaders to be in effect when I render to
texture, but a different set of shaders for the other camera(s), which will
use the texture from the RTT camera.
Do I attached my stateset with the shaders directly to each camera node?
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Paul Martz
Sent: Wednesday, November 04, 2009 2:39 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Camera question
Wyatt Earp wrote:
> If I have a prerender camera for rtt, and another
> camera which will take as input the texture from the rtt camera do
> some "stuff" then render to texture the output, and then a third
> camera which takes camera 2s output as input and performs then final
> render... what would my scenegraph look like?
It really depends on how you want the Viewer's Camera manipulator to
work. Do you want it to manipulate Camera 1 or do you want it to
manipulate your final render camera? It also depends on what kind of
scene geometry you are rendering for each of your Cameras.
Here's one way to do it:
I would have your Camera 2 configured as prerender at the top of the
scene graph. I would have your Camera 1 also configured as prerender and
added as a child to Camera 2. The I would setSceneData in
osgViewer::Viewer, passing in Camera 2 -- osgViewer's built-in Camera
will be the "final render" camera in your example.
The problem you typically run into with this kind of setup is that you
want to attach a camera manipulator to the osgViewer::Viewer, but you
want it to manipulate the matrices in Camera 1, not the top-level Viewer
("final render") Camera. You can do this with some fairly hairy
Here's another way to do it:
Use the osgViewer::Viewer Camera as Camera 1 in your example. So you'll
need to call Viewer::getCamera()->attach to make it into an RTT Camera
(just like you would any Camera). For the top of your scene graph,
you'll probably want a Group with Camera 2 as a child. Camera 2 is
configured as post render, and it will have the "final render" Camera as
a child, also set up to post render. In addition to having Camera 2 as a
child, your top Group node will probably also be the parent of the
geometry you need to render in your first render pass.
With this configuration, the camera manipulator attached to Viewer will
manipulate the matrices in Camera 1 without the need for fancy rewiring.
That is the most common case, as Camera 1 in your example is usually the
parent of a large scene graph, whereas Camera 2 and the "final render"
Camera are usually just rendering screen-oriented textured quads and
therefore do not need a camera manipulator.
osg-users mailing list
osg-users at lists.openscenegraph.org
More information about the osg-users