After having a GDNet account for a while, I figured it was about time I started using my Journal. I think this might be quite a big first entry too :).
Recently I've been lookng into different shadow mapping techniques, and trying to find out new ways to hide/remove aliasing and shadow acne. Variance Shadow Maps (VSMs) seem like a good candidate, although i've had trouble playing with them at home due to my lacklustre hardware (a laptop with a GeForce FX 5650 Go). Anyway, one of the cool things about VSMs is the fact you can blur the shadow map directly (or let the hardware filter it for you). This got me thinking - what other ways could you use a blurred shadow map? Due to the shadow map test being binary (in/out of shadow), the information about the shadow boundaries is lost when you blur the shadow map. But what if we don't make the shadow test binary, and instead use a kind of fuzzy test?
So, instead of:
float lightAmount = 1.0f;
if((lightSpaceDepth - shadowMapDepth) < 0)
lightAmount = 0.0f;
We do something like this:
float lightAmount = 1.0 - ((lightSpaceDepth - shadowMapDepth) / fuzzyDist);
lightAmount = clamp(lit, 0, 1);
where fuzzyDist is the range where the test result ranges from 0 to 1 e.g. it will give us less shadow where depths are close together. Because our shadow map values now look like this (since they are blurred):
as apposed to this:
it means we should get a nice soft shadow boundary.
I gave it a go - I made a regular 512x512 shadow map, down sampled it to 256x256 and then ran a 13x13 gaussian blur kernal over it. This is the result:
(Featuring a T-rex by cyberchinchilla from Turbo Squid)
I was quite pleased with the result - there's no aliasing even though the shadow map is only 256x256 and I only have to take a single sample in the lighting shader meaning it runs quickly. What's even better, by increasing the value of fuzzyDist, I was able to increase the blurryness of the shadow at no extra cost.
However, my happyness was pretty short lived when I tried it with other bits of geometry:
As you can see, using a fuzzy test to determine the amount of shadow, we loose a lot of important information about the scene - the knot is actually resting on the floor, yet the shadow at the point of contact is very weak.
Even worse that that, geometry that isn't primarily smooth in nature looses too much info in the blurring process giving you results like this (please excuse the poor modelling :))
As you can see, the building in the top right is showing lots of false self shadowing. TBH, these are all things that I expected - I didn't really foresee much use in blurring the shadow map, but the results are also more pleasant (and faster) than I assumed.
To try and combat these issues, I'm going to use the original depth map in conjunction with the blurred one, but so far it looks like i'll have to take multiple samples from it to have any useful info to combat the problem.
Anyway, I'll get back shortly if I make any progress.