Transcript lighting

Illumination
Lighting
and Shading
CPI 400
SciComp & Viz
Arizona State University
Terminology
• Illumination:
1. luminous flux at any point on a surface exposed to incident light
(direct or indirect)
2. A light source
3. Spiritual or intellectual enlightenment
• Lighting:
1. Method to provide artificial illumination
2. Illumination
3. The act of igniting
Lighting Overview
•
•
•
•
CG lighting models
Elements of a lighting model
The Phong illumination model
Application of the Phong model
Shading methods: flat, Gouraud, Phong
CG Lighting Models: Global
Multiple interaction
of light & objects
Not real-time (yet)
Examples:
Raytracing,
radiosity,
photon mapping …
From:
http://jedi.ks.uiuc.edu/~johns/raytracer/rayga
llery/stills.html
CG Lighting Models: Local
Single interaction
of light & objects
Real-time
Supported by OGL
Example:
Phong illumination
model
Elements of a Lighting Model:
• light sources:
number, type (desk lamp vs sun), color
Elements of a Lighting Model:
• light sources:
number, type, color
• reflections
Elements of a Lighting Model:
• light sources:
number, type, color
• reflections
• material properties:
reflection & absorption
of light
3D feel,
depth perception
lighting model == approximation of real-world lighting!
Elements of the Phong Model
Light Source Properties
1. ambient light
>
>
>
>
scattered
no detectable direction
backlighting in a room
can use to give a feel for the main
color in a room
> not dependent on viewpoint
Elements of the Phong Model
Light Source Properties
1. ambient light
2. diffuse light
>
>
>
>
directional
scatters equally in all directions once hits object
closest to the color of light
not dependent on eye position
Elements of the Phong Model
Light Source Properties
1. ambient light
2. diffuse light
3. specular light
>
>
>
>
comes from a detectable direction
bounces off object in preferred direction
plays a role in shininess
dependent on viewpoint
diffuse and specular normally set the same
Elements of the Phong Model
Light Source Properties
1.
2.
3.
4.
ambient light
diffuse light
specular light
point source vs spotlight
> point source: light emitted in all directions
> spotlight: cone-shaped
Elements of the Phong Model
Material properties
Elements of the Phong Model
Material properties
1. reflectance of light
a. ambient
> amount of ambient light
> most visible where no direct light hits
Elements of the Phong Model
Material properties
1. reflectance of light
a. ambient
b. diffuse
> degree of scattering of light on surface
> matte vs flat paint finish
Color of object == ambient and diffuse
(typically set the same)
Elements of the Phong Model
Material properties
1. reflectance of light
a. ambient
b. diffuse
c. specular
> degree of mirror-like quality
> typically set to white so highlights
produced are color of light
Elements of the Phong Model
Material properties
1. reflectance of light
a. ambient
b. diffuse
c. specular
d. translucent (opaque)
Elements of the Phong Model
Material properties
1. reflectance of light
a. ambient
b. diffuse
c. specular
d. translucent (opaque)
2. surface normals (unit length!)
Elements of the Phong Model
Material properties
1. reflectance of light
a. ambient
b. diffuse
c. specular
d. translucent (opaque)
2. surface normals
3. emissive color
Light & Material Properties
Examples
increasing diffuse
increasing ambient
increasing specular
Light & Material Properties
absorption/reflectance influence on color
Example:
red box will reflect red light
absorb green and blue light
Geometry of the Phong Model
v
p
l
n
r
v
theta
phi
point on surface
(light – p) vector
normal to surface
reflection vector
(viewpoint – p) vector
angle of incidence
angle between v and r
All vectors normalized
p
Recall: angle of incidence
equals angle of reflection
Diffuse Intensity Calculation
Lambert’s
Law:
light reflected is proportional to the
cosine of the angle (theta) between
surface normal n and light vector l
theta is called the angle of incidence
Diffuse Intensity Calculation
Lambert’s
Law:
light reflected is proportional to the
cosine of the angle (theta) between
surface normal n and light vector l
theta is called the angle of incidence
theta=0
theta=60
Flat Shading
One normal per triangle
Simulates viewer and light source distant
then v, n, l same over triangle
 one shading calculation
glShadeModel(GL_FLAT)
Gouraud (smooth) Shading
One normal per vertex
Lighting calculation made at each vertex  I1, I2, I3
Lighting at any point p within triangle v1, v2, v3
I = b1*I1 + b2*I2 + b3* I3
where b1, b2, b3 are the
barycentric coordinates
of p wrt v1, v2, v3
p = b1*v1 + b2*v2 + b3*v3
(b1 + b2 + b3 = 1)
Phong Shading
One normal per vertex ... however
a normal is calculated for each rendered point p in triangle
vertex normals n1, n2, n3
p = b1*v1 + b2*v2 + b3*v3
n = b1*n1 + b2*n2 + b3*n3
Calculate intensity at p wrt n
Not considered a real-time algorithm
therefore, not in ogl