Single Sample Soft Shadows Using Depth Maps


Published on

Talk given @ Graphics Interface 2002, Calgary, CA

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Single Sample Soft Shadows Using Depth Maps

  1. 1. Single Sample Soft Shadows Using Depth Maps Stefan Brabec and Hans-Peter Seidel Max-Planck-Institut f ür Informatik
  2. 2. Overview <ul><li>Introduction </li></ul><ul><li>Single sample soft shadows with depth maps </li></ul><ul><li>Implementation </li></ul><ul><li>Results </li></ul><ul><li>Conclusion & Future Work </li></ul>
  3. 3. Introduction <ul><li>Good-looking shadows greatly improve quality of rendered images </li></ul><ul><li>For interactive applications mostly hard-shadows are used </li></ul>
  4. 4. Hard vs. Soft Shadows <ul><li>Hard Shadows </li></ul><ul><ul><li>Point light / directional light </li></ul></ul><ul><ul><li>Fast rendering </li></ul></ul><ul><ul><ul><li>Shadow Volumes, Shadow Mapping … </li></ul></ul></ul><ul><li>Soft Shadows </li></ul><ul><ul><li>Area light / volume light </li></ul></ul><ul><ul><li>Slow rendering… </li></ul></ul><ul><ul><ul><li>Sampling the light source </li></ul></ul></ul>
  5. 5. Soft Shadows <ul><li>E.g. sampling the area light source: </li></ul><ul><ul><li>Needs a number of hard-shadow calculations and accumulates the results </li></ul></ul><ul><ul><li>More samples gives smoother penumbra </li></ul></ul>many samples = expensive rendering
  6. 6. Soft Shadow Example <ul><li>Ground plane shadows </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
  7. 7. Parker’s Method <ul><li>Soft shadows for point lights </li></ul><ul><ul><li>Adding an outer hull to an object </li></ul></ul><ul><ul><li>Rays inside outer hull are attenuated </li></ul></ul>
  8. 8. Parker’s Method <ul><li>Each ray is attenuated according to distance to inner object </li></ul>
  9. 9. Parker’s Method <ul><li>Pros </li></ul><ul><ul><li>Minimal overhead for ray casting (speed & implementation work) </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Not suitable for hardware rendering </li></ul></ul><ul><ul><li>Adds only an outer penumbra very thick shadows </li></ul></ul>
  10. 10. Our Method <ul><li>Parker’s idea adapted for hardware rendering ? </li></ul><ul><ul><li>Use sampled input data (depth maps) </li></ul></ul><ul><ul><ul><li>Shadow map algorithm </li></ul></ul></ul><ul><ul><li>Concept of extended occluders </li></ul></ul><ul><ul><ul><li>Search for hard shadow/lit regions </li></ul></ul></ul><ul><ul><li>But: </li></ul></ul><ul><ul><ul><li>Penumbra for outer and inner regions </li></ul></ul></ul>
  11. 11. Shadow Mapping <ul><li>Render depth map from light position </li></ul><ul><li>Render from camera and compare transformed z coordinate with depth stored in light’s depth map </li></ul>
  12. 12. Shadow Mapping
  13. 13. Computing Hard Shadows <ul><li>Given two depth maps (light & cam) we compute shadows as </li></ul>foreach(x,y) { P = (x,y,depth_camera[x,y]) P`= warp_to_light(P) if( depth_light[P` x ,P` y ] < P` z ) pixel is blocked else pixel is lit }
  14. 14. Adding Outer Penumbra <ul><li>Adding an outer penumbra region to this hard shadow: </li></ul>foreach(x,y) { P = (x,y,depth_camera[x,y]) P`= warp_to_light(P) if( depth_light[P` x ,P` y ] < P` z ) pixel is blocked else pixel is lit } lit or outer penumbra ?
  15. 15. Adding Outer Penumbra <ul><li>Add penumbra by searching for the nearest hard shadow </li></ul><ul><ul><li>Use (P` x ,P` y ) as the starting point </li></ul></ul><ul><ul><li>Search neighborhood for a nearby pixel that is in hard shadow </li></ul></ul><ul><ul><li>When a maximum search radius is reached then pixel is completely lit </li></ul></ul>
  16. 16. Adding Outer Penumbra <ul><li>Project & Search </li></ul>
  17. 17. Adding Outer Penumbra <ul><li>Assign attenuation value </li></ul><ul><ul><li>f rises up from 0 (no illum) to 1 (full illum) </li></ul></ul><ul><li>To do </li></ul><ul><ul><li>Define properties that affect size of penumbra </li></ul></ul><ul><ul><li>Integrate those into the search scheme </li></ul></ul>maximal extend hard shadow found
  18. 18. Adding Outer Penumbra <ul><li>Distance receiver/light </li></ul>larger penumbra
  19. 19. Adding Outer Penumbra <ul><li>Distance receiver/light </li></ul><ul><ul><li>Varying r max according to this distance </li></ul></ul>depth map search P ` r m a x 2 r m a x 1
  20. 20. Adding Outer Penumbra <ul><li>Distance receiver/occluder </li></ul>larger penumbra
  21. 21. Adding Outer Penumbra <ul><li>Distance receiver/occluder </li></ul><ul><ul><li>Is known when a (possible) occluder is found (inside the r max region) </li></ul></ul><ul><ul><li>Dim f based on this distance </li></ul></ul><ul><ul><li>Keep searching in r max for minimum f … </li></ul></ul>
  22. 22. Adding Outer Penumbra <ul><li>Distance receiver/occluder </li></ul>P ` r m a x depth map search
  23. 23. Outer Penumbra Algorithm search(P`) { r max = P` z f min = 1 search r inside r max found blocker at r ? r` max = r max * (P` z - depth_light[ at r]) f = clamp 01 (r/ r` max ) f min = min(f, f min ) return f min } receiver/light: receiver/occluder: foreach(x,y) { P = (x,y,depth_camera[x,y]) P`= warp_to_light(P) if( depth_light[P` x ,P` y ] < P` z ) illum = 0 else illum = search(P`) }
  24. 24. Adding Inner Penumbra <ul><li>Previous slide </li></ul><ul><ul><li>Algorithm that adds a penumbra to the hard shadow (like Parker’s method) </li></ul></ul><ul><li>Better </li></ul><ul><ul><li>Penumbra region that also smoothes the inner region </li></ul></ul>
  25. 25. Adding Inner Penumbra <ul><li>Search scheme can also be applied to inner regions </li></ul>c is user defined constant where inner and outer meet (e.g. 0.5) f  [0.0;c) f  [c;1.0] Attenuation depth_light[…] – depth_light[P` x , P` y ] P` z - depth_light[…] r`max = rmax * lit pixels blocked pixels Search for pixel is blocked pixel is lit Search when Inner Penumbra Outer Penumbra
  26. 26. Self Shadowing Problem <ul><li>Problem when searching with constant P` z </li></ul><ul><ul><li>Surface can shadow itself </li></ul></ul>
  27. 27. Self Shadowing Problem <ul><li>Solutions </li></ul><ul><ul><li>Divide scene into disjunct occluders and receivers </li></ul></ul><ul><ul><li>Better: additional search criterion </li></ul></ul><ul><ul><ul><li>Assign object IDs (like Hourcade) </li></ul></ul></ul><ul><ul><ul><li>IDs should group logical, spatially related objects </li></ul></ul></ul><ul><ul><ul><li>Outer penumbra search: id_light[..] != P` ID </li></ul></ul></ul><ul><ul><ul><li>Inner penumbra search: id_light[..] == P` ID </li></ul></ul></ul>
  28. 28. Self Shadowing Problem <ul><li>Object IDs </li></ul><ul><ul><li>May also fail if distinct objects are nearly adjacent </li></ul></ul><ul><ul><li>No self-shadowing with soft shadows </li></ul></ul><ul><ul><ul><li>Use hard shadow for such cases </li></ul></ul></ul><ul><ul><li>No automatic ID assignment (yet) </li></ul></ul><ul><ul><ul><li>Simply used scene graph structure </li></ul></ul></ul>
  29. 29. Implementation <ul><li>Generating the input data </li></ul><ul><ul><li>Render depth + id map from light source position </li></ul></ul><ul><ul><ul><li>e.g. store (ID mod 256) in stencil buffer and read back 24/8 packed depth_stencil </li></ul></ul></ul><ul><ul><li>Render depth + id map from camera position </li></ul></ul>
  30. 30. Implementation <ul><li>Shadow computation </li></ul><ul><ul><li>Render light & camera id/depth map </li></ul></ul><ul><ul><ul><li>read back to host memory </li></ul></ul></ul><ul><ul><li>Perform search </li></ul></ul><ul><ul><li>Result: attenuation map (window resolution) </li></ul></ul><ul><ul><li>Use attenuation map to modulate light source contribution </li></ul></ul>
  31. 31. Implementation <ul><li>Subpixel Accuracy </li></ul><ul><ul><li>Keep fractional part when warping P to P` </li></ul></ul><ul><ul><li>Reduces quantization artifacts </li></ul></ul>
  32. 32. Implementation <ul><li>Adaptive Sampling </li></ul><ul><ul><li>Reduce number of searches </li></ul></ul><ul><ul><li>Start with one search per NxN block </li></ul></ul><ul><ul><li>Refine when </li></ul></ul><ul><ul><ul><li>Object IDs differ </li></ul></ul></ul><ul><ul><ul><li>Hard shadow results differ </li></ul></ul></ul><ul><ul><li>If not, interpolate region </li></ul></ul><ul><ul><li>Row / Column refinement </li></ul></ul>
  33. 33. Implementation <ul><li>Example: ID of 3 differs from rest </li></ul>
  34. 34. Results 10 to 15 (AMD 1GHz + GF3) FPS 256x256 Light depth/id map 512x512 Window resolution
  35. 35. Results Soft shadow with outer penumbra only Soft shadow Hard shadow
  36. 36. Results FPS ~20 (Dual P4 + GF4) Light depth/id map 512x125 Window resolution 512x512
  37. 37. Results
  38. 38. Results
  39. 39. Conclusions <ul><li>Good looking, soft penumbra regions using only information obtained from a single light source sample </li></ul><ul><li>Independent of scene complexity </li></ul><ul><ul><li>like shadow mapping </li></ul></ul><ul><li>Runs at interactive frame rates </li></ul><ul><li>Also suitable for ray tracing </li></ul>
  40. 40. Future Work <ul><li>Control of penumbra size </li></ul><ul><ul><li>Frustum settings / r max affect size </li></ul></ul><ul><ul><ul><li>Better: define area light in scene units </li></ul></ul></ul><ul><li>Cases where object ID method fails </li></ul><ul><ul><li>Nearby objects </li></ul></ul><ul><ul><li>Self-shadowing with soft shadows ? </li></ul></ul><ul><li>Speed-Up </li></ul><ul><ul><li>Distance map ? </li></ul></ul>
  41. 41. Thank You !