[osg-users] Shadows on two-sided polygons
a-goebel at gmx.de
Sat Nov 21 04:57:30 PST 2009
>> 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
You mean by setting the StateAttribute CullFaces to off and override for
my shadowed scene? This would probably work (even though it is set with
override in the ShadowMap? Which will override which?), but not for the
polygon-offset, as this is not controlled with state. I mean this line:
// negative polygonoffset - move the backface nearer to the eye point so
// shadow themselves
float factor = _polyOffset;
float units = _polyOffset;
>> 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.
It´s great to hear that, I haven´t used the new classes yet, as they are
not (at least in 2.8.2) part of the shadow-Example and I could not
easily play with them. However, I have made an option in my program to
use the StandardShadowMap, and it does not work for me (yet). Here are
- the side facing away from a light is not dark, example:
- the backside of a shadowed plane shows the shadow, too:
The correct images (with my shaders) look like this:
Is it possible to render a more correct shadow for models like mine with
StandardShadowMap? It seems a promising technology to me, I would like
to use it, and the results (where they are correct) look really good.
> 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.
I think it´s nicer to have the shaders as separate files, one can easily
load them and use them, no need to modify the source.
More information about the osg-users