[osg-users] How to apply shadows to a scene with different shaders

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Tue Jul 22 13:51:46 PDT 2008


Hello Denis,

> Is there a 
> way to get Shadow texture from osg ShadowMap and pass it to another 
> shader? Am I going in a right direction? Should I use osg ShadowMap to 
> get shadow texture and pass it to different shaders or something else?

I definitely think you should use osgShadow::ShadowMap if that saves you 
having to reimplement the same thing yourself!

Check the top of the shader in src/osgShadow/ShadowMap.cpp, there is a 
bunch of uniforms with names that start with "osgShadow_". You can use 
those same variable names in other shaders, and you will then have 
access to the same data (as long as the shader is on a node in the 
subgraph under the ShadowedScene node). The sampler is the shadow map 
itself, and the others are parameters. So you can use the same code and 
just combine it with whatever else you want to do.

Remember that lighting in CG is just a product (multiplication) of 
different values, and so you can multiply the value you get from the 
shadow2DProj() function call with other colors to get the result you want.

Hope this helps,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/



More information about the osg-users mailing list