# Is this phong model is alright?

This topic is 3017 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I read this page about specular lighting: http://wiki.gamedev.net/index.php/D3DBook:%28Lighting%29_Blinn-Phong I get the point of both technique, that the phong takes 26 instructions vs blinn that takes only 23, although phong is more correct. So I tried to be creative and try to make my own code by using the blinn idea but as phong. Look on the image that explain the blinn idea(from the page above with the theta): http://wiki.gamedev.net/images/d/de/Diagram_4.2.png So I use in this equality: cos 2a = 2(cos a)^2 - 1 Blinn use it too, but he said that (cos 2a)^n ~= (cos a)^m (n > m) because it's negligible. So please tell me if it's ok and should be work well: My "version" of the Phong model(HLSL):
float SpecularLightingFactor(float3 mnLightDir, float3 normal, float3 nEye, float exp)
{
// Compute the half vector
float3 half_vector = normalize(mnLightDir + nEye);
// Compute the angle between the half vector and normal
float HdotN = dot(half_vector, normal);
// Compute the specular colour
if (HdotN < 0)//If the face block the light
return 0;
else
return pow(2 * pow(HdotN, 2) - 1 , exp);
}

mnLightDir means minusNormalizedLightDirection. So is it good or did I made mistakes?

##### Share on other sites
Refer to Cg Tutorial.

I believe its correct as long as it gives you visually pleasing results.

##### Share on other sites
Quote:
 Original post by KopavelRefer to Cg Tutorial.I believe its correct as long as it gives you visually pleasing results.

I've checked this already, but it's look confusing...
Look on this:
http://img168.imageshack.us/img168/3862/problomspec.jpg
It's doesn't seems to be smooth.
I just want to make sure.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 13
• 9
• 12
• 9
• ### Forum Statistics

• Total Topics
631438
• Total Posts
3000073
×