All Topics  
Phong shading

 
Phong Shading

   Email Print
   Bookmark   Link






 

Phong shading



 
 
Phong shading refers to a set of techniques in 3D computer graphics
3D computer graphics

3D computer graphics are graphics that use a Cartesian coordinate system#Three-dimensional coordinate system representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images....
. Phong shading includes a model for the reflection of light from surfaces and a compatible method of estimating pixel colors by interpolating
Interpolation

In the mathematics subfield of numerical analysis, interpolation is a method of constructing new data points within the range of a discrete set of known data points....
 surface normal
Surface normal

A surface normal, or simply normal, to a Flatness is a vector which is perpendicular to that surface. A normal to a non-flat surface at a Point P on the surface is a vector perpendicular to the Tangent space to that surface at P....
s across rasterized polygons.

These methods were developed by Bui Tuong Phong
Bui Tuong Phong

Bui Tuong Phong was a Vietnamese-born computer graphics researcher and pioneer. His publications are most often referenced using his family name, B?i, which comes before his given name by Vietnamese name convention, but his inventions are remembered under his given name Phong, since it is conventional to address Vietnamese perso...
 at the University of Utah
University of Utah

The University of Utah is a public university research university in Salt Lake City, Utah. One of ten institutions that make up the Utah System of Higher Education and Utah's premier research school currently enrolls 21,526 undergraduate and 6,684 graduate student students and has 1,419 regular Faculty members....
, who published them in his 1973 Ph.D. dissertation.

The model of reflection may also be referred to as the Phong reflection model, Phong illumination or Phong lighting.






Discussion
Ask a question about 'Phong shading'
Start a new discussion about 'Phong shading'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Phong shading refers to a set of techniques in 3D computer graphics
3D computer graphics

3D computer graphics are graphics that use a Cartesian coordinate system#Three-dimensional coordinate system representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images....
. Phong shading includes a model for the reflection of light from surfaces and a compatible method of estimating pixel colors by interpolating
Interpolation

In the mathematics subfield of numerical analysis, interpolation is a method of constructing new data points within the range of a discrete set of known data points....
 surface normal
Surface normal

A surface normal, or simply normal, to a Flatness is a vector which is perpendicular to that surface. A normal to a non-flat surface at a Point P on the surface is a vector perpendicular to the Tangent space to that surface at P....
s across rasterized polygons.

These methods were developed by Bui Tuong Phong
Bui Tuong Phong

Bui Tuong Phong was a Vietnamese-born computer graphics researcher and pioneer. His publications are most often referenced using his family name, B?i, which comes before his given name by Vietnamese name convention, but his inventions are remembered under his given name Phong, since it is conventional to address Vietnamese perso...
 at the University of Utah
University of Utah

The University of Utah is a public university research university in Salt Lake City, Utah. One of ten institutions that make up the Utah System of Higher Education and Utah's premier research school currently enrolls 21,526 undergraduate and 6,684 graduate student students and has 1,419 regular Faculty members....
, who published them in his 1973 Ph.D. dissertation.

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 shader
Pixel shader

A pixel shader is a shader program, often executed on a graphics processing unit. It adds 3D shading and lighting effects to pixels in an image, for example those in video games....
s 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
Per-pixel lighting

In computer graphics, per-pixel lighting is commonly used to refer to a set of methods for computing illumination at each rendered pixel of an image....
". Typically it is called "shading" when being contrasted with other interpolation methods such as Gouraud shading
Gouraud shading

Gouraud shading,named after Henri Gouraud , is a method used in computer graphics to simulate the differing effects of light and colour across the surface of an object....
 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 reflects light as a combination of the diffuse reflection
Lambertian reflectance

If a surface exhibits Lambertian reflectance, light falling on it is scattered such that the apparent brightness of the surface to an observer is the same regardless of the observer's angle of view....
 of rough surfaces with the specular reflection
Specular reflection

Specular reflection is the perfect, mirror-like reflection of light from a surface, in which light from a single incoming direction is reflected into a single outgoing direction....
 of shiny surfaces. It is based on Bui Tuong Phong
Bui Tuong Phong

Bui Tuong Phong was a Vietnamese-born computer graphics researcher and pioneer. His publications are most often referenced using his family name, B?i, which comes before his given name by Vietnamese name convention, but his inventions are remembered under his given name Phong, since it is conventional to address Vietnamese perso...
's informal observation that shiny surfaces have small intense specular highlight
Specular highlight

