SlideShare a Scribd company logo
1 of 7
Download to read offline
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

What's hot

Angular magnification of mircoscope and telescope by anjali and tanishka
Angular magnification of mircoscope and telescope by anjali and tanishkaAngular magnification of mircoscope and telescope by anjali and tanishka
Angular magnification of mircoscope and telescope by anjali and tanishkaTanishkPrasad
 
Physics 504 Chapter 3-4
Physics 504 Chapter 3-4Physics 504 Chapter 3-4
Physics 504 Chapter 3-4Neil MacIntosh
 
Physically Based Rendering
Physically Based RenderingPhysically Based Rendering
Physically Based RenderingKoray Hagen
 
Lecture26
Lecture26Lecture26
Lecture26zukun
 
Phy exppp chap12
Phy exppp chap12Phy exppp chap12
Phy exppp chap12hmsoh
 
Assignment #14 (p1): Photography Research And Prectice
Assignment #14 (p1): Photography Research And PrecticeAssignment #14 (p1): Photography Research And Prectice
Assignment #14 (p1): Photography Research And Precticemedia_jojo
 
Intr 351 1 intro to lighitng
Intr 351 1 intro to lighitngIntr 351 1 intro to lighitng
Intr 351 1 intro to lighitngamhdrexel
 
Refraction through lenses
Refraction through lensesRefraction through lenses
Refraction through lensesAbhishek Sharma
 
PPT on refraction and lenses by pg
PPT on refraction and lenses by pgPPT on refraction and lenses by pg
PPT on refraction and lenses by pgPritam Ghanghas
 
Sci 1010 chapter 7
Sci 1010 chapter 7Sci 1010 chapter 7
Sci 1010 chapter 7stanbridge
 

What's hot (14)

Light, Lenses & the Human Eye
Light, Lenses & the Human EyeLight, Lenses & the Human Eye
Light, Lenses & the Human Eye
 
Light and the human eye 2012
Light and the human eye 2012Light and the human eye 2012
Light and the human eye 2012
 
Angular magnification of mircoscope and telescope by anjali and tanishka
Angular magnification of mircoscope and telescope by anjali and tanishkaAngular magnification of mircoscope and telescope by anjali and tanishka
Angular magnification of mircoscope and telescope by anjali and tanishka
 
Physics 504 Chapter 3-4
Physics 504 Chapter 3-4Physics 504 Chapter 3-4
Physics 504 Chapter 3-4
 
Physically Based Rendering
Physically Based RenderingPhysically Based Rendering
Physically Based Rendering
 
Lecture26
Lecture26Lecture26
Lecture26
 
Broadcast Lens Technology Part 2
Broadcast Lens Technology Part 2Broadcast Lens Technology Part 2
Broadcast Lens Technology Part 2
 
Phy exppp chap12
Phy exppp chap12Phy exppp chap12
Phy exppp chap12
 
Light
LightLight
Light
 
Assignment #14 (p1): Photography Research And Prectice
Assignment #14 (p1): Photography Research And PrecticeAssignment #14 (p1): Photography Research And Prectice
Assignment #14 (p1): Photography Research And Prectice
 
Intr 351 1 intro to lighitng
Intr 351 1 intro to lighitngIntr 351 1 intro to lighitng
Intr 351 1 intro to lighitng
 
Refraction through lenses
Refraction through lensesRefraction through lenses
Refraction through lenses
 
PPT on refraction and lenses by pg
PPT on refraction and lenses by pgPPT on refraction and lenses by pg
PPT on refraction and lenses by pg
 
Sci 1010 chapter 7
Sci 1010 chapter 7Sci 1010 chapter 7
Sci 1010 chapter 7
 

Similar to Shading

Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination modelAnkit Garg
 
illuminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdfilluminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdfSayantanMajhi2
 
Lecture 1. Lighting Design.pptx
Lecture 1. Lighting Design.pptxLecture 1. Lighting Design.pptx
Lecture 1. Lighting Design.pptxNisthaPathak2
 
