[osg-users] Shadows on two-sided polygons
lewandowski at ai.com.pl
Sun Nov 22 11:59:46 PST 2009
> thanks a lot for your detailed answer. I will work through the example
> within one of the next holydays, as I am not a professional programmer
> (I´m a math teacher) and will need some quiet time for a demanding task
> like this. My software is a math-software to illustrate vector geometry,
> and thus displays planes and so on simply as polygons. That´s the reason
> I need two-sided materials (or at least I decided to do so, the
> alternative would have been to use more massive planes).
> For the time being it is a comfort for me that I didn´t make a simple
> mistake and that it is quite some work to adjust the StandardShadowMap
> to two-sided polygons.
Well... it depends. If the only trouble is incorrect back face lighting and
lack of shadows from faces in front of light, then method could be simpler:
1. You can write your own shaders. I have read you already did that for
ShadowMap. Then with small modification you could try using them with
StandardShadowMap. This would give you the correct lighting I guess.
Warning: if you want to adapt shaders made for ShadowMap make sure you
change names of uniforms to match names used by StandardShadowMap (they use
different naming convention).
2. To make sure both faces cast shadows simply call setMode( GL_CULL_FACE,
OFF | OVERRIDE ) on your scene root stateset. This will force usage of both
faces in shadow map rendering.
I hope this will let you reach the goal. But if you don't expect to use any
more complex - view dependent techniques in the future then it would be
easier to stay with ShadowMap. StandardShadowMap gives the same shadow
precision. When one asks why there are two techniques doing the same then
the answer is that StandardShadowMap lays foundation for more advanced
techniques like MinimalShadowMap & LispSM variants. So, if one day you
decide to switch to LispSM or MinimalXXXShadowMap then migration will be
definitely simpler when you make your tweaks for StandardShadowMap.
> Who maintains ShadowMap? I´d like the maintainer to do some tests with
> my shader. If you think it´s better than the standard one, I´ll refactor
> it into the Shadow-Map code. For a first impression, see the images in
> the last mail.
I guess that would be Robert. If you post the fixes on submissions lists
all interested may work as your testers.
> Regards & thanks for the example,
More information about the osg-users