Document Sample
alpha Powered By Docstoc
					Coordinate Systems
          Coordinate Systems
        (conventional Cartesian
           reference system)

            X           Z
 Transformation occurs                 Scale
  about the origin of the   Translate
  coordinate system’s

Order of Transformations Make a

Box centered at   Rotate about Z 45;    Translate along X 1;
origin            Translate along X 1   Rotate about Z 45
Hierarchy of Coordinate Systems
                       Local coordinate system

  Also called:
   – Scene graphs
   – Tree structures
    The Camera
  Parallel Projection

Perspective Projection
  The Camera
                   Near Clipping
                      Plane             Far Clipping
Projection Plane                           Plane

                                   View Volume
Rendering Pipeline

  Modelling     Transform       Visibility

                            Illumination +

                        Color            Realism
Polygons, Meshes & Scan Conversion


                                 Scan line

Approximating Curved Surfaces
with Flat Polygons
               Flat Shading – each
               polygon face has a
               normal that is used to
               perform lighting
Gouraud Shading
                     Compute vertex normals
                      by averaging face
                     Compute intensity at each

                  I1,2   I1,2,3,4   I1,3   Scan line

Illumination / Shading
 Distinction between illumination and
 shading models
  – illumination - calculate intensity at a
    point on surface
  – shading - uses calculated intensities to
    shade polygons (uses illumination models)
 we’ll review the important models
Illumination / Shading
 We’ll talk more about concepts that
 lead to realism:
  – global illumination:
     • ray tracing + radiosity
  – “special effects/tricks”:
     • shadows, texture maps, bump maps, anti-
       aliasing, transparency, reflection maps,
Local Illumination
 Local vs. global illumination models
   – local (typically) - how is one point of the
     scene illuminated directly by the light
     • is light source only source of illumination?
     • Simple models lump the rest into a single
       ambient term
     • do not account for reflections within the
Local Illumination
 Local vs. global illumination models
   – global - illuminates the whole scene
     • typically makes use of local illumination
     • incorporates inter-reflectance of objects
 Ambient – basic, even
  illumination of all objects in a
 Directional – all light rays are
  in parallel in 1 direction - like
  the sun
 Point – all light rays emanate
  from a central point in all
  directions – like a light bulb
 Spot – point light with a limited
  cone and a fall-off in intensity –
  like a flashlight
                               Penumbra angle
                           (light starts to drop off
                                to zero here)
Light Effects
                               Usually only considering
  reflected        Light         reflected part

Light=refl.+absorbed+trans.   Light=ambient+diffuse+specular

                               I  ka I a  kd I d  ks I s
Ambient Light
 is the light in the environment evenly reaching all
  surfaces from all directions
 light location doesn’t matter
 eye position doesn’t matter

 IA: ambient light
                       I  ka I a
 ka: material’s ambient reflection coefficient
Ambient Light

 IA: ambient light
                      I  ka I a
 ka: material’s ambient reflection coefficient

 Models general level of brightness in the scene
 Accounts for light effects that are difficult to
  compute (secondary diffuse reflections, etc)
Ambient Light Example
Diffuse Light
 Light absorbed by the surface and then reflected
  equally to all directions
 Models dullness, roughness of a surface
Lambert’s Law:       I  kd I d cos      N
(perfectly diffuse
     surface)          kd I d N  L        f   L

 Id: intensity of light source
 kd: material’s diffuse reflection coefficient
 N: normal vector (normalized)
 L: light source vector (normalized)
Diffuse Light
Diffuse Lighting Example
Specular Light
 Light that is reflected from the surface unequally
  to all directions
 Models reflections on shiny surfaces
         Phong’s Law:                               Light
        I  k s I s cos 
                                     Eye   R
                                              ff   L
           k d I d E  R 

    R              R             R

          n=inf.       n=large       n=small
Specular light example
   Specular light calculation

  The effect of ‘n’ in the phong model

n = 10                 n = 90

n = 30                n = 270
Depth Cueing/Illumination
 Theory - illumination fall-off with square of
    distance 1/d2
   doesn’t give good results
   often a factor of 1/d or 1/(d+c) is used
   a way to simulate fog - linear fade …
   use start s and end e fade distances
   d = distance from viewer:
              I  I0                          for d  s
                  (e  d )      (d  s)
                          I0           If   for s  d  e
                  (e  s )      (e  s )
                 If                          for d  e
Depth Cueing/Illumination
Shading a Polygon
 Illumination Model: determine the color of a
    surface (data) point by simulating some light
   Local IM: deals only with isolated surface (data)
    point and direct light sources.
   Global IM: takes into account the relationships
    between all surfaces (points) in the environment.
   Shading Model: applies the illumination models at a
    set of points and colors the whole scene.
   Texture Mapping: remappes and avgs. any value
    above (diffuse) from a 2d picture or map
