Illumination Model
Why Lighting?
Color is a fundamental attribute of our viewing
experience. The perception of color arises from light
energy entering our visual system.
This complex process is relevant to computer
graphics because a realistic image is one that seems
indistinguishable from the light energy coming from a
real scene.
If we don’t have lighting effects nothing looks three
dimensional!
Why Lighting? (cont…)
Basics of Reflected Light
The colours that we perceive are determined by the
nature of the light reflected from an object
For example, if white
light is shone onto a
green object most
wavelengths are
absorbed, while green
light is reflected from Colours
Absorbed
the object
Basics of Reflected Light
The amount of incident light reflected by a surface
depends on the type of material
Shiny materials reflect more of the incident light and
dull surfaces absorb more of the incident light
For transparent surfaces some of the light is also
transmitted through the material
Components of Reflections
Ambient – surface exposed to indirect light reflected from nearby objects.
Diffuse – reflection from incident light with equal intensity in all directions.
Depends on surface properties.
Specular – near total of the incident light around reflection angle.
6
Real Lights and Reflection
Real lights are complicated
Sun light, iridescent bulbs, fluorescent bulbs
Different spectra in different directions
Again, pretty complicated
May be described by bidirectional reflectance distribution
function (BRDF)
Besides
The incoming light can come from a source, or bouncing
off another object, or after multiple bounces
Sources can be extended
Multiple interactions between light and surface
Illumination Model
An illumination model, also called a lighting model is
used to calculate the intensity of light that we
should see at a given point on the surface of an
object.
Done by simulating some light attributes
Can be
Local illumination
Global illumination
8
Illumination Model
Local illumination
Models only the direct illumination from the source
Does not consider light reaching after bouncing off other objects
Only consider the light, the
observer position, and the
object material properties
Global illumination
take into account the interaction
of light from all the surfaces in
the scene
9
Things to Model
Light sources
What color, intensity, lines through space
Reflection of light off surfaces
How much light reflected in each direction
How are color and intensity changed
Life on a surface
L: direction to light
N: normal vector
R: reflection of light about normal
V: direction to viewer (i.e. reflection
direction of interest)
Point Light Sources
Simplest model we can use for a light source
Defined by:
The position (x,y,z) of the light
The RGB values for the colour of the light
Radiates equal intensity in all direction
L = Plight - Psurface
Directional Light Sources
A large light source, like the sun, can be modelled as
a point light source
However, it will have very little directional effect
i.e. All light rays are considered parallel
Specified by:
• direction (x,y,z)
• intensity (r,g,b)
L = -direction
Intensity Attenuation
As light moves from a light source its intensity
diminished
At any distance d away from the light source the
intensity diminishes by a factor of 1
d2
This means that
a surface close to the light source (small d) receives a
higher incident intensity from the source than a distant
surface (large d).
Intensity Attenuation
However, using the factor 1 2 does not produce very good
d
results so we use something different
We use instead in inverse quadratic function of the form:
1.0, source at infinity
f radial d 1 .
attenuation a a d a d 2 , local source
0 1 2
A user can then fiddle or manipulates with the coefficients ao,
a1, and a2 , to obtain a variety of lighting effects
The value of the constant term ao can be adjusted to
prevent f(d) from becoming too large when d is very
small.
Spotlights
To turn a point light source into a spotlight we simply
add a vector direction and an angular limit θl
If Vlight and Vobj are the unit vector
Then
Vobj Vlight cos
If this angle is inside the light’s angular limit then the
object is within the spotlight
Spotlights - Angular Intensity Attenuation
Points outside the cone are not illuminated (stay in
dark).
Angular attenuation is:
1.0, source not a spotlight
fangular 0.0, Vobj Vlight cos cos
attenuation
a otherwise
Vobj Vlight ,
a is a constant
Phong Model
Phong model is an empirical model developed in 1973
by Phong Bui Tuong
Simple and fast method for calculating surface intensity
at a given point
Gives reasonably good results and is used in most
graphics systems
The important components are:
Ambient light
Diffuse reflection
Specular reflection
Emissive light
For the most part we will consider only monochromatic
light sources
Ambient Light
A surface that is not exposed
to direct light may still be lit
up by reflections from other
nearby objects – ambient
light
The total reflected light from
a surface is the sum of the
contributions from light
sources and reflected
light
Ambient Light
To incorporate background light Phong model simply
set a general brightness level for a scene
This approximates the global diffuse reflections
(inter-reflections) from various surfaces within the
scene
This light intensity is simply denoted by Ia,
It is
Independent of the light positions or surface directions
Independent of location of viewer
Has no direction
Diffuse Reflection
Surfaces that are rough or grainy tend to reflect light
in all directions
This scattered light is called diffuse reflection
This type of reflection is called Lambertian Reflection
(thus, Lambertian surfaces)
The brightness of the surface is independent of the
observer position (since the light is reflected in all
direction equally)
Diffuse Reflection (cont…)
Surface’s material property:
A parameter kd is set for each surface
kd determines the fraction of light that is to be scattered as
diffuse reflections from that surface
This parameter is known as the diffuse-reflection
coefficient or the diffuse reflectivity
kd is assigned a value between 0.0 and 1.0
0.0: dull surface that absorbs almost all light
1.0: shiny surface that reflects almost all light
Diffuse Reflection – Ambient Light
For background lighting effects we can assume that
every surface is fully illuminated by the scene’s
ambient light Ia
Therefore the ambient contribution to the diffuse
reflection is given as:
I ambdiff kd I a
Ambient light alone is not enough to render a scene
or very uninteresting so we need some other lights in
a scene as well
Diffuse Reflection (cont…)
When a surface is illuminated by a light source, the
amount of incident light depends on the orientation of
the surface relative to the light source direction
N θ = angle of incidence
Il
Incident
light
Diffuse Reflection (cont…)
So the amount of incident light on a surface is given
as:
I l ,incident I l cos
So we can model the diffuse
reflections as: I l ,diff k d I l ,incident
k d I l cos
if N and L are unit vector, N L cos
k d I l ( N L ) if N L 0
I l ,diff
0 if N L 0
Combining Ambient And Incident Diffuse Reflections
To combine the diffuse reflections arising from
ambient and incident light most graphics packages
use two separate diffuse-reflection coefficients:
ka for ambient light
kd for incident light
The total diffuse reflection equation for a single point
source can then be given as:
k a I a k d I l ( N L ) if N L 0
I diff
ka I a if N L 0
Examples
Specular Reflection
Additionally to diffuse reflection we see a
highlight, or bright spot, on objects (such
as polished metal, apple ...) at certain
viewing directions.
This phenomenon, called specular
reflection,
It is the result of total, or near total reflection
of the incident light in a concentrated region
around the specular reflection angle.
Specular Reflection (cont…)
A perfect mirror reflects light only in the specular-
reflection direction
Other objects exhibit specular reflections over a finite
range of viewing positions around vector R
Specular Reflection Model
The Phong model sets the intensity of specular reflection as
proportional to the angle between the viewing vector and the
specular reflection vector
So, the specular reflection intensity is proportional to the
angle Φ can be varied between 0° and 90° so that cosΦ
varies from 1.0 to 0.0
The specular-reflection exponent, ns is determined by the
type of surface we want to display
Shiny surfaces have a very large value (>100)
Rough surfaces would have a value near 1
Specular Reflection Model
The effect of ns on the angular range in which we can
expect to see specular reflections
Specular Reflection Model
For some materials the amount of specular reflection
depends heavily on the angle of the incident light
Fresnel’s Laws of Reflection describe in great detail
how specular reflections behave
However, we don’t need to worry about this and
instead approximate the specular effects with a
constant specular reflection coefficient ks
Specular Reflection Model
So the specular reflection intensity is given as:
I l , spec k s I l cos
ns
V R cos
Remembering that
We can say:
k s I l (V R) ns if V R 0 and N L 0
I l , spec
0.0 if V R 0 or N L 0
Example
Calculating Reflection Vector
Since L and N are normalized
N L cos θ cos θ
N N cos θ ( N .L )N
U N L
R L 2U 2N L N L
Half way Vector
An alternative way of computing Phong specular
lighting is:
I l , spec k s I l ( N H ) ns
H (halfway vector): halfway between V and L
LV
H
|LV|
Why?
Efficient computations
36
Combining Diffuse & Specular Reflections
For a single light source we can combine the effects
of diffuse and specular reflections simply as follows:
I I diff I spec
k a I a k d I l ( N L) k s I l (V R) ns
Example
Example
Ambient Diffuse
Final
Specular Image
Emission
Some objects are self-luminous
Light intensity due to emission is measured as –
I e ki
k i coefficien t of the object' s intrinsic intensity
Therefore,
I I diff I spec I e
Multiple Light Sources
We can place any number of light sources in a scene
We compute the diffuse and specular reflections as
sums of the contributions from the various sources
n
I I ambdiff I l ,diff I l ,spec
l 1
n
k a I a I l kd N L k s V R
ns
l 1
Adding Intensity Attenuation
To incorporate radial and angular intensity
attenuation into our model we simply adjust our
equation to take these into account
So, light intensity is now given as:
I I ambdiff f l ,radatten f l ,angattenI l ,diff I l , spec
n
l 1
where fradatten and fangatten are as discussed
previously
RGB Colour Considerations
For an RGB colour description each intensity
specification is a three element vector
For each light source: I l I lR , I lG , I lB
Similarly all parameters are given as vectors:
ka kaR , kaG , kaB k s k sR , k sG , k sB
k d k dR , k dG , k dB
Each component of the surface colour is then
calculated with a separate expression
I lR ,diff kdR I lR ( N L) I lB ,diff kdB I lB ( N L)
I lG ,diff kdG I lG ( N L)
Summary
To create realistic (or even semi-realistic) looking
scenes we must model light correctly
To successfully model lighting effects we need to
consider:
Ambient light
Diffuse reflections
Specular reflections
Nate Robin’s Tutorial
Nate Robin’s OpenGL Tutorials available at: http://users.polytech.unice.fr/~buffa/cours/synthese_image/DOCS/
www.xmission.com/Nate/tutors.html