Hi Viggo,
> 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? > I think what you need is something like osg::Switch but on the StateAttribute level. I am not sure, but I think such one does not exists. Hence you could try to write your own visitor class, which will go through all your objects and change the shaders accordingly for example. Maybe we can start discussing of implementing something like osg::SwitchAttribute or osg::SwitchStateSet ? > 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. > Do you want to implement Deffered Lighting? If yes, then I would suggest to use multiple rendering targets just in the first pass, when you render the normal colored geometry. Or you could use one shader which renders all the normals and whatever is needed for the deferred lighting to the mrt targets for the entire scene. > 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. > If you duplicate your nodes, then you can use osg::Switch for that purpose. It can switch between different nodes, so exactly what you need. However I am not sure if it is a right idea, since you will duplicate all the geometry and hence need more memory. Best regards, Art > Anyhow, I would be very happy if someone could guide me in > the right direction on this one. > > Regards, > Viggo > > _________________________________________________________________ > Snakk gratis med tekst, telefoni og video. Få Windows Live > Messenger du også. > http://get.live.com/nb-no/messenger/overview_______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org __________________________________________________________ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

