C481 B581 Computer Graphics
Dana Vrajitoru
Rendering
Light and Color
What is light:
-
electromagnetic wave
-
frequency (f) and wavelength (lambda) :
c = f * lambda
-
white light: contains all visible frequencies 400
nm < l < 700 nm
-
Color: a particular frequency.
-
Red = 700, green = 546.1, blue = 435.8
Some properties of the light:
- Brightness or luminance: total energy of the light
- Hue: the dominant wavelength
- Saturation: the percentage of luminance which is taken by the
dominant wavelength.
- The color sensation or intensity I = r ×
Ired + g × Igreen
+ b × Iblue
Light sources
Ambient light:
-
Illuminates the entire scene uniformly.
-
The light of the sun on a cloudy day.
-
Does not produce shadow.
-
Its intensity is constant.
Directional light:
-
A light source situated at the infinity, that arrives everywhere along
the same direction.
-
The sun on a sunny day.
-
Produces a shadow.
-
The intensity is constant.
Point light source:
-
Light sources situated at a perceptible distance that illuminate the scene
radially.
-
An uncovered lamp.
-
Produces shadow.
-
The intensity can depend on the closeness to the source.
-
It illuminates along a direction going from the light source to the current
point.
Projection light source:
-
Similar to the point light sources, but they don't illuminate in every
direction.
-
It has an illumination range, which is usually inside a cone centered on
the light source.
|
|
|
|
Ambient light
|
Directional light source
|
Point light source
|
Projection light source
|
General principle
The intensity of what we see from a ray of light depends on the angle
between it and the view vector.

Constant Shade Model
Note that the normal to any planar polygon (triangle) is constant on
the polygon.
If Ip is the intensity of the light, L the opposite of the
direction of the light, and N is the normal to the surface, we can
compute the intensity of the light on that polygon as
I = Ip cos (N, L)
The color will be constant on the surface of the polygon.
The Phong model
Local illumination model: considers only one point at a time.
Notations (all the vectors are unit vectors):
Q - the point to draw.
V - the viewpoint vector, going from the point Q to the viewer's eye
for the perspective projection, or perpendicular to the projection plane
for the parallel projection.
N - the normal to the surface in the point Q.
L - a vector going from the point Q to the light source.
R - the reflection of L in the point Q: L, N, and R are co-planar, L
and R make the same angle with N.
theta - the angle between L or R and N: cos theta
= L × N.
phi - the angle between R and V: cos phi
= R × V.
General idea: split the ray L into two reflected rays:
-
diffuse reflection, going equally in all directions, of factor
kd .
-
specular reflection, going in the R direction, of factor
ks.
-
add the ambient component of factor ka.
-
if ka+ ks+ kd < 1, part of the ray
is absorbed by the material.
Computing the light intensity in Q :
I = kaIa + kdId + ksIs
Ia is constant.
To compute Id and Is, start with the intensity
of the light source Ip.
Id = Ip cos theta For the specular
component, Phong added a reflection factor k that concentrates the
specular reflected light on R. If k is large, the specular component
of the intensity decreases more dramatically as the angle between R
and V increases.
Is = Ip cosk phi
Computing the Color
Given the color of the object from which a point has been projected onto
the current pixel (independent of the light):
object_color = (r, g, b)
and I, the intensity of the light computed with the Phong model:
I = kaIa + kdId +
ksIs=
(Ired, Igreen, Iblue)
The color that will be drawn on one pixel:
pixel_color = r Ired + g Igreen +
b Iblue
Generalizing the Phong model
Several light sources with intensities Ip1,
Ip2, ..., Ipn:
Id
= Sumin=1
Ipi cos thetai
Is
= Sumin=1
Ipi
cosk phii
For point light sources with intensity decreasing with distance:
Ip = Ipc * 1/(d(Light source,
Q)+e)
For projection light source: if Phi
= angle(L, light source direction)
Ip = Ipc *
cos Phi, if Phi
< Phi0
Ip = 0, if Phi > Phi0
Surface properties:
-
For metallic surface: increase ks and k.
-
For velvet-looking surface: increase kd.
-
Surface irregularities: introduce a random factor in the reflected
components.
ks = ksc * random(0.8, 1)
kd = kdc * random(0.8, 1)
-
Can produce stone surfaces, orange skin, fabrics, journal paper, wood,
etc.
Distance Term in the Phong Model
- To include a term depending on the distance to the light source,
if we denote by
d = distance (light source, Q)
I = kaIa + factor *(kdId +
ksIs)
where factor = 1/(a + bd + cd2)
- The factor is know as the quadratic attenuation term.