Question about ATI's parallax occlusion mapping sample in DX SDK

Started by
9 comments, last by bsh_aoa 15 years, 11 months ago
Quote:Original post by Jason Z
I think there was an article in one of the ShaderX books (3 or 4 I think) that discusses POM, but I don't recall if it has the self shadowing discussion in it or not. If you still have trouble with it, try posting some questions here - I have seen Natalya from time to time around here (assuming someone else can't answer your questions [grin])!


In shaderx3, the POM just generates hard shadow, and there is a ParallaxMapping(just compute parallax offset) demo as well. In Shaderx5, the POM has soft shadow, and it tells us to implement the Penumbral effect as this way:
Wp = Ws(Dr - Db) / Db, i think this formula is very easy to understand.But in the book's appendix, it gives a demo code as this:
Quote:
float sh0 = tex2Dgrad( tNormalHeightMap, texSampleBase, dx, dy ).a;
float shA = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.88, dx, dy ).a - sh0 - 0.88 ) * 1 * g_fShadowSoftening;
float sh9 = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.77, dx, dy ).a - sh0 - 0.77 ) * 2 * g_fShadowSoftening;
float sh8 = ...
.
.
.
float sh4 = ...

// Compute the actual shadow strength:
fOcclusionShadow = 1 - max( max( max( max( max( max( shA, sh9 ), sh8 ), sh7 ), sh6 ), sh5 ), sh4 );

// The previous computation overbrightens the image, let's adjust for that:
fOcclusionShadow = fOcclusionShadow * 0.6 + 0.4;

WHY??

This topic is closed to new replies.

Advertisement