Illumination and Shading - PowerPoint PPT Presentation

1 / 43
About This Presentation
Title:

Illumination and Shading

Description:

Points in a scene. points are the smallest units of our scene: can think of them having no area or ... Instead use fatt = min(1 / c1 c2dL c3 (dL)2, 1) ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 44
Provided by: chaitr
Category:

less

Transcript and Presenter's Notes

Title: Illumination and Shading


1
Illumination and Shading
2
  • Sampling a scene
  • ideally, need to consider light coming to the
    viewer from each point on each surface in a scene
  • Points in a scene
  • points are the smallest units of our scene can
    think of them having no area or infinitesimal
    area
  • there are an infinite number of visible points
    mathematically intractable
  • Surface elements
  • only consider a finite number of differential
    pieces of surface
  • figure out how much light comes to the viewer
    from each of these pieces of surface

3
Global/local Illumination
  • Lights and Shadows
  • most light striking a surface element comes
    directly from emissive light sources in the scene
    (direct illumination)
  • sometimes light from source is blocked by other
    objects
  • surface element is then in shadow from that
    light source
  • Inter-Object Reflection
  • light bounces off other objects toward our
    surface element
  • when that light reaches our surface element, it
    brightens it (indirect illumination)
  • Global Illumination simulates what happens when
    other objects affect the light reaching a surface
    element
  • Local Illumination does not worry about this.

from Pixars Luxo Jr.
object
eye
direct illumination
indirect illumination
light
light
object
object
4
BRDFs
  • In general, behavior of light is simulated by
    bi-directional reflectance distribution functions
    (BRDFs)
  • Lambertian and Phong approximations model simple
    BRDF
  • given incoming light ray at surface point, BRDF
    is used
    to calculate how much of that light ray will be
    reflected in
    a particular outgoing
    direction (function of incoming and

    outgoing angles)
  • can be obtained from analytical model
  • or measurements of actual surfaces

5
Illumination and Shading
  • Illumination (Lighting) model
  • Expresses the factors determining a surfaces
    color at a given point (defines the nature of the
    light emanating from a source geometry of light
    distribution, etc.)
  • Shading Model
  • Determines where the illumination model is
    applied and the arguments it receives
  • Some shading models invoke an illumination model
    for each pixel others invoke an illumination
    model for selected points, shading the rest by
    interpolation
  • Reflection models calculate light intensity at a
    given point.

6
Graphics A Hack!
Caveat Most illumination models used in
graphics (especially in interactive 3D graphics
h/w) are approximations picked for efficiency not
accuracy- they are not physically based) An
important reseach goal develop modelsefficient
and physically correct The intensity and
wavelength of light reflected from a surface
depends on the incident wavelength, angle of
incidence, nature (roughness) of the surface
material, and its electrical properties
(permissivity, permeability and conductivity).
(road example when driving, incidence direction
changes..also for copper, color change happens
with change of incidence)
7
  • Light energy is simply sum of all contributions
  • Each term can be calculated separately and later
    added together
  • multiple light sources
  • multiple interactions (diffuse, specular, more
    later)
  • multiple colors (R-G-B, or per wavelength)

8
Illumination Models
  • Local Illumination
  • Defines single light and single surface
    interaction
  • Global Illumination
  • Defines interchange of lights between all
    surfaces

Incident flux
Reflected flux
?i
?r
Transmitted flux
Absorbed flux
?t
9
Local illumination models
diffuse
Specular
Traditional graphics LIMs are Fast to
compute Heuristic and incomplete
(incomplete) Most interested in light in
direction of viewpoint
10
Local illumination models
  • Most such adhoc illumination models have three
    components
  • I ambient diffuse specular
  • The ambient term allows for some global control
    of brightness in a scene. Typically,
  • I Ia Ka
  • Where Ia is an ambient illumination constant
    defined once the entire scene and ka is an
    ambient reflection coefficient, usually
    restricted to lie in 0,1

11
Reflection Characteristics of Surfaces
Illumination model
  • Components of a simple ( non- physically based)
    illumination model
  • Ambient reflection
  • Diffuse reflection
  • Specular reflection
  • Ambient reflection
  • Independent of object position and viewer
    position
  • Constant
  • Exists in most environments some light hits
    surface from all directions a way of
    approximating contributions from indirect
    lighting

12
Reflection characteristics of surfaces
  • Ambient reflection (continued)
  • A total hack, but images without some form of
    ambient lighting look stark
  • I Ia Ka
  • Ia Intensity of ambient light
  • Ka Fraction reflected, 0lt Kalt1
  • Diffuse (Lambertian) reflection
  • Typical of dull matte surfaces
  • Independent of viewer position
  • Dependant of light source position (in this case
    a point source again a non-physical abstraction)

