First off, I just want to say that I am very impressed with Sunburn, which I started using a few days ago....
My first (of probably many!) questions:
I have an outdoor scene where the camera is set in a typical FPS view, near the ground. There is a relatively complex model close to the camera, some 'enemies' in the middle distance, as well as distant buildings (cubes at the moment!). I have one directional light which cast shadows on all objects, to simulate sunlight.
The problem is, if I set the shadows settings to be something like these:(approximate settings so that the distant buildings are shadowed correctly)
..then the shadows on the forground model become very indistinct, or even invisible on some variations.
To get the foreground model's shadows looking correct, then I use something like these settings:
I realise that I am trying to get two very extreme ends of the spectrum working together, so how should I be approaching this? (Other than baking the lights on the distant buildings, which I don't want to do, as I want a day/night cycle).
Further to this, I have just tried scaling down all models by a factor of 100 (and changing all the shadow settings to compensate), as it occurred to me the problem may have been to do with the resolution of the shadow map. If I scale any smaller, odd clipping starts to occur (I am guessing some kind of view frustrum precision at a wild guess?) Anyway, It made some difference in the quality by scaling everything down, but basically the problem still remains: is there a way of getting detailed shadows in both the foreground and background?
And also, while I am harassing you with the shadow questions: Is there a way of setting a shadow-casting light to only affect dynamic scene objects (the editor only lets you choose from: All, Static, or None.)?
At least that way I could choose to use texture baking for static scenery if there is no satisfactory solution to my original problem!
The default shadow resolution and directional level of detail provides the best balance of visual quality and performance in average scenes, but control over these is exposed so you can also adjust them to better fit your game.
The ShadowMapManager properties that help tune the shadows are:
PageSize - the size of the render targets used to store the scene's shadows maps. More than one shadow map can fit on a page, but the page size will limit the maximum shadow map size (the map needs to fit on the page - generally the maximum map size is half of the page size due to packing).
The default value is 2048 (but does not have to be a power of two). On Xbox this should ideally be reduced to 1024 or lower to avoid predicated tiling and the related performance hit. On PC it can be increased depending on the target hardware, though be careful - while my 8600GT supports 4096x4096 textures it will not create a floating point render target this large (it usually caps out around 3200x3200).
ShadowLODRangeHints - adjust the lod transition points for direction shadows, this allows you to push the transition points away from the camera to make the lod seams smoother, or bring them closer to the camera to increase resolution of shadows near the camera.
These adjustments are relatively free performance-wise, though it's a constant struggle to balance greater shadow quality at the camera with smooth lod transitions.
The best way to adjust these values is to consider where the shadows realistically can falloff - can you get away with shadows that fade before the far clipping plane (can you hide this with fog)?
Then make sure the shadow end distance is right at the very edge of your target falloff area (to avoid wasted shadow map space), adjust the shadow fade start distance to soften the transition (if needed), then try adjusting the lod range hints to get the most pleasing combination of detail and lod transitions.
Finally adjust the shadow page size if necessary, your previous adjustments should have helped reduce the size of the page you'll need (even a little bit helps).
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
We hadn't considered shadow casting only from dynamic objects, that's an interesting idea - though it would cause lights to illuminate dynamic objects through walls (statics would not cast shadows).
The clipping you mentioned is likely from the visible distance still being very high after scaling down your scene - if you adjust the visible distance to be relative to the scene it should fix the problem.