[osg-users] Shadows on two-sided polygons

Wojciech Lewandowski lewandowski at ai.com.pl
Fri Nov 20 16:01:05 PST 2009

Hi Guys,

Assuming one light (which is reasonable considering other shadow 
limitations) it should be possible to compute ambient term in fragment 
shader only (its simply: gl_FrontLightModelProduct[0].ambient). If you have 
right ambient term you could use shadow factor to blend between  glColor 
(containing difuse+ambient from vertex pipeline) and above ambient computed 
in fragment shader.


From: "Jean-Sébastien Guay" <jean-sebastien.guay at cm-labs.com>
Sent: Friday, November 20, 2009 10:17 PM
To: "OpenSceneGraph Users" <osg-users at lists.openscenegraph.org>
Subject: Re: [osg-users] Shadows on two-sided polygons

> Hi Andreas,
>> I have turned off those things, and now it works good for me. Should I
>> refactor that in a way that the application programmer can choose the
>> behaviour and submit that?
> You could, but I think setting those things via overridden state is also 
> acceptable, since if you need that you'll probably know what to set...
>> Another thing: I have written a vertex and a fragment shader that work
>> together in a way that allows the shadows to be rendered exactly in the
>> ambient color. This means that shadowed surfaces look the same as
>> surfaces that face away from the light. This gives a much more natural
>> feeling, and you don´t get false shadows on the backs of polygons. I
>> needed the vertex shader to get the correct ambient color, I think it is
>> not possible to do this with a fragment shader alone.
> I assume you're talking about osgShadow::ShadowMap? The shaders used for 
> the ViewDependentShadow classes (LightSpacePerspectiveShadowMapDB, CB, VB) 
> already do this. Note that osgShadow::StandardShadowMap is the equivalent 
> of osgShadow::ShadowMap but under the ViewDependentShadow architecture, so 
> you could have used that and you would have gotten the right shadow 
> ambient color.
> You can always submit those shaders (as part of modified ShadowMap.cpp 
> files so that they work by default), I'm sure anyone still using 
> osgShadow::ShadowMap will be glad you do.
> J-S
> -- 
> ______________________________________________________
> Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
>                                http://www.cm-labs.com/
>                         http://whitestar02.webhop.org/
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 

More information about the osg-users mailing list