Hi guys,
right now in HLSL I'm trying to implement specular lighting, but ran into an issue, first here's a code snippet:
float3 reflection;
float4 specular;
// Initialize the specular color.
specular = float4(0.0f, 0.0f, 0.0f, 0.0f);
// Calculate the amount of light on this pixel.
float lightIntensity = saturate(dot(input.normal, -lightvec));
if(lightIntensity > 0.0f)
{
//color += (ambientcol * lightIntensity);
// Saturate the ambient and diffuse color.
color = saturate(color);
reflection = normalize(2 * lightIntensity * input.normal - (-lightvec));
specular = pow(saturate(dot(reflection, input.viewDirection)), specularPower);
}
// Add the specular component last to the output color.
color = saturate(color + specular);
Now all the alien variables are set correctly (debugged), but somehow the variable specular is NEVER correctly calculated.
Now this seams a bit vein, but this is all I got for now... But do you know why it happens?
Thank You