SlideShare a Scribd company logo
Shading and Lighting
                                                 Why we need shading
• Shade objects so their images              • Suppose we build a model of a
  appear three-dimensional                     sphere using many polygons and
• Light-material interactions                  color it with glColor. We get
• Phong model                                  something like



                                             • But we want




                   Shading                                Scattering
• Why does the image of a real sphere look   • Light strikes A
  like                                         – Some scattered
                                               – Some absorbed
                                             • Some of scattered light strikes B
                                               – Some scattered
• Light-material interactions cause each
                                               – Some absorbed
  point to have a different color or shade
• Need to consider                           • Some of this scattered
  –   Light sources                          light strikes A
  –   Material properties                      and so on
  –   Location of viewer
  –   Surface orientation




                                                                                   1
Rendering Equation                                   Global Effects
• The infinite scattering and absorption                                           shadow
  of light can be described by the
  rendering equation
  – Cannot be solved in general
  – Ray tracing is a special case for
    perfectly reflecting surfaces
                                                                                  multiple reflection
• Rendering equation is global and                                     translucent surface
  includes
  – Shadows
  – Multiple scattering from object to object




       Ray Tracing Scene                         Local vs Global Rendering
                                                • Correct shading requires a global
                                                  calculation involving all objects and
                                                  light sources
                                                  – Incompatible with pipeline model which
                                                    shades each polygon independently
                                                    (local rendering)
                                                • However, in computer graphics,
                                                  especially real time graphics, we are
                                                  happy if things “look right”
                                                  – Exist many techniques for
                                                    approximating global effects




                                                                                                        2
Light-Material Interaction
                                                            Light Sources
• Light that strikes an object is partially
  absorbed and partially scattered              General light sources are difficult to
  (reflected) or refracted                       work with because we must integrate
• The amount reflected determines the            light coming from all points on the
  color and brightness of the object             source
  – A surface appears red under white light
    because the red component of the light is
    reflected and the rest is absorbed
• The reflected light is scattered in a
  manner that depends on the
  smoothness and orientation of the
  surface




     Simple Light Sources                                  Surface Types
• Point source                                  • The smoother a surface, the more
  – Model with position and color                 reflected light is concentrated in the
  – Distant source = infinite distance away       direction a perfect mirror would reflected
    (parallel)                                    the light
• Spotlight                                     • A very rough surface scatters light in all
                                                  directions
  – Restrict light from ideal point source
• Ambient light
  – Same amount of light everywhere in
    scene
  – Can model contribution of many sources            smooth surface        rough surface
    and reflecting surfaces




                                                                                               3
Phong Model                                       Ideal Reflector
• A simple model that can be computed               • Normal is determined by local
  rapidly
                                                      orientation
• Has three components
   – Diffuse                                        • Angle of incidence = angle of
   – Specular                                         reflection
   – Ambient                                        • The three vectors must be coplanar
• Uses four vectors                                         r = 2 (l · n ) n - l
   – To source
   – To viewer
   – Normal
   – Perfect reflector




       Lambertian Surface
• Perfectly diffuse reflector                               Specular Surfaces
• Light scattered equally in all                    • Most surfaces are neither ideal diffusers
  directions                                          nor perfectly specular (ideal reflectors)
• Amount of light reflected is                      • Smooth surfaces show specular highlights
                                                      due to incoming light being reflected in
  proportional to the vertical
                                                      directions concentrated close to the
  component of incoming light                         direction of a perfect reflection
  – reflected light ~cos θi
  – cos θi = l · n if vectors normalized
  – There are also three coefficients, kr, kb, kg
                                                                                    specular
    that show how much of each color                                                highlight
    component is reflected




                                                                                                  4
Modeling Specular
                 Reflections                                 The Shininess Coefficient
 • Phong proposed using a term that                        • Values of α between 100 and 200
   dropped off as the angle between the                      correspond to metals
   viewer and the ideal reflection                         • Values between 5 and 10 give surface that
   increased                                                 look like plastic
        Ir ~ ks I cosαφ
                                                                      cosα φ
                                                       φ
