I was having no end of trouble with this function, emitted by the shader designer in VS2012. If you look at the code below, you can see the difference between the VS Version and MY Version.
In the VS version, they do not take into account the texture, so the "shady" sides of any object lit only by ambient is just grey. In MY version, you can see I added the pixelcolor (which is from the texture) and then it works great. Since they take the pixelcolor into account for the diffuse lighting, I can't figure out why they wouldn't for the ambient.
Since I'm very new to 3D I don't want to assume I'm so clever and the VS team never tested this. And since its so fundamental, I'm wondering if I'm just missing something. Thoughts?
float3 LambertLighting(
float3 lightNormal,
float3 surfaceNormal,
float3 materialAmbient,
float3 lightAmbient,
float3 lightColor,
float3 pixelColor
)
{
// compute amount of contribution per light
float diffuseAmount = saturate(dot(lightNormal, surfaceNormal));
float3 diffuse = diffuseAmount * lightColor * pixelColor;
// combine ambient with diffuse
// VS Version:
return saturate((materialAmbient * lightAmbient) + diffuse);
// MY Version:
return saturate((materialAmbient * lightAmbient * pixelColor) + diffuse);
}