Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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; 
        return pow(2 * pow(HdotN, 2) - 1 , exp); 
mnLightDir means minusNormalizedLightDirection. So is it good or did I made mistakes?

Share this post

Link to post
Share on other sites
Original post by Kopavel
Refer 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:
It's doesn't seems to be smooth.
I just want to make sure.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!