Phong shading

Phong shading

Phong shading refers to a set of techniques in 3D computer graphics. Phong shading combines a model for the reflection of light from surfaces with a compatible method of estimating pixel colors using interpolation of surface normals across rasterized polygons.

These methods were developed by Bui Tuong Phong, who published them in his 1973 Ph.D. dissertation at the University of Utah.

The model of reflection may also be referred to as the Phong reflection model, Phong illumination or Phong lighting. It may be called Phong shading in the context of pixel shaders or other places where a lighting calculation can be referred to as "shading".

The interpolation method may also be called Phong interpolation, and is also usually what is referred to by "per-pixel lighting". Typically it is called "shading" when being contrasted with other interpolation methods such as Gouraud shading or flat shading. The Phong reflection model may be used in conjunction with any of these interpolation methods.

Phong reflection model

Phong reflection is an empirical model of local illumination. It describes the way a surface is lit as a combination of the diffuse lighting of rough surfaces with the specular reflection of shiny surfaces. It is based on Bui Tuong Phong's informal observation that for very shiny surfaces the specular highlight was small and the intensity fell off rapidly, while for duller surfaces it was larger and fell off more slowly. Additionally it includes an "ambient" term to simulate the way that a low level of light is typically present everywhere in a scene.

We first define, for each light source in the scene to be rendered, the components i_s and i_d, where these are the intensities (often as RGB values) of the specular and diffuse components of the light sources respectively. A single i_a term controls the ambient lighting; it is sometimes computed as a sum of contributions from the light sources.

If we then define, for each "material" (which is typically assigned 1-to-1 for the object surfaces in the scene):

:k_s: specular reflection constant, the ratio of reflection of the specular term of incoming light:k_d: diffuse reflection constant, the ratio of reflection of the diffuse term of incoming light (Lambertian reflectance):k_a: ambient reflection constant, the ratio of reflection of the ambient term present in all points in the scene rendered:alpha: is a "shininess" constant for this material, which decides how "evenly" light is reflected from a shiny spot, and is very large for most surfaces, on the order of 50, getting larger the more mirror-like they are.

We further define mathrm{lights} as the set of all light sources, L is the direction vector from the point on the surface toward each light source, N is the normal at this point of the surface, R is the direction that a perfectly reflected ray of light (represented as a vector) would take from this point of the surface, and V is the direction towards the viewer (such as a virtual camera).

Then the shade value for each surface point I_p is calculated using this equation, which is the "Phong reflection model":

:I_p = k_a i_a + sum_mathrm{lights} (k_d (L cdot N) i_d + k_s (R cdot V)^{alpha}i_s).

The diffuse term does not use the direction towards the viewer (V), as the diffuse term is equal in all directions from the point, including the direction of the viewer. The specular term, however, is large only when the reflection vector R is nearly aligned with viewpoint vector V, as measured by the alpha power of the cosine of the angle between them, which is the dot product of the normalized direction vectors R and V. When alpha is large, representing an almost mirror-like reflection, the specular reflection will be very small because the high power of the cosine will go rapidly to zero with any viewpoint not aligned with the reflection.

When we have color representations as RGB values, this equation will typically be calculated individually for R, G and B intensities.

Phong interpolation

Phong shading improves upon Gouraud shading and provides a better approximation of the shading of a smooth surface. Phong shading assumes a smoothly varying surface normal vector. The Phong interpolation method works better than Gouraud shading when applied to a reflection model that has small specular highlights such as the Phong reflection model.

The most serious problem with Gouraud shading occurs when specular highlights are found in the middle of a large triangle. Since these specular highlights are absent from the triangle's vertices and Gouraud shading interpolates based on the vertex colors, the specular highlight will be missing from the triangle's interior. This problem is fixed by Phong shading.

Unlike Gouraud shading, which interpolates colors across triangles, in Phong shading we linearly interpolate a normal vector across the surface of the triangle from the three given normals. The surface normal is interpolated and normalized at each pixel and then used in the Phong reflection model to obtain the final pixel color. Phong shading is more computationally expensive than Gouraud shading since the reflection model must be computed at each pixel instead of at each vertex.

In some modern hardware, variants of this algorithm are implemented using pixel or fragment shaders. This can be accomplished by coding normal vectors as secondary colors for each polygon, have the rasterizer use Gouraud shading to interpolate them and interpret them appropriately in the pixel or fragment shader to calculate the light for each pixel based on this normal information.

ee also

*Blinn–Phong shading model — Phong shading modified to trade precision with computing efficiency
*Bui Tuong Phong
*Specular highlight — Other specular lighting equations
*Gouraud shading
*Bidirectional reflectance distribution function : Another reflection model


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Phong Shading —   [nach dem Informatiker Bui Tuong Phong], Shading …   Universal-Lexikon

  • Phong-Shading — Ein Polyeder mit Phong Shading (rechts) Phong Shading ist ein Verfahren aus der 3D Computergrafik, um Polygon Flächen mit Farbschattierungen zu versehen. Benannt wurde es nach seinem Entwickler Bui Tuong Phong, der es erstmals 1975 vorstellte.… …   Deutsch Wikipedia

  • Phong Shading — Ein Polyeder mit Phong Shading (rechts) Phong Shading ist ein Verfahren aus der 3D Computergrafik, um Polygon Flächen mit Farbschattierungen zu versehen. Benannt wurde es nach seinem Entwickler Bùi Tường Phong, der es erstmals 1975 vorstellte.… …   Deutsch Wikipedia

  • Phong shading — Ombrage Phong Les types d ombrage numériques Ombrage plat Ombrage de Gouraud Ombrage de Phong Une sphère interpolée et rendue selon Phong Aujourd hui, le terme ombrage de Phong est utilisé à la fois pour le …   Wikipédia en Français

  • Phong-Shading — Methode zur Darstellung von bzw. Beleuchtungsmodellierung bei 3D Objekten …   Acronyms

  • Phong-Shading — Methode zur Darstellung von bzw. Beleuchtungsmodellierung bei 3D Objekten …   Acronyms von A bis Z

  • Blinn–Phong shading model — The Blinn–Phong shading model (also called Blinn–Phong reflection model or modified Phong reflection model) is a modification to the Phong reflection model developed by Jim Blinn.[1] Blinn–Phong is the default shading model used in OpenGL and… …   Wikipedia

  • Phong — may refer to: Computer graphics *Phong shading *Blinn–Phong shading model *Bui Tuong Phong creator of the Phong shading interpolation method and reflection model. Other *Phong Kniang language *Nam Phong *A character in the animated show ReBoot *A …   Wikipedia

  • Shading —   [dt. Schattierung], in der Grafikverarbeitung eine Reihe von Verfahren, Licht und Schatteneffekte bei der Darstellung von dreidimensionalen Grafiken zu berechnen. Das Shading ergänzt somit das Rendering. Shading Verfahren nützen aus, dass sich… …   Universal-Lexikon

  • Shading — oder Schattierung[1] ist ein Begriff aus der 3D Computergrafik, der im weiten Sinn die Simulation der Oberflächeneigenschaften von Objekten bezeichnet.[2] Im Speziellen bezeichnet Shading die Anwendung eines Interpolationsverfahrens, mit dem der… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”