Sign in to follow this  
cebugdev

[dx9 HLSL] Shadow Map with point light

Recommended Posts

cebugdev    635
Hi all,

i am reading the tutorial for implementing shadow map in HLSL directx9 at
[url="http://www.gamedev.net/page/resources/_/reference/programming/special-effects/shadows/soft-edged-shadows-r2193"]http://www.gamedev.net/page/resources/_/reference/programming/special-effects/shadows/soft-edged-shadows-r2193[/url]

and got me wondering how shadow map is done when using point light?
see, the tutorial is using a directional light where the LightViewProjection Matrix is calculated using D3DXMatrixLookAtLH( &matView, &vLightPos, &vLightAim, &g_vUp );
Point light does not have direction, but the direction is computed in HLSL instead.

so how do i do the shadowmap descrbed on the above link using point lights?
How do i compute the lightViewProjection matrix for point lights? can it be done in HLSL?

Thanks,

Share this post


Link to post
Share on other sites
Hodgman    51223
You can represent the point light as 6 spot-lights ([url="http://www.google.com.au/search?q=cubic+shadow+maps"]cubic shadow maps[/url]), or 2 spot-lights ([url="http://www.google.com.au/search?q=dual+paraboloid+shadow+maps"]dual paraboloid shadow maps[/url]), or if the light source itself is outside the view-frustum, you can take a short-cut and treat it as a single spot-light.

Share this post


Link to post
Share on other sites
zipwax    114
That wasn't the most informative reply. Why represent it as six spot lights? Why can't I find a HLSL example for a point-light shadow routine where the point light simply uses a perspective transformation instead of a orthographic transformation? Are there any examples online of a point-source shadow mapping (SIMPLE) example?

Share this post


Link to post
Share on other sites
Zero01    109
take a look at [url="http://gamedevelop.eu/en/tutorials/dual-paraboloid-shadow-mapping.htm"]http://gamedevelop.e...dow-mapping.htm[/url]

Share this post


Link to post
Share on other sites
zipwax    114
To the first guy who asked the question, I figured it out. For a point-light, you simply duplicate the exact same projection matrix as you use for the camera. In other words, move the "eye" to the point source's location (the view matrix), and calculate the projection matrix to be the same as you used for the camera. Then calculate the shadow map. Be careful that the light is not too close to your model, or the shadow map won't contain all of the model, and you'll get STRANGE shadows.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this