Why is my shadowmap all white?
Posted
by
Berend
on Game Development
See other posts from Game Development
or by Berend
Published on 2012-09-26T05:38:13Z
Indexed on
2012/09/26
9:53 UTC
Read the original article
Hit count: 263
I was trying out a shadowmap. But all my shadow is white. I think there is some problem with my homogeneous component. Can anybody help me? The rest of my code is written in xna
Here is the hlsl code I used
float4x4 xWorld;
float4x4 xView;
float4x4 xProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 ScreenPos : TEXCOORD1;
float Depth : TEXCOORD2;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
//------- Technique: ShadowMap --------
VertexToPixel MyVertexShader(float4 inPos: POSITION0, float3 inNormal: NORMAL0)
{
VertexToPixel Output = (VertexToPixel)0;
float4x4 preViewProjection = mul(xView, xProjection);
float4x4 preWorldViewProjection = mul(xWorld, preViewProjection);
Output.Position =mul(inPos, mul(xWorld, preViewProjection));
Output.Depth = Output.Position.z / Output.Position.w;
Output.ScreenPos = Output.Position;
return Output;
}
float4 MyPixelShader(VertexToPixel PSIn) : COLOR0
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.ScreenPos.z/PSIn.ScreenPos.w;
return Output.Color;
}
technique ShadowMap
{
pass Pass0
{
VertexShader = compile vs_2_0 MyVertexShader();
PixelShader = compile ps_2_0 MyPixelShader();
}
}
© Game Development or respective owner