Illumination and Shading (PowerPoint)

Document Sample
Illumination and Shading (PowerPoint) Powered By Docstoc
					Illumination
        and Shading
    Illumination and Shading
   Given: scene specification (object positions,
                 optical properties of the surface,
    viewer       position, viewing direction, ……)
   Find: intensity for each pixel
                                   light
viewer        image
              plane
     Illumination Models
          (lighting model, shading model)

   Rendering needs a model for how light interacts
    with objects.
   Physically correct model: the intensity reflected
    from every point depends on the intensity from
    every other points
        – global illumination
   Simplistic model: the intensity depends only on
    the direct illumination due to light sources
        – local illumination
Light Sources
 light-emitting sources
 self-luminosity

          : the resulting intensity
          : the object’s intrinsic intensity
 - point sources
 - distributed sources
 light-reflecting sources
    Reflection Models
 : describe the way incident light reflects from a
   surface
 : ambient, diffuse, specular reflection
This model is known as:
       - a shading model
       - a lighting model
       - a light reflection model
       - a local illumination model
       - Phong illumination model
       - a reflectance model
  Ambient Light(주변광)
: multiple reflection of nearby objects (light-reflecting
   sources) yields a uniform illumination
: ambient illumination is constant for an object, without
   regard to directions of faces


      : the incident ambient intensity
      : ambient reflection coefficient,
        the proportion reflected away from the surface
   Wavelength dependence
   and     are function over all wavelengths   .
Ideally, we need


Calculate RGB component separately:
Diffuse Reflection(난반사)
    matte (dull) surfaces diffuse incident light
     uniformly to every direction
    (light intensity is independent of angle of
     reflection)
    light intensity depends on angle of incidence
    Diffuse Reflection

        N
L                : the intensity of the light source

                 : diffuse reflection coefficient,

                 : the surface normal (unit vector)

                 : the direction of light source,
                          (unit vector)
Light-source attenuation
:the energy falls off as the distance the light travels




  for user-supplied constants      ,     ,    .
   Specular Reflection
: perfect reflector reflects all lights to the
   direction where angle of reflection is
   identical to the angle of incidence. It
   accounts for the highlight.
: real object reflects most of light over a range
   of positions close to the direction
Specular Reflection
           N
    L                   R

                              V




note that N, L, and R are coplanar, but V may not be
  coplanar to others
   Specular Reflection                     L
                                                 N
                                                          R

For a perfect mirror reflector                                  V



For a near-perfect reflector, the highlight falls off quickly
with increasing .


       : the intensity of the incident light
       : the color-independent specular coefficient
       : a term that determines the gloss of the surface
          (larger value gives small highlight, Fig 14-14)
    Specular Reflection
  More about
       glass type: much variation as       varies.
       many opaque materials are nearly constant.
Calculating the reflection vector
                                             N
                                       L             R
                                                         V

       Thus
              where N, L : normalized unit vector
Specular reflection superimposed
on diffuse reflection
Shading Models
   Surface shading
       apply shading model to each point of
        curved surface
       approximate curved surfaces by plane
        surfaces and then shade the plane
        surfaces
   Constant shading, Gouraud shading,
    Phong shading
    Constant Shading (Flat Shading)
•   infinitely distant light source (constant        ) result in
    constant diffuse reflection
•   constant         and infinitely distant viewpoint (constant
                 ) result in constant specular reflection
•   abrupt change in surface orientation of adjacent
    surfaces produce an unrealistic effect
        Smooth shading
   Two popular methods:
       Gouraud shading (used by OpenGL)
       Phong shading (better specular highlight,
        not in OpenGL)
Normal vector of a vertex
        Gouraud Shading
       Compute vertex illumination (color) before the
        projection transformation
       Shade interior pixels: color interpolation
        (normals are not needed)

                    C1
                                             for all scanlines

Ca = lerp(C1, C2)        Cb = lerp(C1, C3)


            C2             C3
                                               * lerp: linear interpolation
                             Lerp(Ca, Cb)
         X-intersection Computation
         (revisited)
   Recall ‘x-intersection interpolation’ for polygon filling.
        Pre-computed delta value per a unit move is repeatedly added.
        Initial/starting value is computed (using similar triangles).
                                        i+1
                      m                                           1
                                          i
     y=mx+B       1                                   1/m    new-x = old-x + 1/m
                                              old-x


    y 8               (5.4,7.3)                       (1.5+?,2)
      7
                                          2
      6
      5                                          (1.5,1.6)            0.4
      4                                                                     1
                                                              ?
      3
      2
        (1.5,1.6)                         1
      1                                                 1/m
             x 1 2 3 4 5 6 7
       Color Interpolation
   Color interpolation is achieved basically through the same mechanism.
                           (r,g,b)=(245,87,32)
      y 8                       at (5.4,7.3)
        7
                                                     (r,g,b)=(188+0.4*10,*,*)=(192,*,*)
        6
                                                                  at (*,2)
        5
             r=202+10
        4                                            2
          r=192+10
        3                                                                   0.4
        2
        1
                                                          (r,g,b)=(188,23,99)
               x 1 2 3 4 5 6 7                                 at (1.5,1.6)
                                                     1
     (r,g,b)=(188,23,99)        y = 7.3-1.6 = 5.7
          at (1.5,1.6)          r = 245-188=57
                               r/y = 57/5.7 = 10


   Recall that z-value interpolation for z-buffering has also been done in
    the same manner.
    Gouraud Shading Problem
   Lighting in the polygon interior can be
    inaccurate
        Mach band effect
         These “Mach Bands” are not physically there. Instead,
         they are illusions due to excitation and inhibition in
         our neural processing.
The bright bands
at 45 degrees
(and 135
degrees) are
illusory.
The intensity of
each square is
the same.
Mach band effect
    Phong Shading
       Surface normals are interpolated




       Shades are computed at each point using the
        interpolated normal vector
       The shading computed by Phong shading is
        C1 continuous.
         Fix the mach band effect – remove edge
          discontinuity
    Phong Shading
   Normal interpolation
                                          n1


           na = lerp(n1, n2)                   nb = lerp(n1, n3)

                               lerp(na, nb)

                n2
                                                n3

   Slow – not supported by OpenGL and
    most graphics hardware

				
DOCUMENT INFO