just some info about why variance shadow mapping is not totally fine in shade-c (not in scientific language):

variance value = blurred(depthmap.x*depthmap.x) - blurred(depthmap.x)*blurred(depthmap.x)

the 0.91b variance shadow mapping by default works with bad blurring, because it uses only one channel for depth (actually depthmap.x), then blurred by a pp shader, then read by object pixel shaders. it is squared in the object pixel shaders just before calling the variance shadow mapping function.
by this approach you always get the same squared values, thus variance is always zero! thus can get only black or white pixels, i.e. the blurred areas are also result in totally shadowed pixels. I made a lerping afterwards with the original depthmap and finally got blurred shadows, but this is only a hack.

the right solution is to get the depth on one channel e.g. depthmap.r, and store its squared value on another channel e.g. depthmap.g, and then do the blurring both on depthmap.r and depthmap.g. this way if you get the square of blurred depthmap.r, it won't be the same as the squared and then blurred value stored in depthmap.g, thus variance won't be always zero as before, thus you can get correct sahdowmapping.

the main advantage of variance shadow mapping over PCF smoothing (like in the default PSSM shader), is its speed, because done directly once on depthmap, and not on screen pixels in the object pixel shaders.

I will implement it soon laugh

Last edited by sivan; 07/04/13 12:18.

Free world editor for 3D Gamestudio: MapBuilder Editor