POM Soft Shadows

Started by
-1 comments, last by Quat 12 years, 2 months ago
I was able to add hard shadows to POM, but got the aliasing issue mentioned in the ShaderX5 book on POM. I tried to implement the soft shadows but do not really understand the formula (from the ShaderX5 book):


float s0 = normalMap.SampleGrad(samLinear, baseTex, dx, dy).a;

float s2 = (normalMap.SampleGrad(samLinear, baseTex + 0.88f*lightRayTS, dx, dy).a - s0 - 0.88)*1*0.25f;
float s3 = (normalMap.SampleGrad(samLinear, baseTex + 0.77f*lightRayTS, dx, dy).a - s0 - 0.77)*2*0.25f;
float s4 = (normalMap.SampleGrad(samLinear, baseTex + 0.66f*lightRayTS, dx, dy).a - s0 - 0.66)*4*0.25f;
float s5 = (normalMap.SampleGrad(samLinear, baseTex + 0.55f*lightRayTS, dx, dy).a - s0 - 0.55)*6*0.25f;
float s6 = (normalMap.SampleGrad(samLinear, baseTex + 0.44f*lightRayTS, dx, dy).a - s0 - 0.44)*8*0.25f;
float s7 = (normalMap.SampleGrad(samLinear, baseTex + 0.33f*lightRayTS, dx, dy).a - s0 - 0.33)*10*0.25f;
float s8 = (normalMap.SampleGrad(samLinear, baseTex + 0.22f*lightRayTS, dx, dy).a - s0 - 0.22)*12*0.25f;

float shadow = 1 - max(max(max(max(max(max(s2, s3), s4), s5), s6), s7), s8);


I know you sample points along the light ray, and want to find the sample that gives the largest shadow (that's where the max comes in).

But what I don't get is the subtraction. For example:

Let h2 = normalMap.SampleGrad(samLinear, baseTex + 0.88f*lightRayTS, dx, dy).a;

float s2 = (h2 - s0 - 0.88);

The height difference between h2 and s0 has to be huge (almost impossible huge in practice) in order for s2 to be positive after subtracting 0.88. Also where does the subtraction by 0.88 come into play anyway?
-----Quat

This topic is closed to new replies.

Advertisement