13
Diffuse reflection
I Sin (?)
?N
I Cos (?)
?
?L
Lamberts Cosine Law I Ipkd cos ? I Ip
kd (?N . ?L ) Ip intensity of the point
light source kd diffuse reflection
coefficient specifies fraction of Ip
reflected Add an ambient term I Ia Ka Ip kd
(?N . ?L )
14
Specular Reflection
  • Specular reflection
  • Typical of bright and shiny surfaces
  • Color depends on material and how it scatters
    light energy
  • In plastics it is color of point source and in
    metal its the color of metal
  • In other materials will combine color of light
    source and color of material
  • Dependant on light source position and viewer
    position
  • The assumption is often made that the specular
    highlights are determined by the color of the
    light source, not the material, e.g.,  ksR ksG
    ksB 1.0 This is true of plastic which is why
    many computer graphics images appear to be
    plastic.

15
Specular Reflection
Direction of reflection
  • Early model by Phong neglected effect of material
    color on specular highlight made all surfaces
    look plastic
  • For perfect reflector, see light iff a 0
  • For real reflector , reflected light falls off as
    a increases

?N
To Point light Source
?R
?L
Direction of ViewPoint
a
?V
?
?
16
Reflection characteristics of surfaces
  • Specular reflection (cont)
  • Phong approximation cosn a
  • As n increases , highlight is more concentrated,
    surface appears glossier

