I noticed that using osgShadow::ShadowMap in my scene makes everything very 
dark, even nodes not part of the shadowed scene.  Studying the OSG code, i 
found this in ShadowMap.cpp, in ShadowMap::cull:
        
const_cast<osg::Light*>(selectLight)->setAmbient(osg::Vec4(0.0f,0.0f,0.0f,1.0f);

The light's ambient is set to black, and never restored!  That certainly 
explains why my whole scene is darker than normal.

I thought i might fix it by saving the ambient value, and restoring it later at 
the bottom of ShadowMap::cull().  And in fact, this does restore the scene's 
lighting - but, it prevents ShadowMap from drawing a shadow correctly.  
Apparently, ShadowMap needs this black ambient set later after cull(), probably 
during render().  But if the light is black during the scene's render(), that's 
not good.

Does anyone see a solution to this?  I can only imagine a couple of 
possibilities:

1. Move the black-ambient from cull() to render pass somehow.  I don't see any 
explicit render() code in ShadowMap so i have no idea how this would work.  It 
seems like it must be possible.

2. Workaround: Make a second light, and set it with ShadowMap::setLight.  Then 
ShadowMap can use that light with black ambient, and leave the real light 
alone.  But, this is messy; we don't actually want 2 lights turned on in the 
OpenGL pipeline, and we'd have to constantly copy values (like direction) from 
the real light to the dummy light.

-Ben


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

Reply via email to