Graphics Lecture 7
Graphics Lecture 7Graphics Lecture 7
Graphics Lecture 7Saiful Islam
 
The nature and propagation of light
The nature and propagation of lightThe nature and propagation of light
The nature and propagation of lightJessabeth Aluba
 
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfUNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfSayantanMajhi2
 
Color Science Seminar
Color Science SeminarColor Science Seminar
Color Science Seminardfoley2019
 
Computer vision - light
Computer vision - lightComputer vision - light
Computer vision - lightWael Badawy
 
Optics mirrors & lenses
Optics mirrors & lensesOptics mirrors & lenses
Optics mirrors & lensesShamim Ahmed
 
Geometric Optics
Geometric OpticsGeometric Optics
Geometric OpticsEmma Zhao
 
illumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarillumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarsyedArr
 
Reflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.pptReflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.pptyasmin511960
 
Reflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.pptReflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.pptGurumurthy B R
 

Similar to Shading (20)

Shading
ShadingShading
Shading
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination model
 
illuminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdfilluminationmodelsshading-200501081735 (1).pdf
illuminationmodelsshading-200501081735 (1).pdf
 
Lecture 1. Lighting Design.pptx
Lecture 1. Lighting Design.pptxLecture 1. Lighting Design.pptx
Lecture 1. Lighting Design.pptx
 
Graphics Lecture 7
Graphics Lecture 7Graphics Lecture 7
Graphics Lecture 7
 
3 D texturing
 3 D texturing 3 D texturing
3 D texturing
 
The nature and propagation of light
The nature and propagation of lightThe nature and propagation of light
The nature and propagation of light
 
Opticsandlight
OpticsandlightOpticsandlight
Opticsandlight
 
Iluminacion
IluminacionIluminacion
Iluminacion
 
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfUNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
 
Color Science Seminar
Color Science SeminarColor Science Seminar
Color Science Seminar
 
Computer vision - light
Computer vision - lightComputer vision - light
Computer vision - light
 
Optics mirrors & lenses
Optics mirrors & lensesOptics mirrors & lenses
Optics mirrors & lenses
 
Geometric Optics
Geometric OpticsGeometric Optics
Geometric Optics
 
Lighting and shading
Lighting and shadingLighting and shading
Lighting and shading
 
illumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarillumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukar
 
Visual realism
Visual realismVisual realism
Visual realism
 
Reflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.pptReflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.ppt
 
Reflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.pptReflection-and-Refraction-of-light.ppt
Reflection-and-Refraction-of-light.ppt
 
Object rendering
Object renderingObject rendering
Object rendering
 

More from Ketan Jani

Graphics pipeline
Graphics pipelineGraphics pipeline
Graphics pipelineKetan Jani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
09transformation3d
09transformation3d09transformation3d
09transformation3dKetan Jani
 
04transformation2d
04transformation2d04transformation2d
04transformation2dKetan Jani
 
02mathematics 1
02mathematics 102mathematics 1
02mathematics 1Ketan Jani
 

More from Ketan Jani (14)

08viewing3d
08viewing3d08viewing3d
08viewing3d
 
07object3d 1
07object3d 107object3d 1
07object3d 1
 
03raster 1
03raster 103raster 1
03raster 1
 
Graphics pipeline
Graphics pipelineGraphics pipeline
Graphics pipeline
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Curves
CurvesCurves
Curves
 
09transformation3d
09transformation3d09transformation3d
09transformation3d
 
07object3d
07object3d07object3d
07object3d
 
06 clipping
06 clipping06 clipping
06 clipping
 
05viewing2d
05viewing2d05viewing2d
05viewing2d
 
04transformation2d
04transformation2d04transformation2d
04transformation2d
 
03raster
03raster03raster
03raster
 
02mathematics 1
02mathematics 102mathematics 1
02mathematics 1
 
02mathematics
02mathematics02mathematics
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