graphics-snippets

StackOverflow


Blinn-Phong model

The Blinn-Phong reflection model (also called the modified Phong reflection model) is a modification to the Phong reflection model developed by Jim Blinn. Blinn-Phong is the default shading model used in OpenGL and Direct3D’s fixed-function pipeline (before Direct3D 10 and OpenGL 3.1), and is carried out on each vertex as it passes down the graphics pipeline; pixel values between vertices are interpolated by Gouraud shading by default, rather than the more computationally-expensive Phong shading.

Half-Way vector

f_BlinnPhong = max(0, pow(cos(theta_H), sh)) = max(0, pow(dot(N, H), sh))


GLSL coding:

float Distribution_BlinnPhong( vec3 esVEye, vec3 esVLight, vec3 esPtNV, float shininess )
{
    vec3 halfVector = normalize( esVEye + esVLight );
    float NdotH = max( dot( esPtNV, halfVector ), 0.0 );
    return ( shininess + 2.0 ) * pow( NdotH, shininess ) / ( 2.0 * 3.14159265 );
}


See also:


<hr/>

profile for Rabbid76 on Stack Exchange, a network of free, community-driven Q&A sites