Document Sample

CS430
Computer Graphics

Chi-Cheng Lin, Winona State University
Topics

 Introduction
 Geometric Model in Lighting
 Colored Surfaces and Lights

2
Introduction

   Lighting
Process of computing the luminous
intensity reflected from a specific 3-D point
Process of assigning colors to pixels
   Shading model dictates how light is
scattered or reflected from a surface
We will begin with achromatic light then
colored lights
3
Introduction

   Two types of light sources
Point light source
Ambient light
   Light interacts surfaces in different ways
Absorbed by surface
Reflected by surface
Transmitted into the interior
   What absorbs all of the incident
achromatic light?
4
Introduction
   Types of reflection of incident light
Diffuse scattering
Some of the incident light penetrates the
surface slightly and is re-radiated uniformly in all
directions
Scattering light interacts strongly with surface
 color is affected by nature of surface material
Specular reflections
Incident light does not penetrate the surface
Reflected directly from the surface
More mirror like and highly directional
Highlight, shiny, plastic like                         5
Introduction

   Total light reflected from the surface in
a certain direction is the sum of
Diffuse components
Specular components
   We calculate the size of each
component that reaches the eye for
each point of interest on surfaces

6
Geometric Model in Lighting

   Principle vectors to find amount of light
reaching the eye from a point P
m: normal vector of surface at P
v: from P to the eye
m
s: from P to light source
eye
Angles between vectors are s           v
P
calculated in the world
coordinates
 Is:   intensity of light source
7
Diffuse Component
 Id:   intensity of the diffused component
Scattering is uniform in all directions
Independent of v
unless m  v  0, where Id = 0 (why?)
   Lambert’s law: brightness is proportional
to the area subtended (= fraction cos())
  0: brightness varies slightly with angle
  90°: brightness falls rapidly to 0
m
s

                                       8
Diffuse Component

            s ˆ
cos() = ˆ  m
 Id    I s d max((ˆ  m),0),
s ˆ
where d  diffuse reflection coefficien t
 How do we calculate/obtain the value
for d ? By experiments.

9
Specular Reflection
 Isp:intensity of specular reflection
 Phong model is used to approximate
highlight
Amount of light reflected is greatest in the
direction of perfect mirror reflection, r
Amount of light reflected diminished
rapidly at the nearby angles
Beam pattern               m         r

s
P                   10
Specular Reflection
                          ˆ ˆ
Remember r  s  2(s  m)m ?
 Amount of light reflected falls off as 
increases and is approximately cosf(),
where f is the Phong exponent
 I sp    I s s (ˆ  v)f ,
r ˆ
where s  specular reflection coefficien t
m           r

s              eye
v

   Problem: expensive to compute as r
has to be found and normalized                 11
Specular Reflection
   Solution (proposed by Jim Blinn)
Calculate h = s + v
Let  be the angle between h and m
Use  to calculate the falloff of specular
intensity as  has the same property as 
  , but can be compensated by different
value of f        m h          =0 m =h
s               s    v


v

                      ˆ ˆ
I sp  I s s max((h  m)f ,0)                12
Ambient Light

   A uniform background glow in the
environment
Source is not situated at any particular place
Light spreads uniformly in all directions
 Ia:intensity of light source
 Iaa is added to the light reaching the eye
a: ambient reflection coefficient
a is often the same as d

13
Combining Light Contributions
   I = Ia a + Id d  lambert + Isp s  phongf
lambert = max(( ˆ  m),0)
s ˆ
ˆ ˆ
phong = max((h  m),0)
   Implications for different points P on a facet
Ambient is not changed for different P
m is the same for all point on the facet
If the light is far far away, s will change slightly
as P changes  diffuse will change slightly on
different P
If the light or/and eye is/are close, s and h will
change a lot as P changes  specular changes
significantly over the facet                         14
Colored Surfaces and Lights

   Colored surface
Ir = Iar ar + Idr dr  lambert + Ispr sr  phongf
Ig = Iag ag + Idg dg  lambert + Ispg sg  phongf
Ib = Iab ab + Idb db  lambert + Ispb sb  phongf
 lambert and phong terms do not depends on
color component
 We have to define 9 reflection coefficients
Ambient and diffuse reflection are based on the
color of surface
15
Colored Surfaces and Lights
   Colored light (Isr, Isg, Isb)
If the color of a surface is (r, g, b), then it is
reasonable to set
(ar, ag, ab) = (dr, dg, db) = (rK, gK, bK),
where K is the fraction of light reflected
The diffusion of the surface =
(Isrdr, Isgdg, Isbdb) = (IsrrK, IsggK, IsbbK)
   Example: white light
Isr = Isg = Isb = I, (r, g, b) = (0.3, 0.45, 0.25)
then diffusion = (0.3IK, 0.45IK, 0.25IK) 
the surface is seen as its color                     16
Colored Surfaces and Lights

   Color of specular light
Often the same as that of light source
   Example: sunlight
Highlight on plastic caused by sunlight is
white
Set (sr, sg, sb) = (s, s, s)
s = 0.5  slightly shiny
s = 0.9  highly shiny
   Different coefficients are selected for
specific materials. (Fig 8.17)                17
18

 Vertices are sent down the pipeline
along with their associated normals
 All shading calculations are done on
vertices
v 1 , m1
v2, m2            VM       projection
clip   viewport
matrix             matrix

v 0 , m0          shading is
applied here

19

 Lights are objects and the positions of
light sources are also transformed by
the modelview matrix
 After all quantities are expressed in
camera coordinates, colors are attached
to vertices using the formula
 If an object is clipped, normals of newly
generated vertices are calculated by
interpolation
20

   Polygonal face in 3D space
Individual face
Underlying surface approximated

21

22

   Entire face is drawn with the same color
   Lateral inhibition
When there is a discontinuity across an
object, the eye manufactures a Mach band
at the discontinuity and a vivid edge is seen
   Specular highlights are rendered poorly
Either no highlight at all
Or highlight on the entire face

23

 Smooth shading computes colors at more
points on each face to de-emphasize
 Use linear interpolation
Interpolate vertex colors
Interpolate vertex normals
Interpolate normal for each pixel
24

 Used by OpenGL                          color3
 Example
colora: by interpolating
color2
color3 and color4 colora             colorb
colorb: by interpolating color
4
color1 and color2             color1

Colors of pixels on the horizontal line
segment is obtained by interpolating
colora and colorb
   Does not picture highlights well                       25
 Compute normal at each pixel by
interpolating the normals at the vertices
 Apply the shading model to to every
point to find the color
 Example                              m3
ma: by interpolating m3 and m4
mb: by interpolating m1 and m2
m2
Normals of pixels on the        ma        mb
horizontal line segment is      m4
m1
obtained by interpolating ma and mb
Colors of the pixels are then computed      26
 Very smooth appearance
 Highlights are approximated better
 Principle drawback
Heavy computation  slow speed
   Not supported by OpenGL
Can be approximated using texture
mapping

Don’t be
confused!!
   Phong shading  Phong model                    27

DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 0 posted: 5/3/2013 language: Unknown pages: 27