CS488 - Introduction to Computer Graphics - Lecture 10
Public Service Announcements
- Assignment 3 due 18 June, one week from today.
- PDF that covers colour
Lambertian Surfaces
Model of body reflection
How much light hits the surface?
- Idealize light sources as points emitting light
- How much light does a source emit?
- How much light is there at a distance r from the source?
- Segregate the light by direction
- How much light per unit angle?
- How much light per square metre?
- Falls off with distance.
- How? Think how big the surface of a sphere is.
- How much of the surface does a square metre of the sphere cover?
- Depends on the angle
- How?
- What if the lights were (infinite) lines?
- Why is an infinite line the same as a circle?
- What if the lights were (infinite) planes?
- Why is an infinite surface the same as a sphere?
- In computer graphics this is called ambient light.
- What do we do in practice?
Comment. Two general aspects of the above are very important to getting
things right in computer graphics
- The scaling arguments from dimensionality
- The geometric derivations of angular facts from small areas
How much light leaves the surface?
This material is described with diagrams here.
We are only interested in the light leaving the surface in a particular
direction. Why?
The light divides into two parts at the surface
- part is reflected: `surface reflectance'
- part enters the surface: `body reflectance'
The simplest model of body reflectance is Lambert's cosine law. Surfaces
with body reflectance following Lambert's cosine law are called
Lambertian.
What makes a Lambertian surface Lambertian?
- Half-sphere within the body, centred at the bit of surface
- Half-sphere above the body, bottom at the surface
- Draw a little cylinder passing through the centre.
- Whatever goes in the bottom comes out the top
- modified by the angular size of the hole
- cosine factor
What goes into the eye
- Same geometry as illumination, only backward
- Cosine factors cancel one another
Important point
- The ubiquitous cosine terms (l.n, v.n, etc.) occur whenever we
translate between areas on a plane and areas on a sphere.
What colour is the light?
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?
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
Shading
Terminology
- Psychologist: shading
- Artist: shading
- Add lighting effects that convey shape
- Masaccio
- Utah-graphics: shading
- interpolate within polygons to eliminate faceting
- Renderman: shader
- function applied at a pixel to determine colour once geometry and
illumination are known
- GPU: shaders
- vertex shader
- geometry shader
- pixel shader
We are doing Utah-graphics
Flat Shading
Shade entire polygon one colour
- 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
Gouraud Shading
Calculate at vertices and interpolate linearly
- derivative discontinuities at polygon edges
- Mach bands
Interpolating within triangles
- 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)
- 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
- C(P) = a1 * C(V1) + ...
- C(P) is the determinant of a matrix, if you care
- The calculations are affine-invariant, so you could
- transform a triangle into a standard triangle with an affine
transformation
- shade it
- 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.
What's wrong with Goraud shading?
- Think about the edge between two triangles
- Think about highlights
Phong Shading
Interpolate the vertex normals, light vectors, and view vectors
- Do the lighting calculation at each pixel
Highlights are more precise
Return to: