This is the shader (single directional light):
VS_OUT VShader(VS_IN input)
{
VS_OUT output = (VS_OUT)0;
output.position = mul(WorldViewProj, input.position);
output.normal = mul((float3x3)NormalTransf, input.normal);
return output;
}
float4 PShader(VS_OUT input) : SV_TARGET
{
float3 normal = normalize(input.normal);
float3 diffuse = 0.6 * saturate(dot(normal, -SunDirection));
return float4(0.25 + diffuse, 1);
}
NormalTransf is the transpose of the inverse world * view matrix:
The problem is that the light follows the camera... I tried multiplying by different matrices and the closest i got is when i multiplied by NormalTransf, except the y and z values of SunDirection get switched.