Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by bsh_aoa May 8, 2008 at 9:19 AM 9 replies 2.2k views
Original Post
bsh_aoa
bsh_aoa
When I study parallax occlusion mapping from ATI's paper "Practical Parallax Occlusion Mapping For Highly Detailed Surface Rendering", i find the paper didn't provide a source code demo(you may tell me: you can find ATI's demo "ToyShop"). Unluckily, first i have a NVidia 8600GT Card(not a AMD-ATI Card), i cannot run the demo; second, that demo is just a demo(doesn't have any source code). However, there is a "Practical Parallax Occlusion Mapping sample" in D3D9 SDK, but i have some question about that sample, when it computes the softshadow effect: // vLightTS is the normalize light vector in tangent space float2 vLightRayTS = vLightTS.xy * g_fHeightMapScale; 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 = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.66, dx, dy ).a - sh0 - 0.66 ) * 4 * g_fShadowSoftening; float sh7 = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.55, dx, dy ).a - sh0 - 0.55 ) * 6 * g_fShadowSoftening; float sh6 = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.44, dx, dy ).a - sh0 - 0.44 ) * 8 * g_fShadowSoftening; float sh5 = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.33, dx, dy ).a - sh0 - 0.33 ) * 10 * g_fShadowSoftening; float sh4 = (tex2Dgrad( tNormalHeightMap, texSampleBase + vLightRayTS * 0.22, dx, dy ).a - sh0 - 0.22 ) * 12 * g_fShadowSoftening; // 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; who can help me?
Sneftel
Sneftel
Quote:
but i have some question about that sample

Perhaps you should ask it.
Jason Z
Jason Z
You can check out my article on the topic for some further clarification. I developed the programs on NV hardware, so you should have any trouble running it. You can find it in my signature below:
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
bsh_aoa
bsh_aoa
Quote:
Original post by Jason Z
You can check out my article on the topic for some further clarification. I developed the programs on NV hardware, so you should have any trouble running it. You can find it in my signature below:


in your "Parallax Occlusion Mapping Article", you didn't compute shadow(Occlusion), you just computed the parallax amount.
bsh_aoa
bsh_aoa
Quote:
Original post by Sneftel
Perhaps you should ask it.


:)
Sneftel
Sneftel
...no, seriously.
LeonPost
LeonPost
I have read the ATI article and the article about parallax occlusion mapping here from gamedev. However, I still have on major probably. I just do not understand how to calculate the self-shadowing. Can anyone explain this to me?
Jason Z
Jason Z
Self shadowing is calculated by first finding the parallax corrected visible point, then performing the same process back towards the light source. If the POM surface is intersected before you get back to the light source (or above the max height of the surface) then the point is in shadow. I think there is a presentation talking about this from Natalya at GDC (it was what I based the research for my article on...) that was pretty good at explaining the process.

Hope this helps!
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
LeonPost
LeonPost
Jason Z, that does help out a lot. Thank you. Just as a reference would you happen to know any other articles that are good besides yours and natalyas? I like to read as much as I can when I am trying to learn how to do these techniques.
Jason Z
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])!
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
bsh_aoa
bsh_aoa
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??

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.