Brain Dump

Phong Illumination

Tags
computer-graphics

An illumination algorithm in 4 [see page 7, stages], which only supports direct illumination and lacks support for shadows or inter-reflection between objects.

We define the light intensity:

\begin{align*} \mathrm{Reflected Light} &= \mathrm{Ambient} + \mathrm{Diffuse} + \mathrm{Specular} \
l &= (k_a \times l_a) + (k_d \times l_d) + (k_s \times l_s) \end{align*}

Such that \[ k_a + k_d + k_l = 1 \].

This can also be [see page 15, rewritten] as: \[ I = k_a \times l_a + I_L(k_d(L.N) + k_s(R.V)^{n}) \]

Note: when using multiple light sources you should Sum each light source in place of \(I_L\) and clamp it to prevent illumination overflow.

TermDefinition
\(k_a\)Fraction of ambient light reflected (esentially the color of the surface).
\(l_a\)Ambient light intensity.
\(k_d\)
\(l_d\)Intensity of the light incident on the surface.
\(k_s\)
\(l_s\)

Note: You can [see page 22, specify] a vector of diffuse values for RGB coloration.

Ambient

\[ k_a \times l_a \]

A constant (we specify) that [see page 8, simulates] the global/indirect illumination. It specifies how something which isn't in visible light should appear.

Warn: This doesn't account for reflections.

Consider a ball held above your head towards the sun. The front of the ball is visible because the sun is shining on it but the back would be completely black (ignoring sunlight) reflecting onto it from other sources.

Diffuse

\[ k_d \times l_d \]

Simulates the directional impact light has on an object. The more an object faces a light source, the brighter its surface becomes.

We [see page 10, can] calculate the normal using the dot product between the normal of the polygon (N) and the direction of the light source (L).

\[ l_d = I_l cos(\theta) = I_l (L . N) \]

Where the \(\theta\) is the angle between the two vectors \(L\) and \(N\). And \(I_l\) is just the intensity of the light source. Observe that with this model the object has the greatest specular contribution where it's normal is facing the light source (\(\cos(0) = 1\)) and the lowest contribution when perpendicular from it (\(\cos(90) = 0\)).

Note: The angle of our viewpoint (v) is [see page 9, irrelevent]. All that's relevant is the angle at which the normal of the surface meets the light source.

Consider a [see page 11, [sphere](COM3503-w04-rendering-01)]. The light that's reflected onto our eyes is the same regardless of where we're looking. The illumination at the surface is dependent on the intersection of that point and the light source.

Specular

\[ k_s \times l_s \]

Specifies the shinyness (reflectivity) of a surface.

The idea behind phongs approach was that:

- Ideal (perfectly smooth shiny) objects reflect light in the mirror direction. - Most objects are not ideal so light is reflected in the vicinity of the mirror direction. - The [tiny bright](https://www.google.com/search?q=specular+lobe&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiygYf6t8vsAhVZShUIHYhrDeIQ_AUoAXoECBUQAw&biw=2124&bih=1106&dpr=0.88) spot we see on the surface of shiny object is the specular lobe.

Phong calculates this [see page 14, value] using the cosine of the angle between the viewpoint and the perfect mirror direction to some power \(n\). The value of \(n\) indicates how reflective the object is, a low value of n is very noisy whereas a high value is very clearly smooth and shiny (See the \(cos^{n}(\Omega)\) graphs).

Optimisations

Blinn [see page 20, introduced] an optimisation for this equation by removing the need for calculating \(R.V\)