Illumination - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

Illumination

Description:

Flat. Gouraud. Phong ... Per polygon (flat shading): entire polygon gets the same color ... Flat Shading. Compute one normal for each polygon. Assumes light is ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 33
Provided by: pm5
Category:

less

Transcript and Presenter's Notes

Title: Illumination


1
Illumination Shading Comp 575 - Fall 2008
2
What is a Shading Model?
  • Model of how light interacts with materials
  • We will discuss the common, heuristic shading
    models
  • Flat
  • Gouraud
  • Phong
  • Not physically based work well in practice and
    are common on most graphics boards

3
Diffuse Objects
  • For matte objects with no shininess
  • Diffuse/matte objects are called Lambertian
  • Shading does not vary with viewpoint
  • Example a piece of paper, chalk board
  • Reflected light is scattered equally in all
    directions

4
Lambertian Surface
  • Obeys Lamberts Law (from physics)
  • The color, c, of a surface is proportional to
    the cosine of the angle between the surface
    normal and the direction of the light source

l
l
n
l
n
n
q
q
q
5
Lambertian Surface
  • Lamberts Law As the angle (q) between the
    surface normal (n) and the light direction (l)
    increases, the same amount of light (A) falls on
    a larger surface area (x) ? surface is dimmer
  • Diffuse color is independent of the eye position
  • As you move from the light location, you see more
    area, but the amount of light reflected at that
    angle per visible unit area of surface is
    proportionally less

6
Diffuse Lighting Model
Lets define a lighting model that captures this
Angle between light and the normal
Light color 0,1 (RGB)
Avoid negative light when q gt 90
Diffuse reflectance color fraction of light
reflected from the surface (RGB)
l
n
What happens if light source is at infinity?
7
Ambient Term
  • Lambertian model produces black for any surface
    facing away from the light
  • In reality, light bounces off walls, is scattered
    in the atmosphere, etc., so surfaces facing away
    from the light arent usually black
  • Add an ambient light term for all other light
    (a hack)
  • to ensure 0 ? c ? 1, ca cl ? (1,1,1)

8
Phong Illumination
  • What about highlights on shiny surfaces?
  • Highlight moves with eye location
  • Highlight is brightest when j is 0 c ? (cos j)p
    (v ? r)p

n
Reflected (r)
l
Viewer (v)
j
Specular Color
Phong exponent
9
Specular Highlights
10
Whats Happening to the Light
Less Shiny Surface
Dull Surface
Shiny Surface
Perfect Mirror
11
Phong Exponent
  • The exponent p controls the sharpness of the
    highlight larger p produces sharper highlight

1
p 1
p 2
p 4
p 1
(cos j)p
p 4
p 32
p 8
p 16
p 16
p 64
p 256
p 64
p 128
p 256
0
j
0
90
12
Phong Illumination Computing r
  • How can we compute the reflection vector r?

n and l are unit vectors
n
r
s
-s
l
n(nl)
Solve for s
Substitute s
13
Complete Illumination Equation
  • The complete illumination equation models
  • Ambient light
  • Diffuse reflections
  • Specular reflections
  • We can combine all of these together into a
    single equation

14
Multiple Light Sources
  • Our current equation deals with a single light
    source
  • How do we account for additional light sources?
  • Compute dot products with each light and sum them
    up.

Original Equation
Factor out cl and add N lights
15
Shadows
  • What about shadows?
  • If a point is visible from a light, illuminate
    it. If not, dont.
  • Introduce a visibility term Si for each (point,
    light) pair.
  • Si 0 if the point is not visible, Si 1 if it
    is visible

visibility term
16
Multiple Light Sources
17
RGB Colors
  • Illumination of a point on a surface
  • This equation computes one color channel
  • Since we are working in RGB space, we need to
    compute the equation once each for red, green,
    and blue
  • Also make sure you clamp all colors at 1

18
Illumination vs. Shading
  • Illumination of an entire surface is termed
    shading.
  • Expensive to compute at every visible point (but
    we can do it, if desired)
  • We have three basic options
  • Per polygon (flat shading) entire polygon gets
    the same color
  • Per vertex (Gouraud Shading) compute
    illumination at each vertex and interpolate
    vertex colors
  • Per pixel (Phong Shading) interpolate vertex
    normals and compute illumination for each pixel

19
Flat Shading
  • Compute one normal for each polygon
  • Assumes light is very distant
  • Assumes polygon exactly represents the actual
    surface, not an approximation
  • i.e. cube vs. cylinder
  • Interpolation is not used
  • Faceting occurs when used on approximating
    surfaces

20
Flat Shading
  • You get faceted images

21
Gouraud Shading
  • Compute the normal, ni, at each vertex
  • Compute color at each vertex using the
    illumination model
  • Interpolate colors across the polygon during scan
    conversion
  • Assumes the polygons
  • approximate a curved surface
  • Problems?

n0
n1
n2
22
Interpolating Colors
c1
y1
ca
cb
ys
cs
y2
c2
y3
c3
Same as interpolating z-values.
23
Computing the Normal
  • Often the polygon will come with normals
    associated with the vertices.
  • How do we compute them if they are not given?
  • First compute polygon normals for each polygon
  • Given a polygon with vertices p0, p1, and p2
    (Assume the vertices are specified in
    counter-clockwise order)
  • Compute two edge vectors, v0 and v1
  • Take the cross product between vectors
  • This gives the normal for the polygon
  • Repeat this for each polygon

n v0 x v1
p0
v1 p2 - p0
v0 p1 - p0
p2
p1
24
Computing the Normal (cont)
  • For each vertex, find all polygons that contain
    the vertex
  • for vertex v0, these are polygons p1, p2, p3, and
    p4
  • Take the average of the polygon normals
  • This gives the normal nv0 at
  • the vertex
  • Repeat this for each vertex

v3
nv0
n2
n3
p2
p0
v0
p3
p1
p4
v2
v4
n1
n4
v1
25
Shading
  • Now, with all vertex normals computed, we can
    shade using Gouraud shading
  • Where does Gouraud shading fall short?
  • Highlights on the interior of the polygon
  • How can we handle those?
  • Phong Shading

26
Phong Shading
  • Compute normal, ni, at each vertex
  • Interpolate normals during scan conversion
  • Compute color with the interpolated normals
  • More expensive illumination is computed for
    every visible pixel instead of each vertex.
  • Captures highlights in the middle of a polygon
  • Looks smoother across edges
  • In my opinion, well worth the
  • extra computation.

n0
n1
n
n2
27
(No Transcript)
28
Graphics Historical Note
  • Who were Phong and Gouraud?
  • PhD Students at the University of Utah in the 70s
  • Much of what youre learning in this class was
    discovered at Utah in the 70s.
  • For several years it was the only place to
    computer graphics research.

29
Problems with Interpolated Shading
  • Silhouettes
  • Translucent materials
  • Perspective distortion causes problems Imagine a
    polygon with 1 vertex at a very different depth
    than others
  • Interpolation considers equal steps in y, but
    foreshortening produces unequal steps in depth
  • Problem reduced by using many small polygons
  • Orientation dependence for non-triangles
  • Shared vertices on an edge

30
Potential Problems
  • If the surface normals fluctuate, the vertex
    normals may get interpolated incorrectly.

31
Silhouettes Problem
32
Cant Handle More Complicated Materials
Brushed Aluminum
Isotropic (Normal)
Satin
Velvet
Write a Comment
User Comments (0)
About PowerShow.com