Blinn-Phong Reflectance Model
Formula
In the Blinn-Phong Reflectance Model, reflectance is defined as:
For lights where:
is the total reflectance.
is the ambient reflectance.
is the diffuse reflectance for a given light.
is the specular reflectance for a given light.
To compute these components, we need to define a few vectors.
Vectors
All vectors used should be normalized.
is the surface normal.
is the light vector, pointing from the surface towards the light.
is the view vector, pointing from the surface towards the viewer (camera).
is the half vector, halfway between the and vectors. It can be computed by
Note that we are not concerned with , the Reflection vector, for the Blinn-Phong model.
Components
All dot products used should be clamped between and .
Ambient
Diffuse
Specular
Implementation
, , and are the material properties.
They should be vec3
(colors).
is also a material property, sometimes called shininess
or lower-case n
.
It is a scalar.
Don’t forget to:
- Normalize all vectors
- Vectors passed from the vertex shader to the fragment shader should be normalized both before and after passing. The interpolation of two or more normalized vectors is not guaranteed to be normalized.
- Clamp all dot products between and
Note that the equation does not mean you actually need to divide by the length of . This is merely the notation for a normalized vector. You should simply write in GLSL:
vec3 H = normalize(L + V);