Deferred Rendering Shadow Artifact
I am currently in the process of writing a Deferred Rendering engine in XNA, compiled from a bunch of sources online. One source, The Cansin’s deferred rendering engine tutorial, supplied a good algorithm for calculating the shadow factor in generating the light map. Turns out, used in it’s raw form, the calculation generated some strange shadow anomalies.
I spent a great deal of time trying to figure out what exactly the issue was. Tried many different modifications of the equation to figure out an improved model, but to no avail. Finally, I realized that it was possible that some of the values were not matching the intended range of 0-1, so I added a clamp to the final value. Lo and behold, the problem is fixed!
Here is the fix, found in the lighting shader file when calculating shadow factor:
shadowFactor = min(1.0f, (lightZ * exp(-(DepthPrecision * 0.5f) * (len - DepthBias))));
Hopefully this will help fix any shadow mapping anomalies anyone experiences!