Shader not getting to the pixel shader

Started by
0 comments, last by Tasaq 11 years, 3 months ago

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 anIdentity one the shader gets to the pixel one.

Any idea why this might happen?

Thanks in advance!

Advertisement
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).
Are You sure about that? :)
It will only make red the object's you want to render (say, teapot for instance), everything else will be 'clear' color, since there's no object in that place, there's no need to 'pixel shader' it.

EDIT:
I also noticed You did this:

Matrix view = Matrix.CreateLookAt(modelTransform.Translation, new Vector3(0, 500, 75), Vector3.Up);

What happens now is that object is being culled (unless you set cull mode to none).
1st parameter is camera position, 2nd is LookAt, if you swap them(I believe You wanted to set the camera to look at your object) it might work :)

This topic is closed to new replies.

Advertisement