Phong Illumination Model - School of Computer Science

PG Geldenhuys
Real World Lighting
Physical objects tend to interact with light in
three ways:
• Absorption (black body)
• Reflection (mirror)
• Transmission (glass)
Components of Colour
All colours in the spectrum can be represented
through the combination of intensities of 3
distinct colours, namely:red, green, blue
1.
In coming light carries
information about the
intensity of each of its 3
components.
2.
The reflected intensity of
each component is calculated
individually.
3.
The resulting colour of the
reflected light is then the
combination of the 3
reflected components.
1. Incoming light
3. Reflected
light
2. Surface colour
Lighting in OpenGL
The Phong Illumination model empirically divides
reflection into 3 components:
• Diffuse (Lambertian)
• Specular
• Ambient
Lambertian Explained –
Diffuse reflection arises from the assumption that light from any direction is reflected
uniformly in all direction. Such a reflector is called a pure Lambertian reflector.
Most objects are not perfect Lambertian reflectors. One of the most common
deviations is for smooth metallic or highly polished objects. They tend to have
specular highlights (or “shiny spots”).
Diffuse Light
• Does not originate from the source!!
• It is a component of the reflection due to even
scattering of light by uniform, rough surfaces.
• Depends on the direction of the light and the
surface normal.
• Therefore Light emitted in all directions
(moving the camera relative to the surface and light source will not change
how much the face is lit)
The amount of diffuse light emitted, does depend on the orientation
of surface to the light source.
A surface  to
light source emits
the most light

Intensity  n  r
Or…
Intensity  cos 

Intensity  n  r
A surface // to
light source emits
no light
r  nˆ
I d  I s d
r
I d  I s  d cos
A surface at some
arbitrary angle to the
source emits light whose
intensity is dependent on
the angle
Id – Intensity of emitted light
Is – Intensity of light source
d – diffuse reflection coefficient
(for material)
Note:
Its not possible to have a negative intensity!! When  > 90 or  < -90  Id = 0
We could then rewrite the
formula above as follows :
 r  nˆ 
I d  I s  d max  
,0 
r


Note:
This is not a physically accurate model:
1.
2.
True light is not composed of three components, but an entire
spectrum of frequencies.
In reality, Light intensity is inversely proportional to the distance
from the source squared.
Why does OpenGL not stick to a physically
accurate lighting model?
Realistically, objects emit diffuse light from all
points on their surface, which once again
should fall incident on every other object in
the room.
Practically, OpenGL allows only eight light
sources to be used.
Specular Light
• Originates from the source, not the
material!!
• Material colour should not influence it
• Causes highlights to appear on shiny
surfaces in a mirror-like way.
• Light is emitted in specific directions
(moving the camera relative to the surface and light source is
expected to change which portions of the face are lit)
Phong Model
• Method used by OpenGL to simulate specular lighting
• Best for modeling plastic or glassy materials, not very good for metals
Perfect Mirror
i r
Light is only reflected in the
direction where i = r
Phong Model
i r
For one particular angle of incidence,
light is reflected in a number of
directions, but is most intense in the
direction where i = r.
On either side of this angle, the
intensity drops off to 0.
Phong Model
The intensity varies as some
complicated function of , but in the
Phong Model, it is made to vary
according to the following function:
cosf(), where f should range
somewhere in the region between 0
and 200.
Intensity  r  v 
f
Or…
Intensity  cos f 
I sp
 r v 

 I s  s 

rv
r
i r
f
I sp  I s  s cos f 

v
Isp – Intensity of reflected
light
Is – Intensity of specular
light source
s – specular reflection
coefficient (for material)
 - angle between viewing
vector and maximum
reflection vector
Note:
Its not possible to have a negative intensity!! When  > 90 or  < -90  Isp = 0
We could then rewrite the
formula above as follows :
I sp
 r v  f 
 ,0 
 I s  s max  
 r v





Note:
This diagram is a polar plot, so the length of
the arrows on the right hand side, represent
the reflected intensity for different camera
angles relative to the normal.
i
f
The graph above, shows how the function: cosf() varies with
different values of f. When f = 1, the shininess of the material is low,
and the specular highlight will be large. When f = 256, the shininess
of the material is high (the material is almost mirror like), and the
specular highlight will be small.
Reasons for Ambient Light
• In the real world, light reflecting off walls and other objects
accounts for a lot of the light in a room.
• Physically, if an object were placed in a lit room, even the faces
not directed towards the light would be visible.
• If only diffuse and specular light were applied to a scene, large
areas of it would be left in darkness. (Areas where the angles
between the normal to a face and the light vector were greater
than 90, or less than 0 degrees) (Shadows would appear
unrealistically dark)
Ambient Light
Ambient light has a uniform intensity in all directions, and serves
to increase the overall brightness of the environment.
I  I a a
Ia – Intensity of ambient
light
Pa – Ambient coefficient of
surface.
• Too little – Shadows too harsh
• Too much – picture appears bland
The Overall Picture
The overall light intensity used to shade each face of an object, is
now simply the sum of the three different light intensities
incident on that face i.e.
Intensity = I a  a
 r v  f 
 r  nˆ 


,0 
 ,0 + I d  d max  
+ I s  s max  

r
r v 





This calculation must then be performed for each of the three
light components (R, G, B) to calculate the overall colour of that
face.
Application of the Model
Intensity = I a  a
 r v  f 
 r  nˆ 


,0 
 ,0 + I d  d max  
+ I s  s max  

r
r v 





This is the very formula used by OpenGL, and its parameters are
set as follows:
Ambient
• Ia : Use glLight, set
GL_AMBIENT to the
desired RGB value
• a : Use glMaterial, set
GL_AMBIENT to the
desired RGB value.
Specular
• Is : Use glLight, set
GL_SPECULAR to the
desired RGB value
• s : Use glMaterial, set
GL_SPECULAR to the
desired RGB value.
• f : Use glMaterial, set
GL_SHININESS to the
desired floating point
value.
Diffuse
• Id : Use glLight, set
GL_DIFFUSE to the
desired RGB value
• d : Use glMaterial, set
GL_DIFFUSE to the
desired RGB value.
Wow . . .
For multiple light sources, we add up the ambient, diffuse, and
specular components for each light source to produce the final
product . . .
References
• Lecture notes on illumination by Steve
Sterley.
• Illumination models by Prof Jonathan
Cohen from the Johns Hopkins
Department Of Computer Science.
• Graphics: Illumination, The University
Of Texas Austin.
• Illumination models and Shading, Foley
& Van Dam.