Phong shading
From Wikipedia, the free encyclopedia
- An application of the Phong reflection model.
Phong shading is an interpolation method in 3D computer graphics, using interpolation of surface normals in rasterizing polygons, to get better resolution of specular reflections such as those generated by the Phong reflection model.
Since the inventor's publications combined the interpolation technique with his reflection model, the term Phong shading is also commonly used to refer to the reflection model or to the combination of the reflection model and the interpolation method.
These methods were developed by Bui Tuong Phong, who published them in his 1973 Ph.D. dissertation at the University of Utah.
[edit] Phong illumination or reflection model
Phong reflection is a local illumination model that can produce a certain degree of realism in three-dimensional objects by combining three elements: diffuse, specular, and ambient lighting for each considered point on a surface.
The reflection model has nothing specific to polygons or pixels, unlike the interpolation method.
[edit] Phong interpolation
As a rendering method, Phong shading can be regarded as an improvement on Gouraud shading that provides a better approximation to a point-by-point application of an underlying reflection model by assuming a smoothly varying surface normal vector. The Phong interpolation method works better than Gouraud shading when applied to the Phong reflection model or to any reflection model that has small specular highlights.
The main problem with Gouraud shading is that when a specular highlight occurs near the center of a large triangle, it will usually be missed entirely, due to the interpolation of colors between vertices. This problem is fixed by Phong shading.
We are given three vertices in two dimensions, v1, v2 and v3, as well as surface normals for each vertex n1, n2 and n3; we assume these are of unit length. Unlike Gouraud shading, which interpolates colors across triangles, in Phong shading we linearly interpolate a normal vector N across the surface of the triangle, from the three given normals. This is done for each pixel in the triangle, and at each pixel we normalize N and use it in the Phong illumination model to obtain the final pixel color.
In some modern hardware, variants of this algorithm are called "pixel/fragment shading." It usually means that the lighting calculations can be done per-pixel, and that the lighting variables (including surface normals or some approximately equivalent vector) are interpolated across the polygon.
[edit] See also
- Blinn–Phong shading model — Phong shading modified to trade precision with computing efficiency
- Bui Tuong Phong
- Phong reflection model
- Specular highlight — Other specular lighting equations