Yes, I clamped the variance to 0.002. But I think it doesn't matter, because p_max = variance / (variance + d * d)

Depending on the units you're using, that may be a large value.

In the example of a flat caster, variance will be zero, so you get p=0/(0+d*d), so in theory, there is no fading/bleeding. When you clamp with a minimum variance you're avoiding the practical issues that occur when using very small numbers, but you're also deliberately introducing light bleeding.

With v=0.002, and d=sqrt(v)~=0.045, then we end up with p=1/2.

So if your units are in meters, then at 4.5cm behind the caster, the shadow will be at 50% intensity. It will reach 99% intensity at 4.43m behind the caster.

Reducing your minimum variance value will reduce these distances.

Also, if your units are larger than meters, then things could be much worse. Often you use normalized depth, where 1.0=the distance to the far plane; imagine the case where the far plane is 10000m away! In that case, the 50% shadow value is reached at ~450m, and the 99% value at 44km...

Ignoring the artificial case where v=0, pmax is never going to actually reach 0 / shadow intensity never reaches 100%... Whih isn't ideal; this

Means that an extremely bright light will always *somewhat* shine through a brick wall...

Usually we'd want the shadow to reach

100% intensity at some point, so I'f recommend remapping pmax just for this reason.

E.g. With p=saturate(p*2-1), then at the point where the shadow would've originally reached 50% intensity (4cm), it will now reach 100%.