Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I’m trying to store the depth information of model in XNA from the lights point of view. The model renders fine using a normal shader.

This is the shader code

float4x4 xShadowMapLight;


///DEPTH MAP

float4 RenderShadowMapPS( VS_SHADOW_OUTPUT In ) : COLOR
{ 

  return float4(1,0,0,0); //In.Depth.x,In.Depth.x,In.Depth.x,0);
}

VS_SHADOW_OUTPUT RenderShadowMapVS(float4 vPos: POSITION)
{ 
  VS_SHADOW_OUTPUT Out;

  Out.Position = mul(vPos, xShadowMapLight);

  Out.Depth.x = 1-(Out.Position.z/Out.Position.w);    
  return Out;
}


technique ToonShaderDepthMap
{

 pass P0
 {

   VertexShader = compile vs_2_0 RenderShadowMapVS(); 
   PixelShader = compile ps_2_0 RenderShadowMapPS();
 }

}

And this is the way I generate the light matrix that is passed to the shader.

 Matrix view = Matrix.CreateLookAt(modelTransform.Translation, new Vector3(0, 500, 75), Vector3.Up);
 Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 1.0f, (float)globals.NEAR_PLANE, (float)globals.FAR_PLANE);
 Matrix ShadowMapLight = modelTransform * view * projection;

But apparently I’m not always getting to the pixel shader and it stops in the vertex for some reason. (I have modified the pixel shader to output always a red pixel, so I know when it goes through).

xShadowMapLight is the Matrix containing all the transformations from the lights point of view. Apparently the problem is in mul(vPos, xShadowMapLight); cause if I change the matrix for an Identity one the shader gets to the pixel one.

Any idea why this might happen?

share|improve this question
2  
Your geometry is being sent offscreen by the matrix. It's not that the shader "stops in the vertex shader", it's that the pixel shader only runs if there are some pixels to shade. – Nathan Reed Jan 11 at 17:53

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.