# Highlights

Part of the light didn't enter the body of the surface, but was reflected

• Called surface reflection'
• Where does it go to?

Suppose the surface is smooth

• It is reflected, called specular'
• which means s (specular ray) = l (illuminant ray) - 2 * (e \dot n ) n (normal)
• what is the colour?
• we are assuming that it enters the eye

Suppose we roughen the surface just a little

• The light spreads a little, centred on the specular direction.
• Called gloss'.
• Amount entering the eye depends on the angle between the eye ray and the specular direction

And if we roughen the surface a lot

• The light goes out all over the place
• This is called a matte surface

Here is the hack

• Named Phong lighting after Phong Bui-Tuong
• Let the specular term be ( s \dot e (eye ray) )^p
• small p - matte
• large p - highly specular

How is the incoming light divided between ambient, surface and body reflection?

• Depends on the surface

L(\lambda) = Ia * ka(\lambda) + Id * ( l \dot n ) * kd(\lambda) + Is * ( s \dot e )^p * ks

• ambient term
• Ia( \lambda ) - intensity of ambient light
• ka( \lambda ) - ambient reflectance
• body term
• Id ( \lambda )- intensity of refracted directional light
• l \dot n - geometical factor for illumination direction
• kd( \lambda ) - Lambertian reflectance
• implicit ( e \dot n ) / ( e \dot n )
• surface term
• Is( \lambda ) - intensity of reflected light
• s - specular direction, e - eye direction, p - hack for matte/specular
• ks - reflectance of surface

Terminology

• Add lighting effects that convey shape
• Masaccio
• interpolate within polygons to eliminate faceting
• function applied at a pixel to determine colour once geometry and illumination are known

We are doing Utah-graphics

• Which colour?
• The one calculated from
• illumination
• normal
• view point
• surface properties
• For which pixel
• average colour of all pixels in polygon -- (What?!!?)
• some particular pixel

Calculate at vertices and interpolate linearly

• derivative discontinuities at polygon edges
• Mach bands

Interpolating within triangles

1. Barycentric coordinates
• Three vertices: V1, V2, V3
• Inside point: P = a1*V1 + a2*V2 + a3*V3, subject to a1 + a2 + a3 = 1
• ai = area of triangle opposite Vi / area of entire triangle
• area of triangle (V1, V2, V3) is (1/2) * (V2 - V1) x (V3 - V1)
• e.g. a1 = (V3 - V2) x (P - V2) / (V2 - V1) x (V3 - V1)
2. For practical interpolation we care about P -> P + v
• a1 -> a1 + (V3 - V2) x v / (V2 - V1) x (V3 - V1)
• if we are scanning parallel to an edge, then the corresponding area (ai ) is constant
3. C(P) = a1 * C(V1) + ...
• C(P) is the determinant of a matrix, if you care
4. The calculations are affine-invariant, so you could
• transform a triangle into a standard triangle with an affine transformation
• transform it back

BUT, the calculations are NOT projection-invariant

• Why?
• Graphics hardware can adjust so that you can shade in display space

Interpolating within arbitrary polygons is a bad idea

• Divide into triangles
• But if you must, the algorithm is similar to scan-converting an arbitrary polygon.

• Think about the edge between two triangles