Phong shading

The term Phong shading is used indiscriminately to describe both an illumination model and an interpolation method in 3D computer graphics.

Phong illumination or reflection model

Phong reflection is a local illumination model and can produce a certain degree of realism in three-dimensional objects by combining three elements - diffuse, specular and ambient for each considered point on a surface. It has several assumptions - all lights are points, only surface geometry is considered, only local modelling of diffuse and specular, specular colour is the same as light colour, ambient is a global constant.

Diffuse,

<math>I_d = I_i k_d \sin \theta<math> <math>0 \le \theta \le 2\pi<math>

where <math>I_i<math> is the brightness of the (point) light source. θ is the angle between the surface and the light source. <math>k_d<math> is the reflection coefficient.

For multiple light sources,

<math>I_d = k_d \sum_{n} I_{i,n} (L_n \cdot N)<math>

where L and N are unit vectors, <math>L_n<math> being the light direction vector for the nth light source to the surface.

Specular (highlight producing),

<math>I_s = I_i k_s \cos^n \Omega = I_i k_s (R \cdot V)^n<math>

where n indicates the surface reflectivity, infinity would indicate a perfect mirror. Ω is the angle between the 'mirror' and the viewer. R is the specular direction and V is the actual view vector. This fails to be produce radiosity, a flaw in Phong.

Combining diffuse and specular is sufficient for local accuracy. To mimic global conditions an ambient element is added to give general illumination, usually as a constant value

<math>I_g = I_a k_a<math>

Combining all three gives

<math>I = I_a k_a + I_i (k_d (L \cdot N) + k_s (R \cdot V)^n)<math>

assuming no reduction of light intensity with distance, which can be added if desired.

This is an empirical model, which is not based on physics, but physical observation. Phong observed 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.

This equation can be represented in a graphic way: Missing image
Phong-components.jpg
Visual explanation of the Phong equation

Phong interpolation

Missing image
Phong-shading-sample.jpg
Phong shading interpolation example

As a rendering method, Phong shading can be regarded as an improved version of Gouraud shading that provides a better approximation to reality by approximating the Phong shading model.

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. This problem is fixed by Phong shading.

Some argue that using smaller triangles fixes the problem of Gouraud shading, with respect to specular highlights. Others counter that Phong shading is better able to handle large triangles, and that in any case, very sharp specular highlights would require tiny triangles. The truth is somewhere in between, and it pays to remember that Phong interpolation does very little to soften the abrupt change in color gradient near the edges of triangles. In fact, the improved handling of specular highlights can worsen this problem.

We are given three vertices in two dimensions, v1, v2 and v3, as well as normals for each vertex n1, n2 and n3; we assume these are of unit length. As in Gouraud shading, we linearly interpolate a normal N across the surface of the triangle, from the three given normals. This is done, as in Gouraud shading, 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 shading." It usually means that the lighting calculations can be done per-pixel, and that the lighting variables are interpolated across the triangle.

See also

fr:Ombrage Phong pl:Cieniowanie Phonga

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools