Phong reflection model should not be confused with Phong shading.
The Phong reflection model (also called Phong illumination or Phong lighting) is an empirical model of the local illumination of points on a surface designed by the computer graphics researcher Bui Tuong Phong. In 3D computer graphics, it is sometimes referred to as "Phong shading", particularly if the model is used with the interpolation method of the same name and in the context of pixel shaders or other places where a lighting calculation can be referred to as “shading”.
The Phong reflection model was developed by Bui Tuong Phong at the University of Utah, who published it in his 1975 Ph.D. dissertation.[1] [2] It was published in conjunction with a method for interpolating the calculation for each individual pixel that is rasterized from a polygonal surface model; the interpolation technique is known as Phong shading, even when it is used with a reflection model other than Phong's. Phong's methods were considered radical at the time of their introduction, but have since become the de facto baseline shading method for many rendering applications. Phong's methods have proven popular due to their generally efficient use of computation time per rendered pixel.
Phong reflection is an empirical model of local illumination. It describes the way a surface reflects light as a combination of the diffuse reflection of rough surfaces with the specular reflection of shiny surfaces. It is based on Phong's informal observation that shiny surfaces have small intense specular highlights, while dull surfaces have large highlights that fall off more gradually. The model also includes an ambient term to account for the small amount of light that is scattered about the entire scene.
For each light source in the scene, components
is
id
ia
For each material in the scene, the following parameters are defined:
ks
kd
ka
\alpha
Furthermore, there is
lights
\hat{L}m
m
\hat{N}
\hat{R}m
\hat{V}
Then the Phong reflection model provides an equation for computing the illumination of each surface point
Ip
Ip=kaia+\summ \in lights(kd(\hat{L}m ⋅ \hat{N})im,d+ks(\hat{R}m ⋅ \hat{V})\alphaim,s).
where the direction vector
\hat{R}m
\hat{L}m
\hat{N}
\hat{R}m=2(\hat{L}m ⋅ \hat{N})\hat{N}-\hat{L}m
The hats indicate that the vectors are normalized. The diffuse term is not affected by the viewer direction (
\hat{V}
\hat{V}
\hat{R}m
\alpha
\hat{R}m
\hat{V}
\alpha
Although the above formulation is the common way of presenting the Phong reflection model, each term should only be included if the term's dot product is positive. (Additionally, the specular term should only be included if the dot product of the diffuse term is positive.)
When the color is represented as RGB values, as often is the case in computer graphics, this equation is typically modeled separately for R, G and B intensities, allowing different reflection constants
ka,
kd
ks
When implementing the Phong reflection model, there are a number of methods for approximating the model, rather than implementing the exact formulas, which can speed up the calculation; for example, the Blinn–Phong reflection model is a modification of the Phong reflection model, which is more efficient if the viewer and the light source are treated to be at infinity.
Another approximation[3] that addresses the calculation of the exponentiation in the specular term is the following: Considering that the specular term should be taken into account only if its dot product is positive, it can be approximated as
max(0,\hat{R}m ⋅ \hat{V})\alpha=max(0,1-λ)\beta=\left(max(0,1-λ)\beta\right)\gamma ≈ max(0,1-\betaλ)\gamma
where
λ=1-\hat{R}m ⋅ \hat{V}
\beta=\alpha/\gamma
\gamma
\gamma=2n
n
(1-\betaλ)\gamma
(1-\betaλ) n
(1-\betaλ)\gamma=(1-
2n | |
\betaλ) |
=(1-\betaλ)\overbrace{\scriptstylen}=(...((1-\betaλ)\overbrace{2)2...)2}n.
This approximation of the specular term holds for a sufficiently large integer
\gamma
Furthermore, the value
λ
λ=(\hat{R}m-\hat{V}) ⋅ (\hat{R}m-\hat{V})/2
λ=(\hat{R}m x \hat{V}) ⋅ (\hat{R}m x \hat{V})/2.
\hat{R}m
\hat{V}
λ=1-\hat{R}m ⋅ \hat{V}
\hat{R}m
\hat{V}
This method substitutes a few multiplications for a variable exponentiation, and removes the need for an accurate reciprocal-square-root-based vector normalization.
The Phong reflection model in combination with Phong shading is an approximation of shading of objects in real life. This means that the Phong equation can relate the shading seen in a photograph with the surface normals of the visible object. Inverse refers to the wish to estimate the surface normals given a rendered image, natural or computer-made.
The Phong reflection model contains many parameters, such as the surface diffuse reflection parameter (albedo) which may vary within the object. Thus the normals of an object in a photograph can only be determined, by introducing additional information such as the number of lights, light directions and reflection parameters.
For example, we have a cylindrical object, for instance a finger, and wish to compute the normal
N=[Nx,Nz]
Ip(x)=Ca+Cd(L(x) ⋅ N(x))
With
Ca
Cd
(Ip(x)-Ca)/Cd=L(x) ⋅ N(x)
Which can be rewritten for a line through the cylindrical object as:
(Ip-Ca)/Cd=LxNx+LzNz
For instance if the light direction is 45 degrees above the object
L=[0.71,0.71]
(Ip-Ca)/Cd=0.71Nx+0.71Nz
1=
2 | |
\sqrt{(N | |
x |
+
2)} | |
N | |
z |
Because of the powers of two in the equation there are two possible solutions for the normal direction. Thus some prior information of the geometry is needed to define the correct normal direction. The normals are directly related to angles of inclination of the line on the object surface. Thus the normals allow the calculation of the relative surface heights of the line on the object using a line integral, if we assume a continuous surface.
If the object is not cylindrical, we have three unknown normal values
N=[Nx,Ny,Nz]
The Phong reflection model is often used together with Phong shading to shade surfaces in 3D computer graphics software. Apart from this, it may also be used for other purposes. For example, it has been used to model the reflection of thermal radiation from the Pioneer probes in an attempt to explain the Pioneer anomaly.[5]