Shading Polyhedra
 Flat (facet) shading:
   – Works well for objects
     really made of flat faces.
   – Appearance depends on
     number of polygons for
     curved surface objects.
 If polyhedral model is an approximation
  then need to smooth.
Interpolated shading.
 Wylie, Romney, Evans and Erdahl pioneered
  linear interpolation of shading information from
  the vertices.
 Gouraud generalized this to arbitrary polygons.
 Interpolate illumination in same manner as we
  interpolated z for z-buffering.
   – Not physically correct for illumination.
 Assumption of polygon approximating a curved
  surface gives rise to largest error.
Gouraud shading
      Diffuse Reflection (Lambertian Lighting Model)
The greater the angle between the normal and the vector from
the point to the light source, the less light is reflected. Most light
is reflected when the angle is 0 degrees, none is reflected at 90
Specular Reflection (Phong Lighting Model)
                          •   Maximum specular reflectance occurs
                              when the viewpoint is along the path
                              of the perfectly reflected ray (when
                              alpha is zero).
                          •   Specular reflectance falls off quickly
                              as alpha increases.
                          •   Falloff approximated by cosn(alpha).
                          •   n varies from 1 to several hundred,
                              depending on the material being
                          •   1 provides broad, gentle falloff
                          •   Higher values simulate sharp, focused
                          •   For perfect reflector, n would be
           Small n   Large n
Shading - efficiently
 Constant Shading:
 compute illumination at one point of the primitive
    (e.g. surface) and apply it for the whole primitive.
   Interpolated Shading:
   compute illumination at borders (e.g. vertices) of
    the primitive and interpolate the color
   Accurate Shading:
   compute illumination at every point of the primitive
                          a         I3
                        Ii           I ib
                             Ii, j
             I1                      I2
Flat Shading
 Polygon meshes approximate smooth curved
  surfaces with planar facets. Using the previous
  methods does not generate an illusion of smooth
  curved surface.
                    N1      N2

 Reason: discontinuity of the normal vectors.
Gouraud Shading
 Assign vertex the normal of the smooth surface.
 Average the normal of all neighboring polygons

                    N1       N2

 Interpolate colors along edges and scan-lines
Gouraud Shading

  Flat Shading   Gouraud Shading
Phong Shading
 Gouraud Shading does not properly handle specular

 Reason: Colors are interpolated
 Solution:
   – Compute averaged normal at vertices (Gouraud)
   – Interpolate normals along edges and scan lines!
   – Apply illumination model at every pixel
Phong Shading

    Gouraud Shading

                      Phong Shading
 Describe color variation in interior of 3D polygon
   – When scan converting a polygon, vary pixel colors according to
     values fetched from a texture

                          Surface                  Image

                                                        Angel Figure 9.3
Surface Textures
 Add visual detail to surfaces of 3D objects

                          With surface texture

  Polygonal model
Surface Textures
 Add visual detail to surfaces of 3D objects

            +                  =
 geometry           image           texture map

• Q: How do we decide where on the geometry
      each color from the image should go?
Option: Varieties of projections
    Texture Mapping
     Steps:
          – Define texture
          – Specify mapping from texture to surface
          – Lookup texture values during scan conversion


t                                          (1,0)   y
      s                                u               x

      Texture             Modeling                       Image
     Coordinate           Coordinate                   Coordinate
      System               System                       System
    Texture Mapping
     When scan convert, map from …
      – image coordinate system (x,y) to
      – modeling coordinate system (u,v) to
      – texture image (t,s)(0,1)

t                                     (1,0)   y
     s                            u               x

      Texture         Modeling                      Image
     Coordinate       Coordinate                  Coordinate
      System           System                      System
   Texture Mapping
 Scan conversion
   – Interpolate texture coordinates down/across scan lines
   – Distortion due to bilinear interpolation approximation
Texture Filtering
 Aliasing is a problem

   Point sampling         Area filtering

                                   Angel Figure 9.5
Texture Filtering
 Size of filter depends on projective warp
   – Can prefiltering images

   Magnification              Minification

                                      Angel Figure 9.14
Mip Maps
 Keep textures prefiltered at multiple resolutions
   – For each pixel, linearly interpolate between
     two closest levels (e.g., trilinear filtering)
   – Fast, easy for hardware
What is a Texture?
 MAP surface detail from a predefined (easy
  table (“texture”) to a simple polygon

 Color
 specular ‘color’ (environment map)
 normal vector perturbation (bump
 map)
 displacement mapping
 transparency
 ...
Bump Mapping
 Modifies the direction of the surface normal.
Texture and Bump Mapping
 Diffuse and normal remapping
Displacement Mapping
 Modifies the surface position in the direction of
  the surface normal.

Shared By: