C481 B581 Computer Graphics
Dana Vrajitoru

Rendering


Light and Color

What is light: Some properties of the light:

Light sources

Ambient light:

Directional light: Point light source: Projection 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:

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:

ks = ksc * random(0.8, 1)
kd = kdc * random(0.8, 1)

Distance Term in the Phong Model