What is Light A very complex process Find a dark area how is it being lit Light bounces mirrors shiny objects Light refracts through other media water heat Light comes from everywhere Global Illumination ID: 697583
Download Presentation The PPT/PDF document "Lighting Jeff Chastine 1" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Lighting
Jeff Chastine
1Slide2
What is Light?
A very complex process
Find a dark area – how is it being lit?
Light bounces (mirrors, shiny objects)
Light refracts through other media (water, heat)Light comes from everywhere (Global Illumination)Light bounces off of lakes in weird ways (Fresnel effect)THUSWe’re forced to make approximationsTradeoff between time and realism“If it looks good, it is good” – Michael Abrash
http://darrentakenaga.com/3d.html
http://en.wikipedia.org/wiki/File:Global_illumination.JPG
Jeff ChastineSlide3
Two components
Light Source Properties
Color (Wavelength(s) of light)
Shape
DirectionObject PropertiesMaterialGeometryAbsorptionSlide4
4
Global Effects
translucent surface
shadow
multiple reflectionSlide5
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
Directional light
- position doesn’t matter
- triangle is almost fully lit
Jeff Chastine
5Slide6
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
(Triangle less lit)
Jeff Chastine
6Slide7
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
(Little to no light hits the surface)
Jeff Chastine
7Slide8
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
(Directional light)
Jeff Chastine
8Slide9
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
(Directional light)
Jeff Chastine
9Slide10
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
(Directional light)
Lesson learned: Lighting depends on angles between vectors!
Jeff Chastine
10Slide11
A Basic Lighting Concept
How can we determine how much light should be cast onto a triangle from a directional light?
P
2
P
0
P
1
(Directional light)
Assuming
N
and
L
are normalized, and
N∙L
isn’t negative
Jeff Chastine
11Slide12
Basic Lighting
Four independent components:
Diffuse
– the way light “falls off” of an object
Specular – the “shininess” of the objectAmbient – a minimum amount of light used to simulate “global illumination”Emit – a “glowing” effect
Only diffuse
Jeff Chastine
12Slide13
Basic Lighting
Four independent components:
Diffuse – the way light “falls off” of an object
Specular
– the “shininess” of the objectAmbient – a minimum amount of light used to simulate “global illumination”Emit – a “glowing” effect
Diffuse+Specular
Jeff Chastine
13Slide14
Basic Lighting
Four independent components:
Diffuse – the way light “falls off” of an object
Specular – the “shininess” of the object
Ambient – a minimum amount of light used to simulate “global illumination”Emit – a “glowing” effect
Ambient
Diffuse+Specular+Ambient
Jeff Chastine
14Slide15
Basic Lighting
Four independent components:
Diffuse – the way light “falls off” of an object
Specular – the “shininess” of the object
Ambient – a minimum amount of light used to simulate “global illumination”Emit – a “glowing” effect
D+S+A+Emit
Note: emit does not produce light!
Jeff Chastine
15Slide16
Interaction between Material and Lights
Final color of an object is comprised of many things:
The base object color (called a “material”)
The light color
Example: a purple light on a white surfaceAny textures we apply (later)Materials and lights have four individual componentsDiffuse color (cd and
ld) Specular color (cs and l
s) Ambient color (
ca and la) Emit color (
ce and
l
e
)
c
d
*
l
d
= [cd.r*ld.r
, cd.g
*ld.g , cd.b*ld.b] // R, G, BJeff Chastine16Slide17
Light Source Direction
In computer graphics, we usually treat lights as
rays
emanating from a source. The
direction
of these rays can either be:
Omni-directional (point light source)
Directional angle (spotlights)
Directional (parallel rays)Slide18
General Lighting
Primary vectors
l
– the incoming light vector
n – the normal of the plane/vertexr – the reflection vectorv – the viewpoint (camera)
l
n
r
θ
θ
v
Jeff Chastine
18Slide19
Diffuse Term
Contribution that a light has on the surface,
regardless of viewing direction
.
A ray of light coming in has an equal chance of being reflected in any direction.What are some ideal diffuse surfaces?Slide20
Lambertian
ReFlectance(diffuse Component)
Light falling on an object is the same
regardless
of the observer’s viewpointGood for rough surfaces without specular highlights
where
and
are normalized
l
n
θ
Jeff Chastine
20Slide21
Lambertian
ReFlectance(diffuse Component)
Light falling on an object is the same
regardless
of the observer’s viewpointGood for rough surfaces without specular highlights
where
and
are normalized
l
n
θ
Note:
final_color
diffuse
has R, G, B
scalar
3 parts (R, G, B)
Jeff Chastine
21Slide22
Lambertian
ReFlectance(diffuse Component)
Technically, it should be:
l
n
θ
Jeff Chastine
22Slide23
BLINN-PHONG Reflection
(Specular Component)
Describes the specular highlight and is
dependent on viewpoint
vAlso describes a “half-vector” h that is halfway between v and l
l
n
r
θ
θ
v
h
Jeff Chastine
23Slide24
BLINN-PHONG Reflection
(Specular Component)
-
which is really
Blinn’s contribution to the original Phong model
l
n
r
θ
θ
v
h
Note: vectors should be normalized
Jeff Chastine
24Slide25
BLINN-PHONG Reflection
(Specular Component)
Our final specular equation is:
l
n
r
θ
θ
v
h
Jeff Chastine
25Slide26
Determining
Realize that
will always be < 1.0, so raising it to a power will make it smaller
is the “shininess” factor
It relates to the size of the specular highlight
s
= ~1
s
= ~30
s
= ~255
Jeff Chastine
26
Slide27
Ambient and Emit Components
Ambient:
Used to simulate light bouncing around the environment (global illumination)
Real world is far too complex for real
time, so just add a little light!Emit:Used to make the object “glow”Does not emit light!!!Both:Independent of viewpointSuper easy to calculate
Jeff Chastine
27Slide28
Final Color
To determine the final color (excluding textures) we sum up all components:
http://en.wikipedia.org/wiki/Phong_reflection_model
final_color
diffuse
final_color
specular
final_colorambientfinal_color
emit
final_color
+
Jeff Chastine
28Slide29
What about Multiple lights?
Calculate final colors and sum them all together
Assuming results are in
f
[ ] and there are count number of lights
Jeff Chastine
29Slide30
Common Kinds of Lights
Point light
Directional Light
Spot Light
Area LightInteresting fact:Lights cannot be seen!Only their effectsWe can light per vertex (fast) or per fragment (slower)Jeff Chastine30Slide31
Point Lights
These lights have a position in 3D space
Sometimes called a “Lamp”
Light emanates from the light in all directions
Distance
d determines brightness (“attenuation”):
Here, per
fragment
lighting used
Jeff Chastine
31Slide32
Point Lights
These lights have a position in 3D space
Sometimes called a “Lamp”
Light emanates from the light in all directions
Distance
d determines brightness (“attenuation”):
Here, per
vertex
lighting used
Jeff Chastine
32Slide33
Directional Lights
Are infinitely far away
position in NO WAY matters
Have only
directionAll objects are lit evenlySometimes called a “Sun”
Jeff Chastine
33Slide34
Spotlights
Point light source
Conical in shape
Jeff Chastine
34Slide35
Spotlights
Point light source
Conical in shape
Have:
An inner and outer cone angleUmbra – areas that are fully in shadowPenumbra – areas that are in partial shadowNote: There’s an ambient light
Jeff Chastine
35Slide36
Area Lights
A “surface” lights objects
Has a position and direction
Provides for a smoother drop off than point
Larger surface == smoother shadowsExpensive to calculate
Jeff Chastine
36Slide37
What you’ll see if you don’t
glEnable
(GL_LIGHTING)
The End!