D3D shadow mapping

Started by
2 comments, last by lun123 21 years, 2 months ago
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.
Advertisement
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

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?
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]

This topic is closed to new replies.

Advertisement