Lighting and Shading
Lighting and Shading
Lighting and Shading
•Lighting
•Lighting models
•Ambient
•Diffuse
•Specular
•Surface Rendering Methods
•Ray-Tracing
What we know
• Two components:
– Lighting Model or
Shading Model - how
we calculate the intensity
at a point on the surface
– Surface Rendering
Method - How we
calculate the intensity at
each pixel
Jargon
• Illumination - the transport of light from a source
to a point via direct and indirect paths
• Lighting - computing the luminous intensity for a
specified 3D point, given a viewpoint
• Shading - assigning colors to pixels
• Illumination Models:
– Empirical - approximations to observed light
properties
– Physically based - applying physics properties
of light and its interactions with matter
The lighting problem…
• What are we trying to
solve?
• Global illumination – the
transport of light within a
scene.
• What factors play a part in
how an object is “lit”?
• Let’s examine different
items here…
Two components
http://graphics.lcs.mit.edu/classes/6.837/F98/
Lecture18/Slide11.html
Specular Reflection
V
Different for shiny vs. dull objects
Snell’s Law is for IDEAL surfaces
V
Phong Model
Phong Reflection Model
• An approximation is sets the intensity of specular
reflection proportional to (cos )shininess
• What are the possible values of cos ?
• What does the value of shininess mean?
• How do we represent shinny or dull surfaces using
the Phong model?
• What is the real thing we probably SHOULD do?
• Ispecular = ksIlight (cos )shininess = ksIlight (V.R)shininess
Effect of the shininess value
How do we compute R?
• N*(N.L)
• R+L=2N(N.L) L
• R = 2N(N.L)-L
N R
N(N.L)
V
L
L V
H
L V
I specular k s I light _ specularity N H
shininess Simplify this
• Instead of R, we
compute halfway
between L and V. H
V
L
Let’s compare the two
R 2 N ( N L) L
I specular k s I light _ specularity V R
shininess
L V H
H
L V
I specular k s I light _ specularity N H
shininess
N R
Q: Which vectors stay
constant when viewpoint V
is far away? L
lights1
lights 1
lights 1
N
R
L
V
Attenuation
1
f d min1,
2
a0 a1d a2 d
Full Illumination Model
lights1
1
f d min1,
2
a0 a1d a2 d
Run demo
Putting Lights in OpenGL
• 1. glEnable(GL_LIGHTING);
• 2. Set up Light properties
– glLightf(…)
• 3. Set up Material properties
– glMaterial(…)
Shading
lights1