Advanced Lighting for Interactive Applications Shadow Algorithms Stefan Brabec Max-Planck-Institut für Informatik Saarbrüc...
Overview <ul><li>Motivation </li></ul><ul><li>Algorithms for hard shadows </li></ul><ul><li>Algorithms for soft shadows </...
Motivation <ul><li>Shadows do significantly contribute to the realism of rendered images </li></ul><ul><li>Global effect w...
Motivation <ul><li>Hard shadows vs. Soft shadows </li></ul>Hard shadow edges -  unreal (like geometry) + computation easie...
Algorithms for Hard Shadows <ul><li>Approximated shadows </li></ul><ul><li>Projected geometry  [Blinn88] </li></ul><ul><li...
Approximated Shadows <ul><li>Hand-Drawn Geometry </li></ul>Images from TombRaider. ©Eidos Interactive.
Approximated Shadows <ul><li>Polygons / Texture Maps: </li></ul><ul><ul><li>Precomputed shape that moves with object </li>...
Projected Geometry <ul><li>[Blinn88]  Me and my fake shadow </li></ul><ul><ul><li>Shadows for selected large receiver poly...
Projected Geometry <ul><li>Example:  xz  plane at  y=0 </li></ul>
Projected Geometry <ul><li>Transformation as 4 by 4 matrix </li></ul>
Projected Geometry <ul><li>General case: receiver polygon in plane  E </li></ul><ul><li>4x4 matrix (see Blinn) </li></ul>
Projected Geometry <ul><li>Basic algorithm </li></ul><ul><ul><li>Render scene (full lighting) </li></ul></ul><ul><ul><li>F...
Projected Geometry <ul><li>Problems </li></ul><ul><ul><li>Z-Fighting </li></ul></ul><ul><ul><ul><li>Use bias when renderin...
Projected Geometry <ul><li>Stencil buffer algorithm (1bit stencil) </li></ul>1. Render scene without receiver polygon 2. C...
Projected Geometry <ul><li>Wrong Shadows & Anti-Shadows </li></ul><ul><ul><li>Objects behind light source </li></ul></ul><...
Projected Geometry <ul><li>Summary </li></ul><ul><ul><li>Only practical for very few, large receivers  </li></ul></ul><ul>...
Shadow Volumes <ul><li>[Crow77]   Shadow algorithms for computer graphics  </li></ul><ul><ul><li>Compute regions of shadow...
Shadow Volumes <ul><li>Extend occluder polygons to form  semi-infinite volumes </li></ul><ul><ul><li>Light source is  cent...
Shadow Volumes <ul><li>Shadow volume generation </li></ul><ul><ul><li>Trivial way </li></ul></ul><ul><ul><ul><li>One volum...
Shadow Volumes <ul><li>Shadow test:  in-out  counter  </li></ul><ul><ul><li>Counter == 0:  lit </li></ul></ul><ul><ul><li>...
Shadow Volumes <ul><li>Use stencil buffer as counter  </li></ul>1. Render scene (ambient color) 2. Render front-facing par...
Shadow Volumes <ul><li>Implementation </li></ul><ul><ul><li>Generate volumes in software (object space) </li></ul></ul><ul...
Shadow Volumes <ul><li>Counting problems </li></ul><ul><ul><li>Viewer in shadow  (correct counter initialization) </li></u...
Shadow Volumes <ul><li>Counting problems </li></ul><ul><ul><li>Stencil depth  </li></ul></ul><ul><ul><ul><li>8 bits for in...
Shadow Volumes <ul><li>Summary </li></ul><ul><ul><li>Shadow volumes in object precision </li></ul></ul><ul><ul><ul><li>CPU...
Shadow Maps <ul><li>[Williams78]   Casting curved shadows on curved surfaces </li></ul><ul><ul><li>Image-space algorithm <...
Shadow Maps <ul><li>Basic Algorithm </li></ul><ul><ul><li>Render scene as seen from light source </li></ul></ul><ul><ul><l...
Shadow Maps Shadow map Final scene
Shadow Maps <ul><li>Hardware implementation </li></ul><ul><ul><li>Render scene to z-buffer (light source view) </li></ul><...
Shadow Maps <ul><li>Hardware implementation </li></ul><ul><ul><li>Project shadow map into the scene </li></ul></ul>Brabec/...
Shadow Maps <ul><li>How to perform shadow test in hardware ? </li></ul><ul><ul><li>Dedicated shadow mapping hardware SGI O...
Shadow Maps <ul><li>Shadow mapping using standard OpenGL   [Heidrich99] </li></ul><ul><ul><li>Encode depth values as alpha...
Shadow Maps <ul><li>Distance to light source in alpha channel: </li></ul><ul><ul><li>Use 1D ramp texture and automatic  te...
Shadow Maps <ul><li>Algorithm using multi texturing </li></ul>1. Render scene from light source view - 1D ramp texture or ...
Shadow Maps <ul><li>Linear sample distribution </li></ul><ul><ul><li>Better than 1/z (depth buffer read) </li></ul></ul><u...
Shadow Maps <ul><li>Problems </li></ul><ul><ul><li>Needs high-resolution texture maps to sample fine details </li></ul></u...
Hybrid Approach <ul><li>[McCool00]   Shadow volume reconstruction from depth maps  </li></ul><ul><ul><li>Combine the pros ...
Hybrid Approach <ul><li>Algorithm overview </li></ul>1. Render scene from light source view (depth only) 2. Read back dept...
Hybrid Approach
Hybrid Approach <ul><li>Summary </li></ul><ul><ul><li>Better than  normal  shadow volumes for very complex scenes </li></u...
Extended Light Maps <ul><li>[Brabec00]  Extended Light Maps </li></ul><ul><ul><li>Additional calculations during shadow ma...
Extended Light Maps  <ul><li>Shadow map generation is expensive ! </li></ul><ul><ul><li>Additional geometry pass </li></ul...
Extended Light Maps <ul><li>Light Maps store pre-computed illumination </li></ul><ul><li>Extended Light Map </li></ul><ul>...
Extended Light Maps <ul><li>Use RGB channel for arbitrary calculations e.g. </li></ul><ul><ul><li>OpenGL lighting </li></u...
Extended Light Maps <ul><li>Example: Pre-computed reflection mapping </li></ul>
Extended Light Maps <ul><li>First pass: </li></ul><ul><ul><li>Use color channel for environment cube map </li></ul></ul><u...
Extended Light Maps <ul><li>How to perform cube mapping in  light source space ? </li></ul><ul><ul><li>Need correct reflec...
Extended Light Maps <ul><li>Two final passes </li></ul><ul><ul><li>Render  normal  scene (textures & lighting) </li></ul><...
Algorithms for Soft Shadows <ul><li>Sampling the Light Source </li></ul><ul><li>Soft Shadow Maps  [Heidrich00] </li></ul>
Sampling the Light Source <ul><li>Use arbitrary hard shadow algorithm </li></ul><ul><ul><li>Select point sample on area li...
Sampling the Light Source <ul><li>Ground plane shadow texture </li></ul>1. Initialize FB (white) 2. For each sample point ...
Sampling the Light Source <ul><li>Result </li></ul>Image from ATI Developer’s Site
Sampling the Light Source <ul><li>Number of samples == number of passes </li></ul><ul><ul><li>Problematic for complex scen...
Sampling the Light Source <ul><li>Similar technique in  [Heckbert97]   Simulating soft shadows with graphics hardware </li...
Soft Shadow Maps <ul><li>[Heidrich00]  Soft shadow maps for linear lights  </li></ul>
Soft Shadow Maps <ul><li>[Heidrich00]  </li></ul><ul><li>Soft penumbra regions for linear light sources </li></ul><ul><li>...
Soft Shadow Maps <ul><li>Visibility of light source </li></ul><ul><ul><li>100% to 0% for [p1,p2] </li></ul></ul><ul><ul><l...
Soft Shadow Maps <ul><li>Linear interpolation of visibility </li></ul><ul><ul><li>Rational function: </li></ul></ul><ul><u...
Soft Shadow Maps <ul><li>Visibility map: </li></ul><ul><ul><li>Additional shadow map channel (percentage visibility) </li>...
Soft Shadow Maps <ul><li>Generating the visibility map </li></ul><ul><ul><li>Triangulate depth discontinuities (shadow map...
Soft Shadow Maps <ul><li>Generating the visibility map </li></ul><ul><ul><li>Render skin polygons to visibility map </li><...
Soft Shadow Maps <ul><li>Edge Detection (on shadow map) </li></ul><ul><ul><li>Laplacian-of-Gaussian </li></ul></ul>left sa...
Soft Shadow Maps <ul><li>Triangulate and warp  </li></ul>
Soft Shadow Maps <ul><li>Render using Gouraud shading </li></ul>
Soft Shadow Maps <ul><li>Visibility maps </li></ul>left sample point right sample point
Soft Shadow Maps <ul><li>New shadow map algorithm </li></ul>shade(p) { if( depth 1 (p) > S 1 [p] )  l 1  = 0; else l 1  = ...
Soft Shadow Maps <ul><ul><li>Shadow & visibility maps only need to be re-computed if light and/or scene changes </li></ul>...
Soft Shadow Maps
Soft Shadow Maps
Conclusion <ul><li>Without shadows there is no realism </li></ul><ul><li>Good looking shadows are expensive </li></ul><ul>...
Thank you !
Upcoming SlideShare
Loading in …5
×

Advanced Lighting for Interactive Applications

1,142 views

Published on

A tutorial on shadow algorithms at GTEC 2001 Hong-Kong.

Published in: Technology, Art & Photos
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,142
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Advanced Lighting for Interactive Applications

  1. 1. Advanced Lighting for Interactive Applications Shadow Algorithms Stefan Brabec Max-Planck-Institut für Informatik Saarbrücken, Germany
  2. 2. Overview <ul><li>Motivation </li></ul><ul><li>Algorithms for hard shadows </li></ul><ul><li>Algorithms for soft shadows </li></ul><ul><li>Conclusion </li></ul>
  3. 3. Motivation <ul><li>Shadows do significantly contribute to the realism of rendered images </li></ul><ul><li>Global effect which is expensive to compute </li></ul><ul><li>Lot of work done in this area </li></ul><ul><li>Which algorithms are suitable for interactive applications ? </li></ul>
  4. 4. Motivation <ul><li>Hard shadows vs. Soft shadows </li></ul>Hard shadow edges - unreal (like geometry) + computation easier Soft shadow boundaries + realistic - expensive
  5. 5. Algorithms for Hard Shadows <ul><li>Approximated shadows </li></ul><ul><li>Projected geometry [Blinn88] </li></ul><ul><li>Shadow volumes [Crow77] </li></ul><ul><li>Shadow maps [Williams78] </li></ul><ul><li>Hybrid approach [McCool00] </li></ul><ul><li>Extended light maps [Brabec00] </li></ul>
  6. 6. Approximated Shadows <ul><li>Hand-Drawn Geometry </li></ul>Images from TombRaider. ©Eidos Interactive.
  7. 7. Approximated Shadows <ul><li>Polygons / Texture Maps: </li></ul><ul><ul><li>Precomputed shape that moves with object </li></ul></ul><ul><ul><li>Rotation / Translation / Scale </li></ul></ul><ul><ul><li>Blurred (more realistic, soft) </li></ul></ul><ul><li>Pros: </li></ul><ul><ul><li>Fast & simple: no global computation </li></ul></ul><ul><li>Cons: </li></ul><ul><ul><li>Quality not very realistic </li></ul></ul>
  8. 8. Projected Geometry <ul><li>[Blinn88] Me and my fake shadow </li></ul><ul><ul><li>Shadows for selected large receiver polygons </li></ul></ul><ul><ul><ul><li>Ground plane </li></ul></ul></ul><ul><ul><ul><li>Walls </li></ul></ul></ul>
  9. 9. Projected Geometry <ul><li>Example: xz plane at y=0 </li></ul>
  10. 10. Projected Geometry <ul><li>Transformation as 4 by 4 matrix </li></ul>
  11. 11. Projected Geometry <ul><li>General case: receiver polygon in plane E </li></ul><ul><li>4x4 matrix (see Blinn) </li></ul>
  12. 12. Projected Geometry <ul><li>Basic algorithm </li></ul><ul><ul><li>Render scene (full lighting) </li></ul></ul><ul><ul><li>For each receiver polygon </li></ul></ul><ul><ul><ul><li>Compute projection matrix M </li></ul></ul></ul><ul><ul><ul><li>Mult with actual transformation (modelview) </li></ul></ul></ul><ul><ul><ul><li>Render selected (occluder) geometry </li></ul></ul></ul><ul><ul><ul><ul><li>Darken/Black </li></ul></ul></ul></ul>
  13. 13. Projected Geometry <ul><li>Problems </li></ul><ul><ul><li>Z-Fighting </li></ul></ul><ul><ul><ul><li>Use bias when rendering shadow polygons </li></ul></ul></ul><ul><ul><ul><li>Use stencil buffer (no depth test) </li></ul></ul></ul><ul><ul><li>Bounded receiver polygon ? </li></ul></ul><ul><ul><ul><li>Use stencil buffer (restrict drawing to receiver area) </li></ul></ul></ul><ul><ul><li>Shadow polygon overlap ? </li></ul></ul><ul><ul><ul><li>Use stencil count (only the first pixel gets through) </li></ul></ul></ul>
  14. 14. Projected Geometry <ul><li>Stencil buffer algorithm (1bit stencil) </li></ul>1. Render scene without receiver polygon 2. Clear stencil buffer 3. Render receiver polygon - stencil operation ‘set’ (visible pixels) 4. Render shadow polygons - without depth test - stencil test ‘is set?’ - stencil operation ‘clear’ - blending e.g. ‘dest = dest * 0.2’ (darken)
  15. 15. Projected Geometry <ul><li>Wrong Shadows & Anti-Shadows </li></ul><ul><ul><li>Objects behind light source </li></ul></ul><ul><ul><li>Objects behind receiver </li></ul></ul><ul><li>Solution </li></ul><ul><ul><li>Clipping </li></ul></ul><ul><ul><ul><li>Use 3D-3D transformation e.g. [Heckbert97] for valid z coordinates </li></ul></ul></ul>
  16. 16. Projected Geometry <ul><li>Summary </li></ul><ul><ul><li>Only practical for very few, large receivers </li></ul></ul><ul><ul><li>Easy to implement </li></ul></ul><ul><ul><li>Use stencil buffer (z fighting, overlap, receiver) </li></ul></ul><ul><ul><li>Efficiency can be improved by rendering shadow polygons to texture maps </li></ul></ul><ul><ul><ul><li>Occluders and receiver ‘static’ for some time </li></ul></ul></ul>
  17. 17. Shadow Volumes <ul><li>[Crow77] Shadow algorithms for computer graphics </li></ul><ul><ul><li>Compute regions of shadow in 3D </li></ul></ul><ul><ul><ul><li>Object-space algorithm </li></ul></ul></ul><ul><ul><ul><li>Cast shadows onto arbitrary receiver geometry (polygons) </li></ul></ul></ul>
  18. 18. Shadow Volumes <ul><li>Extend occluder polygons to form semi-infinite volumes </li></ul><ul><ul><li>Light source is center-of-projection </li></ul></ul><ul><ul><li>Everything behind occluder is in shadow </li></ul></ul><ul><ul><li>Test if point is in at least one volume ! </li></ul></ul><ul><ul><li>Extend to reach outside of view frustum </li></ul></ul>Light Source Shadow Region Occluder
  19. 19. Shadow Volumes <ul><li>Shadow volume generation </li></ul><ul><ul><li>Trivial way </li></ul></ul><ul><ul><ul><li>One volume for each polygon </li></ul></ul></ul><ul><ul><li>Better </li></ul></ul><ul><ul><ul><li>Silhouette-based approach </li></ul></ul></ul><ul><ul><ul><ul><li>Goal: one shadow volume </li></ul></ul></ul></ul><ul><ul><ul><li>Selected occluders only </li></ul></ul></ul><ul><ul><ul><li>By objects (shared edges) </li></ul></ul></ul>
  20. 20. Shadow Volumes <ul><li>Shadow test: in-out counter </li></ul><ul><ul><li>Counter == 0: lit </li></ul></ul><ul><ul><li>Counter >=0: shadowed </li></ul></ul>
  21. 21. Shadow Volumes <ul><li>Use stencil buffer as counter </li></ul>1. Render scene (ambient color) 2. Render front-facing parts of shadow volumes with stencil operation increment (enter) 3. Render back-facing parts of shadow volumes with stencil operation decrement (exit) 4. Render scene (fully lit) with stencil test equal zero
  22. 22. Shadow Volumes <ul><li>Implementation </li></ul><ul><ul><li>Generate volumes in software (object space) </li></ul></ul><ul><ul><li>Counting can be done in hardware (image space) </li></ul></ul>Images from Mark Kilgard’s shadow volume demo (NVIDIA).
  23. 23. Shadow Volumes <ul><li>Counting problems </li></ul><ul><ul><li>Viewer in shadow (correct counter initialization) </li></ul></ul><ul><ul><li>Correct ownership of adjacent polygons (no double hits) </li></ul></ul>
  24. 24. Shadow Volumes <ul><li>Counting problems </li></ul><ul><ul><li>Stencil depth </li></ul></ul><ul><ul><ul><li>8 bits for intersecting volumes </li></ul></ul></ul><ul><ul><ul><ul><li>Stencil wrap mode </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Missing shadows for ‘counter mod 2^n == 0’ </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><li>Stencil clamp </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Missing shadows (missing some ‘enter’ events) </li></ul></ul></ul></ul></ul><ul><ul><ul><li>1 bit enough for non-intersecting volumes </li></ul></ul></ul><ul><ul><ul><ul><li>Generate volumes from silhouette </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Toggle stencil bit </li></ul></ul></ul></ul>
  25. 25. Shadow Volumes <ul><li>Summary </li></ul><ul><ul><li>Shadow volumes in object precision </li></ul></ul><ul><ul><ul><li>CPU intensive, requires polygon representation </li></ul></ul></ul><ul><ul><li>Shadow test in image precision </li></ul></ul><ul><ul><ul><li>Stencil buffer count </li></ul></ul></ul><ul><ul><ul><li>Hardware-accelerated </li></ul></ul></ul><ul><ul><li>Many, large shadow polygons </li></ul></ul><ul><ul><ul><li>Fill rate, geometry processing </li></ul></ul></ul>
  26. 26. Shadow Maps <ul><li>[Williams78] Casting curved shadows on curved surfaces </li></ul><ul><ul><li>Image-space algorithm </li></ul></ul><ul><ul><li>Well suited for hardware implementation </li></ul></ul>
  27. 27. Shadow Maps <ul><li>Basic Algorithm </li></ul><ul><ul><li>Render scene as seen from light source </li></ul></ul><ul><ul><li>Save back depth buffer (2D shadow map) </li></ul></ul><ul><ul><li>Render scene from viewer’s position </li></ul></ul><ul><ul><ul><li>Transform pixel coordinates to light source space </li></ul></ul></ul><ul><ul><ul><li>Compare z with z value stored in shadow map </li></ul></ul></ul><ul><ul><ul><ul><li>Pixel is in shadow if z(light) < z(viewer) </li></ul></ul></ul></ul>
  28. 28. Shadow Maps Shadow map Final scene
  29. 29. Shadow Maps <ul><li>Hardware implementation </li></ul><ul><ul><li>Render scene to z-buffer (light source view) </li></ul></ul><ul><ul><ul><li>Depthbuffer-to-texture copy </li></ul></ul></ul><ul><ul><ul><li>Render-to-texture / pbuffer </li></ul></ul></ul>
  30. 30. Shadow Maps <ul><li>Hardware implementation </li></ul><ul><ul><li>Project shadow map into the scene </li></ul></ul>Brabec/Heidrich ‘Marilyn'. Image taken from OpenGL Programming Guide. Projective texturing: Slide projector
  31. 31. Shadow Maps <ul><li>How to perform shadow test in hardware ? </li></ul><ul><ul><li>Dedicated shadow mapping hardware SGI Onyx/Reality (OpenGL extension) </li></ul></ul><ul><ul><ul><li>Compare fragment’s depth with depth in shadow map </li></ul></ul></ul><ul><ul><ul><ul><li>Use homogenous texture coordinates (s,t,r,q) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Compare r/q with texture value at (s/q,r/q) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Output 1 for lit and 0 for shadow </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Blend fragment color with shadow test result </li></ul></ul></ul></ul><ul><ul><ul><li>High-precision depth texture format </li></ul></ul></ul>
  32. 32. Shadow Maps <ul><li>Shadow mapping using standard OpenGL [Heidrich99] </li></ul><ul><ul><li>Encode depth values as alpha values </li></ul></ul><ul><ul><li>Shadow test using alpha test or programmable texture units (multi texturing) </li></ul></ul>
  33. 33. Shadow Maps <ul><li>Distance to light source in alpha channel: </li></ul><ul><ul><li>Use 1D ramp texture and automatic texture coordinate generation </li></ul></ul><ul><ul><li>Use fog factor as linear distance function [Brabec00] </li></ul></ul>
  34. 34. Shadow Maps <ul><li>Algorithm using multi texturing </li></ul>1. Render scene from light source view - 1D ramp texture or linear fog 2. Copy frame buffer (alpha channel) to texture 3. Render scene shadowed (ambient light only) 4. Render scene fully lit with alpha as - Tex #1: 2D shadow map (projective texture) - Tex #2: 1D linear ramp (distance to light) - Alpha test: clamp(Tex#2 - Tex#1) == 0 5. Add up illumination (blending)
  35. 35. Shadow Maps <ul><li>Linear sample distribution </li></ul><ul><ul><li>Better than 1/z (depth buffer read) </li></ul></ul><ul><li>Color resolution problematic </li></ul><ul><ul><li>8bits in alpha: 256 depth samples </li></ul></ul><ul><ul><li>16bits possible </li></ul></ul><ul><ul><ul><li>Use 2D texture map </li></ul></ul></ul><ul><ul><ul><ul><li>S-coordinate for lower 8bit (texture coordinate repeat) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>T-coordinate for higher 8bit (texture coordinate clamp) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Needs two channels and programmable texture unit </li></ul></ul></ul></ul>
  36. 36. Shadow Maps <ul><li>Problems </li></ul><ul><ul><li>Needs high-resolution texture maps to sample fine details </li></ul></ul><ul><ul><ul><li>Offscreen buffers, render-to-texture </li></ul></ul></ul><ul><ul><ul><li>Filtering ? </li></ul></ul></ul><ul><ul><li>Numerical problems (light leaks, surface acne) </li></ul></ul><ul><ul><ul><li>Bias needed [Reeves87] </li></ul></ul></ul>
  37. 37. Hybrid Approach <ul><li>[McCool00] Shadow volume reconstruction from depth maps </li></ul><ul><ul><li>Combine the pros from shadow maps and shadow volumes </li></ul></ul><ul><ul><ul><li>Shadow volumes generated from depth maps </li></ul></ul></ul><ul><ul><ul><li>Reduced number of shadow volumes for very complex scenes </li></ul></ul></ul><ul><ul><ul><li>Does not need special hardware features (standard shadow text using stencil buffer) </li></ul></ul></ul>
  38. 38. Hybrid Approach <ul><li>Algorithm overview </li></ul>1. Render scene from light source view (depth only) 2. Read back depth buffer 3. Reconstruct shadow volumes - Edge detection (Canny) - Surface reconstruction (Template matching) 4. Render shadow volume with stencil operation 5. Render final scene (stencil test)
  39. 39. Hybrid Approach
  40. 40. Hybrid Approach <ul><li>Summary </li></ul><ul><ul><li>Better than normal shadow volumes for very complex scenes </li></ul></ul><ul><ul><ul><li>Volume for silhouette </li></ul></ul></ul><ul><ul><ul><li>Only one stencil bit (in-out toggle) </li></ul></ul></ul><ul><ul><li>Needs CPU and memory transfer </li></ul></ul><ul><ul><ul><li>Use CPU’s special instruction set </li></ul></ul></ul><ul><ul><ul><li>OpenGL imaging extensions (convolution) </li></ul></ul></ul>
  41. 41. Extended Light Maps <ul><li>[Brabec00] Extended Light Maps </li></ul><ul><ul><li>Additional calculations during shadow map generation </li></ul></ul><ul><ul><ul><li>Utilize special hardware features </li></ul></ul></ul><ul><ul><ul><li>Pre-compute light-relative ‘static’ things </li></ul></ul></ul><ul><ul><ul><li>Use as much hardware resources as available ! </li></ul></ul></ul>
  42. 42. Extended Light Maps <ul><li>Shadow map generation is expensive ! </li></ul><ul><ul><li>Additional geometry pass </li></ul></ul><ul><ul><li>Needs frame buffer reconfiguration </li></ul></ul><ul><li>Idea </li></ul><ul><ul><li>Do as much work as possible during shadow map generation </li></ul></ul>
  43. 43. Extended Light Maps <ul><li>Light Maps store pre-computed illumination </li></ul><ul><li>Extended Light Map </li></ul><ul><ul><li>Light Channel (RGB) </li></ul></ul><ul><ul><ul><li>Normal light map </li></ul></ul></ul><ul><ul><li>Shadow Channel (Alpha) </li></ul></ul><ul><ul><ul><li>Alpha-encoded depth values </li></ul></ul></ul>
  44. 44. Extended Light Maps <ul><li>Use RGB channel for arbitrary calculations e.g. </li></ul><ul><ul><li>OpenGL lighting </li></ul></ul><ul><ul><li>Object textures </li></ul></ul><ul><ul><li>Realistic spotlights </li></ul></ul><ul><ul><li>Special effects </li></ul></ul><ul><ul><li>Reflection mapping </li></ul></ul><ul><ul><li>Bump mapping </li></ul></ul>
  45. 45. Extended Light Maps <ul><li>Example: Pre-computed reflection mapping </li></ul>
  46. 46. Extended Light Maps <ul><li>First pass: </li></ul><ul><ul><li>Use color channel for environment cube map </li></ul></ul><ul><ul><li>Use alpha channel for z-distance </li></ul></ul>
  47. 47. Extended Light Maps <ul><li>How to perform cube mapping in light source space ? </li></ul><ul><ul><li>Need correct reflection vector </li></ul></ul><ul><ul><li>Calculate in camera space: </li></ul></ul><ul><ul><ul><li>Viewing Matrix </li></ul></ul></ul><ul><ul><ul><li>Projection Matrix </li></ul></ul></ul>
  48. 48. Extended Light Maps <ul><li>Two final passes </li></ul><ul><ul><li>Render normal scene (textures & lighting) </li></ul></ul><ul><ul><li>Apply extended light map (shadows & reflections) </li></ul></ul>
  49. 49. Algorithms for Soft Shadows <ul><li>Sampling the Light Source </li></ul><ul><li>Soft Shadow Maps [Heidrich00] </li></ul>
  50. 50. Sampling the Light Source <ul><li>Use arbitrary hard shadow algorithm </li></ul><ul><ul><li>Select point sample on area light source </li></ul></ul><ul><ul><li>Render hard shadows </li></ul></ul><ul><ul><li>Sum up weighted result (e.g. accumulation buffer) </li></ul></ul>
  51. 51. Sampling the Light Source <ul><li>Ground plane shadow texture </li></ul>1. Initialize FB (white) 2. For each sample point do 2a. Render scene 2b. Subtract 1/N from FB only once for each pixel (stencil) ! Image from ATI Developer’s Site
  52. 52. Sampling the Light Source <ul><li>Result </li></ul>Image from ATI Developer’s Site
  53. 53. Sampling the Light Source <ul><li>Number of samples == number of passes </li></ul><ul><ul><li>Problematic for complex scenes </li></ul></ul><ul><li>N samples == (N+1) levels of shadow </li></ul><ul><ul><li>Fully lit, fully shadowed </li></ul></ul><ul><ul><li>(N-1) levels of penumbra </li></ul></ul><ul><li>How much samples ? </li></ul>
  54. 54. Sampling the Light Source <ul><li>Similar technique in [Heckbert97] Simulating soft shadows with graphics hardware </li></ul><ul><ul><li>Shadow texture for each receiver </li></ul></ul><ul><ul><li>Perspective transformation </li></ul></ul><ul><ul><ul><li>Pyramid to box </li></ul></ul></ul><ul><ul><ul><li>Z value for clipping (behind light, behind receiver) </li></ul></ul></ul><ul><ul><li>Runs at interactive frame rates (reasonable number of receivers) </li></ul></ul>
  55. 55. Soft Shadow Maps <ul><li>[Heidrich00] Soft shadow maps for linear lights </li></ul>
  56. 56. Soft Shadow Maps <ul><li>[Heidrich00] </li></ul><ul><li>Soft penumbra regions for linear light sources </li></ul><ul><li>Based on “traditional” shadow map algorithm </li></ul><ul><li>Suitable for hardware and software rendering </li></ul><ul><li>Very small number of light source samples </li></ul><ul><li>Soft shadows at real-time / interactive frame rates </li></ul>
  57. 57. Soft Shadow Maps <ul><li>Visibility of light source </li></ul><ul><ul><li>100% to 0% for [p1,p2] </li></ul></ul><ul><ul><li>0% for [p2,q2] </li></ul></ul><ul><ul><li>0% to 100% for [q2,q1] </li></ul></ul><ul><li>Idea </li></ul><ul><ul><li>Normal shadow maps for umbra and completely lit regions </li></ul></ul><ul><ul><li>Linear interpolation of visibility for penumbra regions </li></ul></ul>
  58. 58. Soft Shadow Maps <ul><li>Linear interpolation of visibility </li></ul><ul><ul><li>Rational function: </li></ul></ul><ul><ul><li>Approximation: valid because large penumbra regions when </li></ul></ul>Receiver Light Source Occluder
  59. 59. Soft Shadow Maps <ul><li>Visibility map: </li></ul><ul><ul><li>Additional shadow map channel (percentage visibility) </li></ul></ul><ul><ul><li>Two-channel shadow map for each sample point </li></ul></ul>
  60. 60. Soft Shadow Maps <ul><li>Generating the visibility map </li></ul><ul><ul><li>Triangulate depth discontinuities (shadow map) </li></ul></ul><ul><ul><li>Warp resulting skin polygons to other view </li></ul></ul>
  61. 61. Soft Shadow Maps <ul><li>Generating the visibility map </li></ul><ul><ul><li>Render skin polygons to visibility map </li></ul></ul><ul><ul><li>Gouraud-shading (linear interpolation) </li></ul></ul><ul><ul><ul><li>“ White” for vertices on receiver </li></ul></ul></ul><ul><ul><ul><li>“ Black” for vertices on occluder </li></ul></ul></ul><ul><ul><li>Completely lit regions </li></ul></ul><ul><ul><ul><li>Default visibility 0.5 </li></ul></ul></ul><ul><ul><li>Completely shadowed regions </li></ul></ul><ul><ul><ul><li>First shadow map channel </li></ul></ul></ul>
  62. 62. Soft Shadow Maps <ul><li>Edge Detection (on shadow map) </li></ul><ul><ul><li>Laplacian-of-Gaussian </li></ul></ul>left sample point right sample point camera view
  63. 63. Soft Shadow Maps <ul><li>Triangulate and warp </li></ul>
  64. 64. Soft Shadow Maps <ul><li>Render using Gouraud shading </li></ul>
  65. 65. Soft Shadow Maps <ul><li>Visibility maps </li></ul>left sample point right sample point
  66. 66. Soft Shadow Maps <ul><li>New shadow map algorithm </li></ul>shade(p) { if( depth 1 (p) > S 1 [p] ) l 1 = 0; else l 1 = V 1 [p] * illum(p,L 1 ); if( depth 2 (p) > S 2 [p] ) l 2 = 0; else l 2 = V 2 [p] * illum(p,L 2 ); return l 1 +l 2 ; }
  67. 67. Soft Shadow Maps <ul><ul><li>Shadow & visibility maps only need to be re-computed if light and/or scene changes </li></ul></ul><ul><ul><li>Minimal overhead for “static walkthroughs” </li></ul></ul>
  68. 68. Soft Shadow Maps
  69. 69. Soft Shadow Maps
  70. 70. Conclusion <ul><li>Without shadows there is no realism </li></ul><ul><li>Good looking shadows are expensive </li></ul><ul><ul><li>Global effect </li></ul></ul><ul><li>Choice of algorithm depends on application </li></ul><ul><ul><li>Use CPU resources ? </li></ul></ul><ul><ul><li>Use hardware resources ? </li></ul></ul><ul><ul><li>Scene complexity </li></ul></ul><ul><ul><li>Shadow quality </li></ul></ul>
  71. 71. Thank you !

×