Sign in to follow this  

Is this phong model is alright?

Recommended Posts

I read this page about specular lighting: 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): 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this