zinnschlag/openmw — pull request #1288 by mrcheko (2014-03-15 15:01:43+00:00)
Title: Stable CSM shadows + enhanced shadow filtering

At some point I wanted shadows to become stable. So these commits is the result.
While exploring the problem I realized that we can't make shadows stable with constantly moving and rotating sun and player camera(also checked it in CryEngine 3.5 - they didn't achieve stability when light rotating, too). So I took idea from skyrim: shadows don't move during some short interval then they move fast to point where they should be if they would move constantly. When standing still shadows still have several pixels blinking but that can't be cured even with stable CSMs. It's now controlled from weatherManager (if u set mSunUpdateInterval to 0.0, u'll get old constant moving and shadow jittering).

Filtering: uses 16 samples instead of 4 earlier. And I can say 512 shadowmaps looks the most natural because they are the softest. Actually there is strange problem in shader results: small dots which don't calculate shadow factor for several neighbour pixels (only on terrain shadows! shadows on objects are ok). I don't know what cause it.

I also tried to set csm to 4 cascades but there aren't enough texture samplers in shader 2.0. So that 'outdoor split count' was added just for it. I would do shadow texture atlas for all 4 shadowsmaps, but don't know if it's possible in ogre system.
Also I don't know if shader will compile for glsl, though I've added 1 branching (frac() in hlsl, fract() - glsl)in it.

Any discussion is welcome.