Illumination & Shading
1. Physics of Light
The color & shading intensity of a point on an object depends on the characteristics of the object (i.e. position, surface normal, albedo) and the light sources (i.e. intensity, distance) that illuminate it.
Albedo is an object's ability to absorb light energy, or reflectivity.
- Energy of a photon
. - Radiant energy of
photons . - Radiation flux (power)
. - Radiance is the radiant flux per unit solid angle per unit projected area, measured in
. It represents the number of photons per time at a small area in a particular direction. It is given by , where is the angle between the surface normal and the direction of the incoming light. - Irradiance is the differential flux onto a differential are, measured in
. It is given by . It is the density of incident flux falling onto a surface.
2. Reflection & Reflectance
Reflection is the process by which electromagnetic flux incident on a surface leaves the surface without a change in frequency.
Reflectance is the fraction of incident flux that is reflected by a surface.
Reflectance is given by a bidirectional reflectance distribution function (BRDF), which is defined as
. It is the ratio of reflected radiance in a given direction to the incident irradiance from a given direction. It is a function of the incoming and outgoing angles, and has units of .
Isotropic BRDFs are simplified models that assume the reflectance is the same in all directions, i.e.
. This reduces the number of parameters from 4 to 3, and is a common assumption in computer graphics.
Anisotropic BRDFs are more complex models that account for directional dependence of reflectance, such as brushed metal or hair. They require more parameters to describe the reflectance behavior.
BRDFs may have the following properties:
- Non-negativity:
. - Energy Conservation
. - Reciprocity
.
A more precise model for reflection is the bidirectional scattering surface reflectance distribution function (BSSRDF), which includes both reflection and transmission.
2.1 Computing Reflected Radiance
To compute the reflected radius, we say:
Or, in the discrete case, for
Where
2.2 Ideal Diffuse Reflectance
Here, assume the surface reflects equally in all directions. In reality, this is a very rough surface (e.g. chalk, clay, dull paints). Here, the BRDF value is constant, so:
Ideal diffuse reflectors reflect light according to Lambert's Cosine Law, which states that the intensity of reflected light is proportional to the cosine of the angle between the surface normal and the incoming light.
For IDR, given the diffuse reflection coefficient
Here, the dot product is clamped to avoid negative values, which would correspond to light coming from behind the surface. The term
2.3 Ideal Specular Reflectance
Here, reflection is only at a mirror angle. This is view dependent, and is a very smooth surface (e.g. polished metal). Real-world materials are usually not perfect reflectors.
2.4 Non-ideal Reflectors
We expect most of the reflected light to be reflected in the direction of the ideal ray. Because of microscopic surface variations we might expect some light to be reflected at a slight offset to the ideal reflected ray. As we move farther away (in the angular sense) from the reflected ray we expect to see less light reflected.
3. Phong Model
The Phong model is a mathematical model deciding how much light is reflected.
is the surface normal. is the light direction. is the ideal reflected ray. is the angle between and , or between and . is the view direction. is the angle between and . is the specular reflection coefficient. is the specular reflection exponent. Decides how glossy/blurry the reflection is. When , we approximate a diffuse material. As , we approximate a perfect mirror.
Then:
3.1 Blinn-Phong Model
This model uses the halfway vector
3.2 Ambient Illumination
Ambient illumination is a hack to represent the reflection of all indirect illumination, avoiding the complexity of global illumination:
Adding it all together gives the Phong illumation model:
3.3 Heuristic Inverse Square
The
4. Shading
There are three levels of shading which can be applied to polygon based systems. These are responsible for determining the color of each pixel on the screen.
4.1 Flat Shading
Here, each polygon is shaded uniformly over its surface. This is computed by taking a point in the centre and the surface normal vector. Only diffuse and ambient components are used.
4.2 Gouraud Shading
Also known as interpolation shading. This is done by:
- Computing a shade value at each vertex.
- Interpolate to find the shade value at the boundary.
- Interpolate to find the shade value at each pixel.
In addition to interpolating shades over polygons, we can interpolate over groups of polygons to give an impression of a smooth surface.
4.3 Phong Shading
Also known as smooth shading, this is more accurate than Gouraud shading but slower. This interpolates normals across triangles, and computes the shade value at each pixel.
This interpolation is known as barycentric interpolation. Any point on a triangle
The average normal vector at that point is then given by:
These formulae come from barycentric coordinates where:
In other words,
The interpolation calculates may be done in either or 2D or 3D. For specular reflection, it must be done in 3D.