Hi J-S, Thank you very much! This was an excellent overview. GREAT !!!
Just one little last question: If I understand right whatever ShadowTechnique is used the result when reaching my scenes "user root node" (child of ShadowScene) there will be the shadow texture which I can use in always the same way. Since the shader code of StandardShadowMap seems to be very complete I could cut and paste it, do my extensions in there and add the program to the StateSet of my node. This should work in a flexible way with any Shadowtechnique used? - Werner - Am Freitag, 10. Dezember 2010, 14:50:37 schrieb Jean-Sébastien Guay: > Hi Werner, > > > I'm a little confused now. > > How are things workingh together? > > I have a ShadowScene and set the ShaderTechnique with my own class > > derived from SoftShadowMap. > > I wrote virtual methods for createShaders and createUniforms for support > > of my shaders. > > ShaderTechnique is having its shaders and now I see ViewDependentShadow > > is also having a different set of shaders. When is ViewDependentShadow > > coming into the game? > > Yes, it seems you're confused indeed :-) Let's go back to basics and > work from there. > > You use osgShadow by adding a ShadowedScene in your scene graph, and > setting a ShadowTechnique on that ShadowedScene. SoftShadowMap is one > possible shadow technique, and the ViewDependentShadow ones are others > (StandardShadowMap, MinimalShadowMap*, LightSpacePerspectiveShadowMap, > etc.). > > I was just using those shadow techniques as an example because you > hadn't mentioned which one you were using, just that you had subclassed > an existing one... > > But what I said still applies. The general idea is that you can attach > shaders (actually an osg::Program containing shaders) at any node in > your graph, and the osg::Program will be inherited downwards like any > state. The ShadowTechnique activates its own shaders at the > ShadowedScene level. So if no other nodes below the ShadowedScene have > an osg::Program, the one from the ShadowTechnique will apply to the > whole subgraph. But if a node below the ShadowedScene has its own > osg::Program, it will override the one from above for its own subgraph > (subject to the same rules of state inheritance as any other > StateAttribute, for example use of PROTECTED and OVERRIDE...). > > But the important part is, if you want your nodes below the > ShadowedScene to have their own shaders AND have shadows, they need to > do the shadow lookup the same way as the shaders that your > ShadowTechnique has. This will generally be in 2 parts, vertex and > fragment shader: > > If your ShadowTechnique's Program has a vertex shader (some do, some > don't), it will generally calculate texture coordinates for the shadow > map's texture unit. You need to do this in your own vertex shader too. > > If your ShadowTechnique's Program has a fragment shader (most do), it > will generally do a texture lookup in the shadow map's texture unit and > decide whether to use only ambient or full lighting depending on the > result of this lookup (whether the fragment is in shadow or not). > > Hope this helps, > > J-S -- TEXION Software Solutions TEXION GmbH - Rotter Bruch 26a - D 52068 Aachen - HRB 14999 Aachen Fon: +49 241 475757-0, Fax: +49 241 475757-29, web: http://www.texion.eu Geschäftsführer/Managing Director: Werner Modenbach _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