reflected          shininess coef
intensity    incoming intensity
       absorption coef
                                                                    -90         φ         90




                  Ambient Light                                       Light Sources
• Ambient light is the result of multiple                  • In the Phong Model, we add the
  interactions between (large) light                         results from each light source
  sources and the objects in the
                                                           • Each light source has separate
  environment
                                                             diffuse, specular, and ambient
• Amount and color depend on both                            terms to allow for maximum
  the color of the light(s) and the                          flexibility even though this form
  material properties of the object                          does not have a physical
• Add ka Ia to diffuse and specular                          justification
  terms                                                    • Separate red, green and blue
     reflection coef      intensity of ambient light         components




                                                                                                         5
Adding up the Components
         Material Properties                         For each light source and each color
• Hence, 9 coefficients for each point                 component, the Phong model can be
  source                                               written as
  – Idr, Idg, Idb, Isr, Isg, Isb, Iar, Iag, Iab      I =kd Id l · n + ks Is (v · r )α + ka Ia

                                                     For each color component
• Material properties match light
  source properties
                                                     we add contributions from
  – Nine absorbtion coefficients                     all sources
     • kdr, kdg, kdb, ksr, ksg, ksb, kar, kag, kab
  – Shininess coefficient α




      Modified Phong Model                                  The Halfway Vector
• The specular term in the Phong                      • h is normalized vector halfway
  model is problematic because it                       between l and v
  requires the calculation of a new                            h = ( l + v )/ | l + v |
  reflection vector and view vector for
  each vertex
• Blinn suggested an approximation
  using the halfway vector that is more
  efficient




                                                                                                6
Using the halfway angle                                                  Example
• Replace (v · r )α by (n · h )β
• β is chosen to match shineness
• Note that halfway angle is half of                    Only differences in
  angle between r and v if vectors are                  these teapots are
                                                        the parameters
  coplanar                                              in the modified
• Resulting model is known as the                       Phong model
  modified Phong or Blinn lighting
  model
    – Specified in OpenGL standard




     Computation of Vectors                                 Ray Tracing Algorithm
•  l and v are specified by the application            • References
• Can compute r from l and n                             – Glassner, Andrew (Ed.) (1989). An Introduction to Ray
                                                           Tracing. Academic Press
• Problem is determining n                               – Shirley, Peter and Morley Keith, R. (2001) Realistic Ray
• For simple surfaces n is can be determined               Tracing,2nd edition. A.K. Peters
                                                         – Free ray tracing program POV-Ray at
  but how we determine n differs depending                 http://www.povray.org
  on underlying representation of surface                – Siggraph 2005 course notes
• OpenGL leaves determination of normal to                  • Introduction to Real-Time Ray Tracing

  application                                            – Many graphics books…
    – Exception for GLU quadrics and Bezier surfaces




                                                                                                                      7

More Related Content

PPTX
Presentation3
PPT
Color Seminar
DOCX
PPT
Light the photonic storm
PPT
Light website
PPT
Presentation3
Color Seminar
Light the photonic storm
Light website

What's hot (13)

PPT
Light, Lenses & the Human Eye
PPTX
Light and the human eye 2012
PPTX
Angular magnification of mircoscope and telescope by anjali and tanishka
PPT
Physics 504 Chapter 3-4
PDF
Lecture26
PDF
Broadcast Lens Technology Part 2
PPT
Phy exppp chap12
PPTX
PPTX
Assignment #14 (p1): Photography Research And Prectice
PPT
Intr 351 1 intro to lighitng
PPTX
Refraction through lenses
PPT
PPT on refraction and lenses by pg
PPT
Sci 1010 chapter 7
Light, Lenses & the Human Eye
Light and the human eye 2012
Angular magnification of mircoscope and telescope by anjali and tanishka
Physics 504 Chapter 3-4
Lecture26
Broadcast Lens Technology Part 2
Phy exppp chap12
Assignment #14 (p1): Photography Research And Prectice
Intr 351 1 intro to lighitng
Refraction through lenses
PPT on refraction and lenses by pg
Sci 1010 chapter 7
Ad

Similar to Shading (20)

PPT
PPTX
Concept of basic illumination model
PDF
illuminationmodelsshading-200501081735 (1).pdf
PPTX
Illumination Models in graphic computer vision and Shading.pptx
PPTX
graphics_Illumenation,texrure And shading.pptx
PPTX
Lecture 1. Lighting Design.pptx
PPT
Graphics Lecture 7
PDF
3 D texturing
PPT
The nature and propagation of light
PPTX
Opticsandlight
PDF
Iluminacion
PDF
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
PPT
Color Science Seminar
PPTX
light microscopy and its components and also errors in light microscopy
PPTX
A SEMINAR TOPIC ON BASICS OF REFRACTION.pptx
PPTX
Computer vision - light
PPTX
Electrical lighting and aquatics lessons
PPTX
computergrapgichiddensurfacemethodes.pptx
PPT
Optics mirrors & lenses
PDF
LIGHT-1.pdfGHFHJGKHLIHUGUJHUKHUGKUHKGUGKHH
Concept of basic illumination model
illuminationmodelsshading-200501081735 (1).pdf
Illumination Models in graphic computer vision and Shading.pptx
graphics_Illumenation,texrure And shading.pptx
Lecture 1. Lighting Design.pptx
Graphics Lecture 7
3 D texturing
The nature and propagation of light
Opticsandlight
Iluminacion
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
Color Science Seminar
light microscopy and its components and also errors in light microscopy
A SEMINAR TOPIC ON BASICS OF REFRACTION.pptx
Computer vision - light
Electrical lighting and aquatics lessons
computergrapgichiddensurfacemethodes.pptx
Optics mirrors & lenses
LIGHT-1.pdfGHFHJGKHLIHUGUJHUKHUGKUHKGUGKHH
Ad

More from Ketan Jani (14)

PPT
08viewing3d
PPT
07object3d 1
PPT
03raster 1
PPT
Graphics pipeline
PPT
Graphics6 bresenham circlesandpolygons
PDF
Curves
PPT
09transformation3d
PPT
07object3d
PPT
06 clipping
PPT
05viewing2d
PPT
04transformation2d
PPT
03raster
PPT
02mathematics 1
PPT
02mathematics
08viewing3d
07object3d 1
03raster 1
Graphics pipeline
Graphics6 bresenham circlesandpolygons
Curves
09transformation3d
07object3d
06 clipping
05viewing2d
04transformation2d
03raster
02mathematics 1
02mathematics

