So recently I have been learning how to implement Diffuse Lighting in DirectX and I have done so with the following code:
float4 PS(VS_OUTPUT input) : SV_TARGET
{
input.normal = normalize(input.normal);
float4 diffuse = ObjTexture.Sample(ObjSamplerState, input.TexCoord);
float3 finalColor;
finalColor = diffuse * light.ambient;
finalColor += saturate(dot(light.dir, input.normal) * light.diffuse * diffuse);
return float4(finalColor, diffuse.a);
}
which has produced the following results:
Before I progress any further with specular lighting I wanted to clean up my code a little so I re-implemented this with a function and few changes.
float3 DirectDiffuseBRDF(float3 diffuseAlbedo, float nDotL)
{
return (diffuseAlbedo * nDotL);
}
float4 PS(VS_OUTPUT input) : SV_TARGET
{
input.normal = normalize(input.normal);
float4 diffuseAlbedo = ObjTexture.Sample(ObjSamplerState, input.TexCoord);
float nDotL = saturate(dot(input.normal, light.dir));
float3 diffuseLighting = DirectDiffuseBRDF(diffuseAlbedo, nDotL);
return float4(diffuseLighting, diffuseAlbedo.a);
}
Which produces:
As you can see the modified code has it's diffuse lighting a little different compared to the original. What am I missing from the original code to get it back to normal?