Jump to content
  • Advertisement
Sign in to follow this  
Quat

POM Soft Shadows

This topic is 2519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!