Template:Mergefrom

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 devised by Bui Tuong Phong and 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. It has several assumptions - all lights are points, only surface geometry is considered, only local modelling of diffuse and specular exists, specular colour is the same as light colour, and ambient is a global constant.

Diffuse,

where

is the brightness of the (point) light source. θ is the angle between the surface normal and the direction of the light source.

is the reflection coefficient.

For multiple light sources,

where L and N are unit vectors,

being the direction vector from the surface to the nth light source.

Specular (highlight producing),

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

Combining all three gives

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' description of light interaction, but instead on 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(*): Visual explanation of the Phong equation

(*) "color and ambient" are not the color of the model and the ambient lightning. "color" is the ambient color and "ambient" is the luminence of the ambient color. The object showed here is gray. But placed in a blue environnement. Thus, this image is very dangerous to consider and is quite inappropriate.

## Phong interpolation

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 polygon.

## History

Phong shading was developed by Vietnamese computer graphics pioneer Bui Tuong Phong, who published it in his 1973 PhD dissertation at the University of Utah.

### Video games

The first 3D gaming hardware capable of Phong shading was Sega's Hikaru arcade system in 1999, with the Hikaru's debut title Brave Firefighters (1999). For the next several years, the very expensive Sega Hikaru arcade system was the only gaming hardware powerful enough for effective Phong shading, with games such as Planet Harriers (2000). Because home systems at the time did not support Phong shading, most Sega Hikaru arcade games were never ported to home systems, with the exception of Cyber Troopers Virtual-On Force (2001) which was ported much later to the Xbox 360 console in 2010, by which time Phong shading was the norm on consoles.

Phong shading was eventually introduced to PC gaming with ATI's Radeon 9700 graphics card. However, Phong shading was still rarely used in PC gaming after that because it was computationally expensive. Doom 3 (2004), for example, used Blinn-Phong shading, an approximation of Phong shading, rather than true Phong shading. Half-Life 2's Source Engine did not support Phong shading until the release of Half-Life 2: Episode One in 2006. It was around 2005 that Phong shading began gaining popularity, with the release of Microsoft's Xbox 360 console and more powerful PC graphics cards.

Phong shading is today evidently used in most modern 3D graphics engines, including Crytek's CryEngine series, Valve's Source EngineEpic's Unreal Engine 3 & 4Square Enix's Luminous Studio, and Kojima ProductionsFox Engine, among others.