   Trouble with my shadow map
  Hello,I am trying to use shadow maps, but am having a few issues.My shadow map was always empty. At first I thought it was the projection and view of the light, but now I find out it is simply the pixel shader, which is supposed to be converting the depth info into colour. When I use my pixel shader, the shadow map is blank, it works a bit if I set it to NULL. Heres the result with the pixelshader set to NULL:My problem stems from the way I am trying to store the depth info. Heres my shader code://--------------------------------------------// Global variables//--------------------------------------------float4x4g_matLightWVP: WORLVIEWPROJECTION;float4x4g_matLightViewProj: VIEWPROJECTION;float4x4g_matWorld: WORLD;//--------------------------------------------// Vertex shaders//--------------------------------------------struct VSOUTPUT_SHADOW{float4 vPosition: POSITION;float  fDepth: TEXCOORD0;};// Shadow generation vertex shaderVSOUTPUT_SHADOW VS_Shadow( float4 inPosition : POSITION ){// Output structVSOUTPUT_SHADOW OUT = (VSOUTPUT_SHADOW)0;g_matLightWVP = mul( g_matWorld, g_matLightViewProj );// Output the transformed positionOUT.vPosition  = mul( inPosition, g_matLightWVP );// Output the scene depthOUT.fDepth = OUT.vPosition.z;return OUT;}//--------------------------------------------// Pixel shaders//--------------------------------------------float4  PS_Shadow( VSOUTPUT_SHADOW IN ) : COLOR0{return float4( IN.fDepth,IN.fDepth,IN.fDepth,1.0f );}Why does this pixel shader produce a blank shadow map render target?Thanks for any help you can giveSimon[Edited by - sipickles on June 12, 2006 3:50:24 PM]
  Okay, so I thought that maybe my projection matrix was bad, since I was lazy and just had the near plane at 100.0f, and the far plane at 5000000.0f.This might reduce the resolution of the shadow map to such a point that all the pixels within my scene, which are fairly close, were within  the same range.I reduced the far clipping range to 5000.0f, but its exactly the same result, a blank shadow map.:([Edited by - sipickles on June 12, 2006 3:57:20 PM];  Yeah, I actually just encountered this issue yesterday, when working on something completely different.The output of the transformation, namely:OUT.vPosition  = mul( inPosition, g_matLightWVP );returns a z value in the range of [0..ZFar], not [0..1].I'll let someone explain this better than I ever could.. Here's a page on Robert Dunlop's great website.Hope this helps.   