Shading

  • 1. Shading and Lighting Why we need shading • Shade objects so their images • Suppose we build a model of a appear three-dimensional sphere using many polygons and • Light-material interactions color it with glColor. We get • Phong model something like • But we want Shading Scattering • Why does the image of a real sphere look • Light strikes A like – Some scattered – Some absorbed • Some of scattered light strikes B – Some scattered • Light-material interactions cause each – Some absorbed point to have a different color or shade • Need to consider • Some of this scattered – Light sources light strikes A – Material properties and so on – Location of viewer – Surface orientation 1
  • 2. Rendering Equation Global Effects • The infinite scattering and absorption shadow of light can be described by the rendering equation – Cannot be solved in general – Ray tracing is a special case for perfectly reflecting surfaces multiple reflection • Rendering equation is global and translucent surface includes – Shadows – Multiple scattering from object to object Ray Tracing Scene Local vs Global Rendering • Correct shading requires a global calculation involving all objects and light sources – Incompatible with pipeline model which shades each polygon independently (local rendering) • However, in computer graphics, especially real time graphics, we are happy if things “look right” – Exist many techniques for approximating global effects 2
  • 3. Light-Material Interaction Light Sources • Light that strikes an object is partially absorbed and partially scattered General light sources are difficult to (reflected) or refracted work with because we must integrate • The amount reflected determines the light coming from all points on the color and brightness of the object source – A surface appears red under white light because the red component of the light is reflected and the rest is absorbed • The reflected light is scattered in a manner that depends on the smoothness and orientation of the surface Simple Light Sources Surface Types • Point source • The smoother a surface, the more – Model with position and color reflected light is concentrated in the – Distant source = infinite distance away direction a perfect mirror would reflected (parallel) the light • Spotlight • A very rough surface scatters light in all directions – Restrict light from ideal point source • Ambient light – Same amount of light everywhere in scene – Can model contribution of many sources smooth surface rough surface and reflecting surfaces 3
  • 4. Phong Model Ideal Reflector • A simple model that can be computed • Normal is determined by local rapidly orientation • Has three components – Diffuse • Angle of incidence = angle of – Specular reflection – Ambient • The three vectors must be coplanar • Uses four vectors r = 2 (l · n ) n - l – To source – To viewer – Normal – Perfect reflector Lambertian Surface • Perfectly diffuse reflector Specular Surfaces • Light scattered equally in all • Most surfaces are neither ideal diffusers directions nor perfectly specular (ideal reflectors) • Amount of light reflected is • Smooth surfaces show specular highlights due to incoming light being reflected in proportional to the vertical directions concentrated close to the component of incoming light direction of a perfect reflection – reflected light ~cos θi – cos θi = l · n if vectors normalized – There are also three coefficients, kr, kb, kg specular that show how much of each color highlight component is reflected 4
  • 5. Modeling Specular Reflections The Shininess Coefficient • Phong proposed using a term that • Values of α between 100 and 200 dropped off as the angle between the correspond to metals viewer and the ideal reflection • Values between 5 and 10 give surface that increased look like plastic Ir ~ ks I cosαφ cosα φ φ reflected shininess coef intensity incoming intensity absorption coef -90 φ 90 Ambient Light Light Sources • Ambient light is the result of multiple • In the Phong Model, we add the interactions between (large) light results from each light source sources and the objects in the • Each light source has separate environment diffuse, specular, and ambient • Amount and color depend on both terms to allow for maximum the color of the light(s) and the flexibility even though this form material properties of the object does not have a physical • Add ka Ia to diffuse and specular justification terms • Separate red, green and blue reflection coef intensity of ambient light components 5
  • 6. Adding up the Components Material Properties For each light source and each color • Hence, 9 coefficients for each point component, the Phong model can be source written as – Idr, Idg, Idb, Isr, Isg, Isb, Iar, Iag, Iab I =kd Id l · n + ks Is (v · r )α + ka Ia For each color component • Material properties match light source properties we add contributions from – Nine absorbtion coefficients all sources • kdr, kdg, kdb, ksr, ksg, ksb, kar, kag, kab – Shininess coefficient α Modified Phong Model The Halfway Vector • The specular term in the Phong • h is normalized vector halfway model is problematic because it between l and v requires the calculation of a new h = ( l + v )/ | l + v | reflection vector and view vector for each vertex • Blinn suggested an approximation using the halfway vector that is more efficient 6
  • 7. Using the halfway angle Example • Replace (v · r )α by (n · h )β • β is chosen to match shineness • Note that halfway angle is half of Only differences in angle between r and v if vectors are these teapots are the parameters coplanar in the modified • Resulting model is known as the Phong model modified Phong or Blinn lighting model – Specified in OpenGL standard Computation of Vectors Ray Tracing Algorithm • l and v are specified by the application • References • Can compute r from l and n – Glassner, Andrew (Ed.) (1989). An Introduction to Ray Tracing. Academic Press • Problem is determining n – Shirley, Peter and Morley Keith, R. (2001) Realistic Ray • For simple surfaces n is can be determined Tracing,2nd edition. A.K. Peters – Free ray tracing program POV-Ray at but how we determine n differs depending http://www.povray.org on underlying representation of surface – Siggraph 2005 course notes • OpenGL leaves determination of normal to • Introduction to Real-Time Ray Tracing application – Many graphics books… – Exception for GLU quadrics and Bezier surfaces 7