Hi Guys,
Today I have added a specular lighting component to my shader and all is working well except for one anomaly. When I increase the specular power variable the specular intensity decrease. The lower the number, the higher specularity.
I can't quite put my finger on why this is.
This is the relevant code from my pixel shader;
float4 color = input.lightColor;
float diffuseIntensity = saturate(dot(input.normal, input.lightPos));
color += (color * diffuseIntensity);
color = saturate(color);
// Specular component
float3 reflection = normalize(2 * diffuseIntensity * input.normal - input.lightPos);
float specularPower = 3.0f; // **** The variable in question ****
float4 specularIntensity = float4(0.0f, 0.0f, 0.0f, 0.0f);
specularIntensity = pow(saturate(dot(reflection, input.lightPos)), specularPower);
color = saturate(color + specularIntensity);
return color;
Any ideas what I might be overlooking here?
Thanks in advance ?