Original Post
Hi all, I am trying to do basic shadowmapping using FBO and Cg. I have assigned simple colors to my geometry to make things simple. My Scene Descroption: The scene contains a sphere placed on a plane of size 20x20 units from -10 - 10 in [X,Z]. My Problem: The shadow does not look nice. I dont know why i get the weird shadow on the sphere and the plane. See this image
My Approach: For every object, i calculate the texture matrix as below T = Bias.Lproj.Lview.Omodel; where, T -> Texture Matrix Lproj -> Light projection matrix Lview -> Light view matrix Omodel -> Object's model matrix This was given here. And then pass this matrix to the vertex shader where the projected texture coordinates are calculated as given below. One more thing when i move my light at or below the plane level, the shadows become like this
Can anyone tell me what is it that i m doing wrong? Thanks, Mobeen [Edited by - mobeen on March 4, 2009 4:09:59 AM]
struct V_In{
float4 position: POSITION;
half4 Color : COLOR0;
};
struct V_Out{
half4 Position : POSITION; //clip space position
half4 Color : COLOR0;
half4 texCoordProj : TEXCOORD0;
};
struct F_Out{
half4 Color:COLOR; //per fragment color
};
V_Out vertex_main(V_In I, uniform float4x4 textureMatrix){
V_Out O;
O.Position = mul(glstate.matrix.mvp, I.position);
O.texCoordProj = mul(textureMatrix , I.position);
O.Color = I.Color;
return O;
}
F_Out fragment_main( V_Out In, uniform sampler2D shadowMap){
F_Out f;
float4 shadowColor = tex2Dproj(shadowMap , In.texCoordProj);
f.Color = In.Color*shadowColor;
return f;
}