Hi Wojtek,
All your math seems correct to me. I would use ( lightSpaceDepth * 0.5 +
0.5 ) to compare with shadow map. But you said you tried it.
Yes, * 0.5 + 0.5 seemed "more correct" but still only seemed to use the
first part of the possible range, so I think you're right that one of my
matrices is probably not set correctly. I'll investigate this.
Using
DEPTH_COMPONENT is also ok IMHO. Debuging shaders display these values
so its possible to access them.
Yes that was what I used as a base for getting the shadow map depth
value. And that value seems to be correct. My problem really seems to be
getting a correct light-space depth for the main pass fragment, in order
to compare it to the shadow map depth value.
Also, when I talk about range, I'm using the DebugShadowMap shader
depth-to-color transformations (the "rainbow" shader) to visualize the
depth. Thanks for that :-)
So I think that maybe your uniforms or
osg_ViewMatrixInverse should be checked. Long time ago we had an issue
with osg_ViewMatrixInverse not being set for nested cameras. We had to
set it ourselves in this case. I am not sure if this limitiation is
still present, it was few years ago.
I remember that too now that you mention it. I'll check it out.
Do I correctly decipher PCSS as percentage closer soft shadows ? I was
mixing SoftShadowMap shaders with MimimalShadowMap for some project in
the past. It was actually possible without changing comparison mode
because SSM also uses GL_COMPARE_R_TO_TEXTURE_ARB mode.
You're talking about PCF, which is not the same as PCSS.
PCF is simply filtering the shadow map by some filter kernel. This is
possible with the current ViewDependentShadow by simply sampling the
shadow map multiple times with offsets and averaging (i.e. doing
multiple shadow2DProj() calls). PCF does not give perceptually-accurate
penumbrae, it simply gives uniformly soft shadows. But it masks aliasing
and is not too costly.
PCSS involves filtering, but also searching for blockers around the
depth sample and varying the filter width based on the distance to
blockers and light size. So it gives perceptually-accurate penumbrae
(artist-tweakable, so not totally accurate, but still good looking). It
is more costly, because you take multiple depth samples for the blocker
search, and multiple depth samples for the filtering. And it requires
that shadow compare mode be turned off, because for the blocker search
you can't just get a "pass" or "fail" value as the shadow2D(Proj) -
sampler2DShadow will give. You need to get the real depth value from the
shadow map and compare that to the depth of the fragment in the main pass.
And remember, the DebugDraw's geodes turn GL_COMPARE_R_TO_TEXTURE_ARB
off for the HUD's drawable, in order to get the real depth... I needed
to do the same but in general in order to get the real depth from a
sampler2D of the shadow map in the main pass.
See this for a bit more detail:
http://developer.download.nvidia.com/whitepapers/2008/PCSS_Integration.pdf
So yeah, anyways, I think I'll be able to do this if I can get that
light-space depth correctly.
Thanks a lot for your help,
J-S
--
______________________________________________________
Jean-Sebastien Guay [email protected]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org