Hi Wojtek,
Duelling frusta can be really nasty.
I agree, but as I said, I seem to be seeing the issues even in cases where the view direction is nowhere near the light direction...
However, minLightMargin should not significantly affect precision of shadow map. It may affect performance but precision could get only a little worse in DrawBounds or CullBounds when some large object behind viewer gets classified as shadow casting, which in turn will cause ShadowVolume to grow a bit and hence ShadowMap will loose some precision. But on average it should not change much.
OK, good to know that that parameter at least should not change things significantly, I'll concentrate my efforts on tweaking maxFarPlane.
maxFarPlane on the other hand can affect the precision significantly. Paritcularly with ViewBounds it can quickly show the ugliness of raserized shadows.
But I'm seeing the worst stability in DrawBounds. In that case, about 70% of the time the shadow looks really great, and 30% of the time the shadow flickers like crazy.
minFarPlane is responisble for clipping frustum depth height. When frustum depth grows, the base of the pyramid ie size of far plane rectangle also grows proportionally, and ShadowVolume becomes also larger. With Duelling Frusta case, size of frustum far plane square is almost linearly projected to shadow map. So if for example we have 90 deg FOV and 1 km maxFarPlane, it translates to 2km x 2km (2 * 1km * tan( 45 deg ) ) size of frustum pyramid base. Projecting this into 2048x2048 map will give mapping close to 1m per texel resolution.
But it should at most go to the max size of the shadow casting scene, right? I mean even if I have a 5km maxFarPlane, if my scene is as I said about 120m x 100m x 100m it should never grow to (2 * 5km * tan( 45 deg ) ) = 10km right? It should be clipped to shadow casting scene size, and also to view/cull/draw bounds, and only then should the maxFarPlane value be used to limit the far plane from going too far? Or am I getting things backwards?
Should I be setting maxFarPlane to about 100m? I'll try that tomorrow (I'm at home now) - the minimum value I ever set it to is 1km... I might also have to find a way to tweak the values per scene. I'm getting the impression that one value for all scenarios just won't cut it.
Another question, does maxFarPlane indicate a far plane width (i.e. the base of the pyramid as you said), or a distance from the viewer to the far plane? I thought it was the maximum the far plane could extend to from the viewer, but above you seem to be saying it's the width of the far plane. Although both values are related by the camera FOV, it's clearly not the same thing.
Now if using similar math to the above, you see that you get worse results than anticipated let me know. There is always a chance for some bug in shadow volume math. When you notice such thing, the best would be, if you could provide simple example illustrating the issue. Then I will gladly look at this problem.
Thanks, I understand you don't want to debug a problem that may well be related to the limitations of the technique. I'll look into what you said, and if I find anything suspicious I'll put together an example.
Thank you, 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

