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 -- ______________________________________________________ Jean-Sebastien Guay [email protected] http://www.cm-labs.com/ http://whitestar02.webhop.org/ _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

