Skip to main content
gamedev.net
🔒 Locked

D3D shadow mapping

Started by lun123 Jan 27, 2003 at 10:53 PM 2 replies 400+ views
Original Post
lun123
lun123
Is it possible to implement basic shadow mapping - one light only - *without* using VS/PS in D3D? If yes, sample code would be very helpful.
S1CA
S1CA
1) Yes. You just render the occluder to a texture from the point of view of the light - i.e. the view and projection matrices describe the light. Then you render the things which recieve shadows with the render target texture and texture projection from the light source.

2) I''m 90% certain I saw an old sample over on the nVidia developer site (developer.nvidia.com). And there is also an example in Game Programming Gems 1 (albeit OpenGL, but its pretty simple to convert).

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
lun123
lun123
Suppose I have set the shadow map as a 2D texture at the stage 0,
and:

SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);

pD3DDevice->SetTransform( D3DTS_TEXTURE0, &matProjLight );
// matProjLight is the transformation from camera space to light view*proj space

SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTF_PROJECTED | D3DTTFF_COUNT4);
// divide the first 3 elements with the 4th

What I actually don''t know is: what will happen with those projected 3D texture coordinates on a 2D shadow map texture?
Night Elf
Night Elf
S1CA, could you explain a bit more, please? The technique you describe sounds interesting, but I can't understand it fully (some pseudo code would be great). Is it fast? I mean, is it something to do in real time (dynamic) or is it just to generate a static shadow map?

[edited by - Night Elf on January 29, 2003 12:25:31 PM]

Topic Locked

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

Sign in to reply to this topic.