shadows
play

Shadows CS418 Computer Graphics John C. Hart Shadowing Shadows - PowerPoint PPT Presentation

Shadows CS418 Computer Graphics John C. Hart Shadowing Shadows indicate light occlusion Fix object positions relative to each other Perspective Distortion screen y y view y clip -z z view 1 x view z


  1. Shadows CS418 Computer Graphics John C. Hart

  2. Shadowing • Shadows indicate light occlusion • Fix object positions relative to each other

  3. Perspective Distortion screen y y view y clip -z z view 1   x view    z   view       1 x x view view         y view y 1 y y           view view  view    y z clip  view            z z z view view view                       1 0 1 z view z   view     1

  4. Shadow Buffer • Williams, SIGGRAPH 78 RGB Depth • Render scene twice from viewpoint ( x , y , z ) screen = WPV ( x , y , z ) world Viewpoint – Once with light source on – Once only with ambient – Save a z-buffer • Render scene from light position ( x , y , z ) light = W l P l V l ( x , y , z ) world – Save only z-buffer Light Position • For each viewpoint image pixel compute ( x , y , z ) vis = W l P l V l V -1 P -1 W -1 ( x , y , z ) screen • If z vis < z light at ( x , y ) vis = ( x , y ) light • Then pixel is in shadow

  5. Shadow Buffer • Williams, SIGGRAPH 78 • Render scene twice from viewpoint ( x , y , z ) screen = WPV ( x , y , z ) world – Once with light source on – Once only with ambient – Save a z-buffer • Render scene from light position ( x , y , z ) light = W l P l V l ( x , y , z ) world – Save only z-buffer • For each viewpoint image pixel compute ( x , y , z ) vis = W l P l V l V -1 P -1 W -1 ( x , y , z ) screen • If z vis < z light at ( x , y ) vis = ( x , y ) light • Then pixel is in shadow

  6. Shadow Buffer • Williams, SIGGRAPH 78 • Render scene twice from viewpoint ( x , y , z ) screen = WPV ( x , y , z ) world – Once with light source on – Once only with ambient – Save a z-buffer • Render scene from light position ( x , y , z ) light = W l P l V l ( x , y , z ) world – Save only z-buffer • For each viewpoint image pixel compute ( x , y , z ) vis = W l P l V l V -1 P -1 W -1 ( x , y , z ) screen • If z vis < z light at ( x , y ) vis = ( x , y ) light • Then pixel is in shadow

  7. Shadow Buffer • Williams, SIGGRAPH 78 • Render scene twice from viewpoint ( x , y , z ) screen = WPV ( x , y , z ) world – Once with light source on – Once only with ambient – Save a z-buffer • Render scene from light position ( x , y , z ) light = W l P l V l ( x , y , z ) world – Save only z-buffer • For each viewpoint image pixel compute ( x , y , z ) vis = W l P l V l V -1 P -1 W -1 ( x , y , z ) screen • If z vis < z light at ( x , y ) vis = ( x , y ) light • Then pixel is in shadow

  8. Shadow Buffer • Williams, SIGGRAPH 78 • Render scene twice from viewpoint ( x , y , z ) screen = WPV ( x , y , z ) world – Once with light source on – Once only with ambient – Save a z-buffer • Render scene from light position ( x , y , z ) light = W l P l V l ( x , y , z ) world – Save only z-buffer • For each viewpoint image pixel compute ( x , y , z ) vis = W l P l V l V -1 P -1 W -1 ( x , y , z ) screen • If z vis < z light at ( x , y ) vis = ( x , y ) light • Then pixel is in shadow

  9. Numerical Analysis

  10. Percentage Closer Filtering • Reeves, Salesin, Cook, SIGGRAPH 87 • Shadow aliasing occurs when numerical inaccuracy and discretization causes sample to compare to the wrong depth near an edge • Can be fixed by comparing sample in a neighborhood (e.g. 3x3 pixels) and filtering the binary shadow answer • Can also be extended to generate soft shadows

Recommend


More recommend