17
Calculating the reflection vector
  • ?R 2?N (?N. ?L) - ?L
  • ?R . ?V (2?N (?N. ?L - L). ?V

?N
?S
?S
?Ncos ?
?L
?R
?
?
18
The Halfway Vector
  • Consider the unit vector halfway between l and v
  • h (lv)/lv
  • If we use nh rather
  • than rv, we avoid
  • calculation of r
  • xtheta-psi
  • thetapsi x phi
  • (if the normal to the surface were oriented along
    h, the viewer would see the brightest specular
    light)
  • (psi is half of phi if all vectors are co-planar)

19
Modified Phong Model
  • The use of the halfway vector was first suggested
    by Blinn
  • The resulting lighting model is known as the
    Blinn or modified Phong model
  • OpenGL default is the modified Phong model

20
Example
Only differences in these teapots are the
parameters in the Phong model
21
Dot products
N
If N.L is ve, the light is behind the surface,
and so cannot illuminate it.
L
If N.V is ve, the viewer is beneath the
surface, and so cannot see the illumination.
(both cases, illumination set to
zero)
N
V
22
Light Sources
  • In the Phong Model, we add the results from each
    light source
  • Each light source has separate diffuse, specular,
    and ambient terms to allow for maximum
    flexibility even though this form does not have a
    physical justification
  • Separate red, green and blue components
  • Hence, 9 coefficients for each point source
  • Idr, Idg, Idb, Isr, Isg, Isb, Iar, Iag, Iab

23
Material Properties
  • Material properties match light source properties
  • Nine absorbtion coefficients
  • kdr, kdg, kdb, ksr, ksg, ksb, kar, kag, kab
  • Shininess coefficient a (n)

24
(No Transcript)
25
Polygon Mesh Shading
  • Use any illumination model
  • Three shading methods each treats a single
    polygon independent of all others ( a huge
    oversimplification really want global
    illumintaion , e.g. for shadows)
  • Constant
  • Gouraud ( intensity Interpolation)
  • Phong ( Normal Vector Interpolation)

26
How good is Phong Model?
27
Flat vs. Gouraud Shading
glShadeModel(GL_FLAT)
glShadeModel(GL_SMOOTH)
28
Constant Shading
  • Single Intensity value per polygon
  • If Polygon mesh is an approximation to curved
    surface, faceted look is a problem
  • Facets are exaggerated by mach band effect

Intensity
Intensity
  • Actual
  • --Perceived

Distance along surface
Distance along surface
29
  • Mach band effect discrepancies between actual
    and perceived intensities due to bilateral
    inhibition
  • A photoreceptor in the eye responds to light
    according to the intensity of the light falling
    on it minus the activation of its neighbors

Mach banding applet http//www.nbb.cornell.edu/n
eurobio/land/OldStudentProjects/cs490-96to97/anson
/MachBandingApplet/
30
Gouraud Shading
  • Use for polygon approximations to curved surfaces
  • Linear Interpolation of intensity along scan
    Lines
  • Eliminates intensity discontinuities polygon
    edges still have gradient discontinuities, so
    mach banding is improved but not eliminated
  • Must differentiate real ( desired) creases from
    those induced by polygonal approximations (e.g,
    shared edges of a cuboid vs edges in polygonized
    sphere)
  • Step 1
  • Calculate bogus vertex normals as average of
    surrounding polygons normals

31
Gouraud Shading
  • Nv (?N1 ?N2 ?N3 ?N4)/ ?N1 ?N2 ?N3
    ?N4
  • Since neighboring polygons sharing vertices and
    edges are approximations to smoothly curved
    surfaces and wont have greatly differing surface
    normals, this approximation is a reasonable one

?N1
?Nv
?N2
?N4
?N3
32
Gouraud Shading
  • Step 2
  • Interpolate intensity along polygon edges
  • Step 3
  • Interpolate along scan Lines

I1
Y1
YS
Ip
Y2
I2
I3
Y3
Ia I1 (Ys-y2)/(y1-y2) I2 (y1-ys )/(y1-y2)
Ib I1 (Ys-y3)/(y1-y3) I3 (y1-ys)
/(y1-y3) Ip Ia (xb-xp)/(xb-xa) Ib (xp-xa)
/(xb-xa)
33
Gouraud Shading
  • Gouraud vs constant shading
  • Integrates nicely with scan line algorithm
  • ?I / ?y is constant along polygon edge

Surface
Intensity
Constant Gouraud -----
34
What Gouraud shading misses
  • Gouraud shading can miss specular highlights in
    specular objects because it interpolates vertex
    colors instead of vertex normals

Here ?Na ?Nb would cause no appreciable
specular component whereas ?Nc would. Shading by
interpolating between Ia and Ib therefore misses
the highlight that evaluating I at C would
catch Interpolating the normal comes closer to
what actual normal of the surface being
polygonally approximated would be Also, if I at
Na or Nb is zero due to the N.L or N.V being
negative, we will loose highlight in the
in-between.
?Nc
?Na
?Nb
Ia
Ib
I
Gouraud
Ib
Ia
Highlight missed by Gouraud
Phong
35
Phong Shading
  • Also called normal vector interpolation
  • Interpolate ?N rather than I
  • Especially important with specular reflection
  • Computationally expensive at each pixel to
  • Recompute ?N ----- must normalize , requiring
    expensive square root
  • Recompute I?
  • Bishop and Weimer developed fast approximation
    using taylor series expansion ( in SIGGRAPH 86)

36
Comparing Shading Models
Flat or Faceted Shading Constant intensity over
each face
Gouraud Shading Interpolation of intensity
across triangles to eliminate edge discontinuity
Pixar Shutterbug images from
www.siggraph.org/education/materials/HyperGraph/s
canline/shade_models/shading.htm
37
Comparing Shading Models (contd.)
Phong Shading Interpolation of surface
normals. Note specular highlights but no shadows
pure local illumination model
Global Illumination Global illumination model
with texture, bump, and reflection mapping
38
  • Should also model inverse square law energy
    density fall off
  • I Ia ka fatt (Ip kd)(?N. ?L), where
    fatt 1 / (dL)2
  • dL path length from light to object to
    viewer
  • This makes surfaces with equal kd(?N. ?L) differ
    in appearance important if overlap

?N
?N
39
  • Formula often creates harsh effects we do not
    often see objects illuminated by point lights
  • Instead use fatt min(1 / c1 c2dL c3 (dL)2,
    1)
  • Where c1 , c2 and c3 are user defined constants
  • This is a heuristic!

40
Refractive Transparency
  • Modeling refracted light complicates matters!

UnRefracted (Geometrical) line of sight
Refracted (optical) line of sight
?t
Transparent object
?i
Line of sight
41
Snells Law
  • sin ?t sin ?i ?i? / ?t?
  • ?i? and ?t? are indices of refraction of the two
    media

Medium 1
Medium 2
42
Non refractive transparency
  • Opacity of a surface is a measure of how much
    light penetrates through that surface.
  • Opacity of 1 corresponds to a completely opaque
    surface that blocks all light incident on it.
  • Surface with opacity of 0 is transparent all
    light passes through it.
  • Transparency, transmittance, or translucency of a
    surface is 1-opacity.

43
Non refractive transparency
  • For partially transparent polygon
  • I? (1- kt1) I ?1 kt1 I?2
  • kt1 transmittance of polygon 1
  • I ?1- intensity calculated for polygon
    1
  • I?2 intensity calculated for polygon
    2

Most opaque Opacity1 Transmittance0
Polygon 1
Polygon 2
Write a Comment
User Comments (0)
About PowerShow.com