A specular highlight is the bright spot of light that appears on shiny objects when illuminated . Specular highlights are important in 3D computer graphics, as they provide a strong visual cue for the shape of an object and its location with respect to light sources in the scene....
s, while dull surfaces have large highlights that fall off more gradually. The reflection model also includes an ambient term to account for the small amount of light that is scattered about the entire scene.

Phong Components Version 4
For each light source in the scene, we define the components and as the intensities (often as RGB values) of the specular and diffuse components of the light sources respectively. A single term controls the ambient lighting; it is sometimes computed as a sum of contributions from all light sources.

For each material in the scene, we define:

specular reflection constant, the ratio of reflection of the specular term of incoming light
diffuse reflection constant, the ratio of reflection of the diffuse term of incoming light (Lambertian reflectance
Lambertian reflectance

If a surface exhibits Lambertian reflectance, light falling on it is scattered such that the apparent brightness of the surface to an observer is the same regardless of the observer's angle of view....
)
ambient reflection constant, the ratio of reflection of the ambient term present in all points in the scene rendered
is a shininess constant for this material, which is larger for surfaces that are smoother and more mirror-like. When this constant is large the specular highlight is small.


We further define as the set
Set

A set is a collection of distinct objects, considered as an object in its own right. Sets are one of the most fundamental concepts in mathematics....
 of all light sources, as the direction vector from the point on the surface toward each light source, as the normal
Surface normal

A surface normal, or simply normal, to a Flatness is a vector which is perpendicular to that surface. A normal to a non-flat surface at a Point P on the surface is a vector perpendicular to the Tangent space to that surface at P....
 at this point on the surface, as the direction that a perfectly reflected ray of light would take from this point on the surface, and as the direction pointing towards the viewer (such as a virtual camera).

Then Phong reflection model provide an equation for computing the shading value of each surface point :

The diffuse term is not affected by the viewer direction . The specular term is large only when the viewer direction is aligned with the reflection direction . Their alignment is measured by the power of the cosine of the angle between them. The cosine of the angle between the normalized vectors and is equal to their dot product
Dot product

In mathematics, the dot product, also known as the scalar product, is an operation which takes two vector over the real numbers R and returns a real-valued scalar quantity....
. When is large, in the case of a nearly mirror-like reflection, the specular highlight will be small because any viewpoint not aligned with the reflection will have a cosine slightly less than one and if this value will rapidly approach zero if is raised to a high power.

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

Phong interpolation

Phong Shading Sample
Phong shading improves upon Gouraud shading
Gouraud shading

Gouraud shading,named after Henri Gouraud , is a method used in computer graphics to simulate the differing effects of light and colour across the surface of an object....
 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 highlight
Specular highlight

A specular highlight is the bright spot of light that appears on shiny objects when illuminated . Specular highlights are important in 3D computer graphics, as they provide a strong visual cue for the shape of an object and its location with respect to light sources in the scene....
s 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
Gouraud shading

Gouraud shading,named after Henri Gouraud , is a method used in computer graphics to simulate the differing effects of light and colour across the surface of an object....
, which interpolates colors across triangles, in Phong shading we linearly interpolate
Linear interpolation

Linear interpolation is a method of curve fitting using linear polynomials. It is heavily employed in mathematics , and numerous applications including computer graphics....
 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.

See also

  • Bidirectional reflectance distribution function
    Bidirectional reflectance distribution function

    The bidirectional reflectance distribution function is a 4-dimensional function that defines how light is reflected at an opaque surface. The function takes an incoming light direction, , and outgoing direction, , both defined with respect to the surface normal , and returns the ratio of reflected radiance exiting along to the irradiance...
    , another reflection model
  • Blinn–Phong shading model
    Blinn–Phong shading model

    The Blinn?Phong shading 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 , and is carried out on each vertex as it passes down the graphics pipeline; pixel values between vertices are interpolated by Gouraud shading by...
     — Phong shading modified to trade precision with computing efficiency
  • Bui Tuong Phong
    Bui Tuong Phong

    Bui Tuong Phong was a Vietnamese-born computer graphics researcher and pioneer. His publications are most often referenced using his family name, B?i, which comes before his given name by Vietnamese name convention, but his inventions are remembered under his given name Phong, since it is conventional to address Vietnamese perso...
  • Gouraud shading
    Gouraud shading

    Gouraud shading,named after Henri Gouraud , is a method used in computer graphics to simulate the differing effects of light and colour across the surface of an object....
  • Specular highlight
    Specular highlight

    A specular highlight is the bright spot of light that appears on shiny objects when illuminated . Specular highlights are important in 3D computer graphics, as they provide a strong visual cue for the shape of an object and its location with respect to light sources in the scene....
     — other specular lighting equations