Jump to content

  • Log In with Google      Sign In   
  • Create Account

Shader not getting to the pixel shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 glmisscelan   Members   -  Reputation: 176

Like
0Likes
Like

Posted 11 January 2013 - 10:09 AM

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!



Sponsor:

#2 Tasaq   Members   -  Reputation: 1235

Like
1Likes
Like

Posted 11 January 2013 - 11:52 AM

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 :)

Edited by Tasaq, 11 January 2013 - 12:03 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS