Hi Robert,
Thanx for the info about that one. We will most certainly need multi-threaded
rendering later on.
I am currently looking into the NodeMask solution.
What about adding an array of states or shaders to a node?
This would make it possible to hold multiple shaders in one node and index them
differently depending on what camera you use.
Is that a good idea for the future?
Viggo
> Date: Fri, 23 May 2008 09:16:35 +0100> From: [EMAIL PROTECTED]> To:
> [email protected]> Subject: Re: [osg-users] Rendering the
> scene multiple times with differentshaders.> > Hi Viggo,> > You should be
> able to set things up using NodeMasks, as you could set> the push/pop
> traversal mask via a cull callback that decorates each> branch of your
> multipass.> > Using osg::Switch would require to modify the switch during the
> cull> traversal which is something you should avoid if you ever want to>
> multi-thread multi-context rendering.> > Robert.> > On Thu, May 22, 2008 at
> 9:11 PM, Viggo Løvli <[EMAIL PROTECTED]> wrote:> > Hi Eric,> >> > It looks to
> me like using the switch could be the solution for my needs.> > I think that
> it would either have to be a switch, or a mask.> >> > An example of what I
> want to do could be written like this:> >> > Original part of my scene
> graph:> > Root> > |> > +--Node_1 (Specifies a states and a fragment shader)>
> > | |> > | +--Node_2 (Specifies a geometry to be rendered)> > | |> > |
> +--Node_3 (Specifies another geometry to be rendered)> >> > Using the switch
> to make sure I can render the scene twice with different> > shader:> > Root>
> > |> > +--Switch> > | |> > | +--Node_1 (Specifies states and a fragment
> shader)> > | | |> > | | +--Node_2 (Specifies a geometry to be rendered)> > |
> | |> > | | +--Node_3 (Specifies another geometry to be rendered)> > | |> > |
> +--Node_4 (This is a clone of Node_1 where I have added a new> > shader)> > |
> | |> > | | +--Node_2 (This is the same node as Node_2 above)> > | | |> > | |
> +--Node_3 (This is the same node as Node_3 above)> > | |> > Conclusion:> > -
> The switch will let one scene render use Node_1 and another scene> > render
> use Node_4.> >> > Using a mask to achieve the same effect:> > Root> > |> >
> +--Node_1 (Specifies states and a fragment shader, MASK = 0x1)> > | |> > |
> +--Node_2 (Specifies a geometry to be rendered)> > | |> > | +--Node_3
> (Specifies another geometry to be rendered)> > |> > +--Node_4 (This is a
> clone of Node_1 where I have added a new shader,> > MASK = 0x2)> > | |> > |
> +--Node_2 (This is the same node as Node_2 above)> > | |> > | +--Node_3 (This
> is the same node as Node_3 above)> > |> > Conclusion:> > - This should work
> as far as I have understood the mask system, and this> > time I do not need
> the switch node.> > - In this solution I would not need to alter the position
> of Node_1 in> > the tree.> >> > It is essential for me to have a solution
> where I do not need to do any work> > in between each time I render the
> scene.> >> > Viggo> >> >> >> > ________________________________> > Date: Thu,
> 22 May 2008 17:14:09 +0200> > From: [EMAIL PROTECTED]> > To:
> [email protected]> > Subject: Re: [osg-users] Rendering the
> scene multiple times with> > differentshaders.> >> > I think use osg::Switch
> is right way to do.> >> > You can set a StateSet to any Node, then (correct
> me if I'm wrong) all> > children will inherit the stateset.> >> > So, I think
> about a graph like this:> >> >> >> > Root> >> > |> >> > ….> >> > |> >> >
> Switch> >> > ___|______________________________> >> > | |> >> > |> >
> Node2->stateset(shader2)> >> > Node1->stateset(shader1) |> >> >
> |_________________________________|> >> > |> >> > |> >> > Rest of your graph>
> >> > ….> >> >> >> > So you can insert this kind of switch to any subgraph
> which use another> > shader, you do not have to duplicates the rest of your
> subgraph since two> > parents can have the same child.> >> >> >> > Another
> way (similar) is to use a simple group instead of the osg::Switch,> > but let
> osg to choose the good branch via nodeMask. In this way, you do not> > have
> to update your graph between to passes.> >> >> >> > I hope it helps you.> >>
> >> >> > Eric Z.> >> >> >> > ________________________________> >> > De :
> [EMAIL PROTECTED]> > [mailto:[EMAIL PROTECTED] De la part de Viggo> > Løvli>
> > Envoyé : jeudi 22 mai 2008 15:57> > À : [email protected]>
> > Objet : [osg-users] Rendering the scene multiple times with> >
> differentshaders.> >> >> >> > Hi,> >> > My scene contains models that use one
> or many textures, some use vertex and> > fragment shaders of different kinds.
> Complex but good looking :-)> >> > I need to render the scene many times each
> frame.> > The first render is a normal one, so I need no change in textures,
> states or> > shaders.> > The second render is a multi target render. Here I
> need to change all the> > fragment shaders that my scene uses. Each shader
> need to output data to each> > render target.> >> > My question is:> > - What
> is the best way to switch shaders on many models in my scene-graph?> >> > One
> way to do it is to put a shader on the top node and override all child> >
> nodes, but that only works if the entire scene-graph renders with the same> >
> shader. My scene uses different shaders, so overriding is not the solution.>
> >> > One idea I have is to parse through all scene graphs that I add to my
> world> > and duplicate all nodes that sets a fragment shader. I could then
> create one> > shader for the normal render and one for the multi target
> render. This would> > require that I mask those nodes so that the correct
> ones are used in each> > render. This will require me to write my own
> function for adding nodes to> > the scene.> >> > Anyhow, I would be very
> happy if someone could guide me in the right> > direction on this one.> >> >
> Regards,> > Viggo> >> >> > ________________________________> >> > Si det
> direkte med Windows Live Messenger. Lei av å vente på svar?> >> >
> ________________________________> > Få Windows Live Messenger du også. Snakk
> gratis med tekst, telefoni og> > video.> >
> _______________________________________________> > 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
_________________________________________________________________
Glem minnepinnen - SkyDrive er her.
http://skydrive.live.com/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org