Hi Peter,

For situation like yours I would recommend overwriting osgShadow::LightSpacePerspectiveShadowMapVB and its internal ViewData class. Internal ViewData contains all the resources you need including shadowCamera. You may then add your own uniform or change any states used for shadow map prerender or final render. See StandardShadowMap::ViewData::init method to learn what states are set by these ShadowTechniques. Btw, if you look there you, will notice that shadow prerender pass overrides any program with fixed pipeline NULL program. So unless you set you shaders with PROTECTED attribute you may not need the uniform.

I think we already wrote about overriding ViewDependentShadowTechniques in the past. If you look carefully you would find posts with neccessary example code.

Cheers,
Wojtek




-----Oryginalna wiadomość----- From: Peter Amstutz
Sent: Thursday, January 13, 2011 4:48 PM
To: OpenSceneGraph Users
Subject: [osg-users] different rendering states for different passes?

Hello all, I have a bit of a knotty problem and was hoping for some
advice.  I am using OSG 2.8.3.

I am using osgShadow::LightSpacePerspectiveShadowMapVB, which renders
the scene in two passes; the prerender stage renders the shadow map, the
main state renders the scene.  My understanding is that the behavior of
the two passes is controlled by setting different shader programs at the
scene root, which sets the default shader program for the whole scene.

However, I am also using shader programs at some of my leaf nodes.  I
would like it to accept shadows, so it needs to read the shadowTexture
uniform.  However, this uniform is only available on the main drawing
pass, not the prerender pass (since the purpose of the prerender pass is
to generate the shadow texture).  The problem I am encountering is the
fact that my shader program does not have a way to distinguish between
executing the prerender pass and the main pass, and attempts to read the
(non-existent) shadowTexture uniform in the prerender pass, which causes
a GL error and results in the node not showing up at all.

I know the solution is to use different shaders for different passes,
but I haven't figured out the right way to set up OSG to do this at the
leaf.  Can anyone point me in the right direction?

--
Peter Amstutz
Senior Software Engineer
Technology Solutions Experts
Natick, MA
02131

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to