Hi Ben,

Thanks for investigating, with my fix I obviously made the assumption
that the ShadowedScene contained the whole scene graph.  As for using
a separate light, this might well be the best route, one would
probably need to keep overwriting it's values each frame from the main
one.  There will probably be issues about having two light sources on
the same light number for a single RenderStage... ouch this one could
get a bit sticky, this suggests we'd need to make the ShadowedScene
its own RenderStage.

Could you explain a bit more about your scene graph layout so I can
better understand the mechanics of what is going wrong. Adding an
extra example scene graph into the osgshadow example that illustrates
this problem would be best
as this would give us something we can all test and reproduce the
problem and make sure fixes work well.

Robert.

On Thu, May 22, 2008 at 8:39 AM, Ben Discoe <[EMAIL PROTECTED]> wrote:
>> -----
>> From: Alejandro Segovia
>> Sent: Wednesday, May 21, 2008 5:50 AM
>>
>> Hey Ben,
>>
>> On Tue, May 20, 2008 at 6:20 AM, Ben Discoe <[EMAIL PROTECTED]> wrote:
>>> 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);
>>
>> I can't seem to find this in OSG 2.2. It must have been added recently.
>> Maybe the old code can be "forward ported"? :P
>
> I dug into SVN, and found the change, revision 7690, December 15, 2007.  
> Comment is "Tweaked the ambient lighting contribution so that the OpenGL 
> vertex lighting has the ambient light source switched off, and use the 
> fragment shader to add this contribution back in."
>
> That added the code:
>
>  // set to ambient on light to black so that the ambient bias uniform can 
> take it's affect
>  
> const_cast<osg::Light*>(selectLight)->setAmbient(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
>
> Unfortunately that breaks ambient light for the entire rest of the scene, 
> because that light is the same light used to illuminate everything, even 
> outside the shadowed sub-graph.  Setting ambient to black has no effect if 
> your materials already have no ambient.  But if they have ambient, then 
> osgshadow is wiping it out, resulting in very dark objects.
>
> So yes, the code can be 'forward ported' - we can remove that black ambient, 
> or some other solution such as using a separate light.  Robert, should i 
> submit the fix to osg-submissions?
>
> -Ben
>
>
> _______________________________________________
> 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