SlideShare a Scribd company logo
 
Probabilistic Approaches to Shadow Maps Filtering Marco Salvi PS3 Engineer LucasArts v1.0
Talk Breakdown Motivations and previous work VSM extensions to many moments PDFs models Higher order moments Exponential shadow maps Conclusions and Q&A
Motivations PCF  is very popular, but.. ..need many samples to fight aliasing ..only  scales linearly with sample count ..difficult to re-use previous computations on neighbouring pixels Can we do any better than  PCF ? ultimately inspired by VSM paper
Statistics 101 (in a slide..  ) Probability Density Function ( PDF ) of a random variable Describe the probability that a random event can take place. Raw  nth  moment
Previous Work   Variance Shadow Maps (1/2) Depth samples are seen as an  (unknown a priori)   PDF PDF represented by first two raw moments, pre-filterable with separable filters! moments can be  hw  filtered and mip-mapped Occlusion as an  upper bound  for probability of being in shadow Chebyshev ’s inequality ( CI )
Previous Work   Variance Shadow Maps (2/2) Light bleeding Only two moments  are not enough  to represent any PDF
Many Moments  (1/2) Natural  extension to VSM to compute extra moments is  easy Generalize  CI  to higher moments a  very tough  problem First 3 rd  and 4 th  order moments inequalities exist.. ..expensive to evaluate
Many Moments  (2/2) Numerical accuracy issues with computations involving higher order moments Would need double precision math VSM still more robust/looks better These naïve extensions to VSM simply don’t work very well
PDFs Models  (1/5) We can adopt an  a priori  distribution model for our PDFs Abandon inequalities and compute occlusion evaluating model’s  CDF Many distribution types available Dirac, triangular, gauss , etc.. N ‘free’ parameters:  mean, variance, skewness, kurtosis , etc..
PDFs Models  (2/5) Rendering steps Render N moments Mip map and filter them! Use  method of moments  to fit a distribution to its moments Solve a  (sometimes non) linear  NxN system of equations Evaluate  CDF  to compute the  occlusion term
PDFs Models  (3/5) A simple example Normal distribution as PDF model A function of mean  and variance  Fit it to first two moments
PDFs Models  (4/5) A simple example Occlusion  (CDF) is a function of mean, variance and receiver depth Image quality comparable to VSM Same light bleeding issues
PDFs Models  (5/5) Other models possible For example mixtures of two  Dirac  or  Normal  distributions (3 and 5 free parameters) Require to render more moments and to iteratively solve  (per pixel)  complex non linear systems
Higher Order Moments  (1/6) Markov’s Inequality ( MI ) First order moment  represents the whole depth distribution
Higher Order Moments  (2/5)
Higher Order Moments  (3/6) No VSM-like light bleeding  Because  variance  is not used Markov’s upper bound is not good, it converges to zero too slowly Light bleeds everywhere,  two LB types : Translation dependant  (absolute LB) Translation independent  (relative LB)
Higher Order Moments  (4/6) MI  still holds if its terms are replaced with  f(x) ,  a positive and monotonically increasing function : A good candidate for  f(x)  is
Higher Order Moments  (5/6) Varying  n   we get  higher order moments : No pre-filtering,  one  sample per pixel
Higher Order Moments  (6/6) Higher order moments reduce light bleeding with  no over darkening A very simple algorithm Render  only one  moment MI  can be evaluated with a  single filtered sample and one division
Exponential  Shadow Maps  (1/7) How to remove absolute light bleeding? Need a new  f(x)  that makes  MI   invariant under translations It can be shown that such a function has to satisfy the following equation:
Exponential  Shadow Maps  (2/7) The previous well known differential equation admits a simple solution: Yes, we have to render As with  VSMs  we can still pre-filter and sample the ( exponential ) shadow map in the usual ways
Exponential  Shadow Maps  (3/7) 512 x 512 x 4 bytes (fp32) 5 x 5  box filter,  4  separable passes
Exponential  Shadow Maps  (4/7) Runs out of range pretty soon ln (max_fp32) ≈ 88  Workaround: render linear depth and pre-filter in  ln space: Pre-filtering is still very fast and it also simplifies occlusion computations
Exponential  Shadow Maps  (5/7) A detour: Convolution Shadow Maps Assume  planar receiver  within a filtering region Depth test approximated via Fourier expansion Render  N  expansion terms ESM is  equivalent  to CSM where depth test is approximated with  exp(O-R) Render  only one  term! Potential light bleeding  with no planar receiver Can be reduced via over-darkening
Exponential  Shadow Maps  (6/7) Overdarkening can reduce light bleeding
Exponential  Shadow Maps  (7/7) Tweak amount of  relative LB with a scale factor  K : Over darken shadows to control LB due to not planar receivers: occluder =  K  * depth occlusion = exp( Ko  *(filtered_occluder-receiver))
Conclusions  (1/2) All techniques presented: Allow to use separable filters and hardware filtering & mipmaps support Reduce shadow maps aliasing Are orthogonal to  exotic  shadow maps projection schemes ( LiSPSM, TSM, ... ) Greatly reduce self-shadowing and shadow maps acne artifacts
Conclusions  (2/2) No presented technique is entirely satisfactory Must get rid of light bleeding associated to non planar receivers High order and exponential shadow maps A  lot  of work still to be done! Hope to have inspired you  
Q&A If you have any question, please contact me: email:  [email_address] blog:  http://pixelstoomany.wordpress.com For more details about  Exponential Shadow Maps  please refer to: “ Rendering Filtered Shadows with Exponential Shadow Maps” Marco Salvi,  ShaderX6 ,  edited by W. Engel. Charles River Media, 2008 .
Bibliography  (1/2) [Williams83] Williams, Lance. “Pyramidal Parametrics”,  SIGGRAPH83 Proceedings , Vol. 17, No. 3, July 1983".  [Reeves87] William T. Reeves, David H. Salesin, Robert L. Cook “Rendering anti aliased shadows with depth maps”,  SIGGRAPH87 Proceedings , (July, 1987), pp. 283-291[Lokovic00] Tom Lokovic and Eric Veach, “Deep Shadow Maps.”  SIGGRAPH 2000 Proceedings  (August 2000), Addison-Wesley.  [Philips95] Thomas K. Philips, Randolph Nelson, “The Moment Bound Is Tighter Than Chernoff's Bound for Positive Tail Probabilities”,  The American Statistician , Vol. 49, No. 2 (May, 1995), pp. 175-178  [Lokovic00] Tom Lokovic and Eric Veach, “Deep Shadow Maps.”  SIGGRAPH 2000 Proceedings  (August 2000), Addison-Wesley.  [Amour04] Jean-Francois St. Amour, Eric Paquette, et al.”Real Time Soft Shadows Using the PDSM Technique.”  ShaderX4,  edited by W. Engel. Charles River Media, Hingham, MA, 2005. [Martin04] Tobias Martin and Tiow-Seng Tan ,”Anti-aliasing and Continuity with Trapezoidal Shadow Maps”,  Proceedings of Eurographics Symposium on Rendering , 21-23 June 2004, Norrköping, Sweden, page 153-160 (text) and page 412 (color plate)
Bibliography  (2/2) [Wimmer04] Michael Wimmer, Daniel Scherzer, Werner Purgathofer, “Light Space Perspective Shadow Maps” ,  Eurographics Symposium on Rendering  2004    [Schueler05] Schueler, Christian. “Eliminating Surface Acne with Gradient Shadow Mapping.”  ShaderX4 , edited by W. Engel. Charles River Media, Hingham, MA, 2005.   [Donnelly06] William Donnelly, Andrew Lauritzen, “Variance Shadow Maps”  Symposium on Interactive 3D Graphics and Games Proceedings  (2006), ACM   [Engel06] Wolfgang Engel, “Cascaded Shadow Maps”,  ShaderX5,  edited by W. Engel. Charles River Media, Hingham, MA, 2006.   [Annen07] Thomas Annen, Tom Mertens, Philippe Bekaert, Hans-Peter Seidel, Jan Kautz, “Convolution Shadow Maps”,  Rendering Techniques 2007: Eurographics Symposium on Rendering , June 2007. [Salvi08] Marco Salvi, “Rendering Filtered Shadows with Exponential Shadow Maps”,  ShaderX6,  edited by W. Engel. Charles River Media, Hingham, MA, 2008.
Appendix  (1/2) ESM: constant light bleeding
Appendix  (2/2) ESM, distance based light bleeding

More Related Content

Probabilistic Approaches to Shadow Maps Filtering

  • 1.  
  • 2. Probabilistic Approaches to Shadow Maps Filtering Marco Salvi PS3 Engineer LucasArts v1.0
  • 3. Talk Breakdown Motivations and previous work VSM extensions to many moments PDFs models Higher order moments Exponential shadow maps Conclusions and Q&A
  • 4. Motivations PCF is very popular, but.. ..need many samples to fight aliasing ..only scales linearly with sample count ..difficult to re-use previous computations on neighbouring pixels Can we do any better than PCF ? ultimately inspired by VSM paper
  • 5. Statistics 101 (in a slide..  ) Probability Density Function ( PDF ) of a random variable Describe the probability that a random event can take place. Raw nth moment
  • 6. Previous Work Variance Shadow Maps (1/2) Depth samples are seen as an (unknown a priori) PDF PDF represented by first two raw moments, pre-filterable with separable filters! moments can be hw filtered and mip-mapped Occlusion as an upper bound for probability of being in shadow Chebyshev ’s inequality ( CI )
  • 7. Previous Work Variance Shadow Maps (2/2) Light bleeding Only two moments are not enough to represent any PDF
  • 8. Many Moments (1/2) Natural extension to VSM to compute extra moments is easy Generalize CI to higher moments a very tough problem First 3 rd and 4 th order moments inequalities exist.. ..expensive to evaluate
  • 9. Many Moments (2/2) Numerical accuracy issues with computations involving higher order moments Would need double precision math VSM still more robust/looks better These naïve extensions to VSM simply don’t work very well
  • 10. PDFs Models (1/5) We can adopt an a priori distribution model for our PDFs Abandon inequalities and compute occlusion evaluating model’s CDF Many distribution types available Dirac, triangular, gauss , etc.. N ‘free’ parameters: mean, variance, skewness, kurtosis , etc..
  • 11. PDFs Models (2/5) Rendering steps Render N moments Mip map and filter them! Use method of moments to fit a distribution to its moments Solve a (sometimes non) linear NxN system of equations Evaluate CDF to compute the occlusion term
  • 12. PDFs Models (3/5) A simple example Normal distribution as PDF model A function of mean and variance Fit it to first two moments
  • 13. PDFs Models (4/5) A simple example Occlusion (CDF) is a function of mean, variance and receiver depth Image quality comparable to VSM Same light bleeding issues
  • 14. PDFs Models (5/5) Other models possible For example mixtures of two Dirac or Normal distributions (3 and 5 free parameters) Require to render more moments and to iteratively solve (per pixel) complex non linear systems
  • 15. Higher Order Moments (1/6) Markov’s Inequality ( MI ) First order moment represents the whole depth distribution
  • 17. Higher Order Moments (3/6) No VSM-like light bleeding Because variance is not used Markov’s upper bound is not good, it converges to zero too slowly Light bleeds everywhere, two LB types : Translation dependant (absolute LB) Translation independent (relative LB)
  • 18. Higher Order Moments (4/6) MI still holds if its terms are replaced with f(x) , a positive and monotonically increasing function : A good candidate for f(x) is
  • 19. Higher Order Moments (5/6) Varying n we get higher order moments : No pre-filtering, one sample per pixel
  • 20. Higher Order Moments (6/6) Higher order moments reduce light bleeding with no over darkening A very simple algorithm Render only one moment MI can be evaluated with a single filtered sample and one division
  • 21. Exponential Shadow Maps (1/7) How to remove absolute light bleeding? Need a new f(x) that makes MI invariant under translations It can be shown that such a function has to satisfy the following equation:
  • 22. Exponential Shadow Maps (2/7) The previous well known differential equation admits a simple solution: Yes, we have to render As with VSMs we can still pre-filter and sample the ( exponential ) shadow map in the usual ways
  • 23. Exponential Shadow Maps (3/7) 512 x 512 x 4 bytes (fp32) 5 x 5 box filter, 4 separable passes
  • 24. Exponential Shadow Maps (4/7) Runs out of range pretty soon ln (max_fp32) ≈ 88 Workaround: render linear depth and pre-filter in ln space: Pre-filtering is still very fast and it also simplifies occlusion computations
  • 25. Exponential Shadow Maps (5/7) A detour: Convolution Shadow Maps Assume planar receiver within a filtering region Depth test approximated via Fourier expansion Render N expansion terms ESM is equivalent to CSM where depth test is approximated with exp(O-R) Render only one term! Potential light bleeding with no planar receiver Can be reduced via over-darkening
  • 26. Exponential Shadow Maps (6/7) Overdarkening can reduce light bleeding
  • 27. Exponential Shadow Maps (7/7) Tweak amount of relative LB with a scale factor K : Over darken shadows to control LB due to not planar receivers: occluder = K * depth occlusion = exp( Ko *(filtered_occluder-receiver))
  • 28. Conclusions (1/2) All techniques presented: Allow to use separable filters and hardware filtering & mipmaps support Reduce shadow maps aliasing Are orthogonal to exotic shadow maps projection schemes ( LiSPSM, TSM, ... ) Greatly reduce self-shadowing and shadow maps acne artifacts
  • 29. Conclusions (2/2) No presented technique is entirely satisfactory Must get rid of light bleeding associated to non planar receivers High order and exponential shadow maps A lot of work still to be done! Hope to have inspired you 
  • 30. Q&A If you have any question, please contact me: email: [email_address] blog: http://pixelstoomany.wordpress.com For more details about Exponential Shadow Maps please refer to: “ Rendering Filtered Shadows with Exponential Shadow Maps” Marco Salvi, ShaderX6 , edited by W. Engel. Charles River Media, 2008 .
  • 31. Bibliography (1/2) [Williams83] Williams, Lance. “Pyramidal Parametrics”, SIGGRAPH83 Proceedings , Vol. 17, No. 3, July 1983". [Reeves87] William T. Reeves, David H. Salesin, Robert L. Cook “Rendering anti aliased shadows with depth maps”, SIGGRAPH87 Proceedings , (July, 1987), pp. 283-291[Lokovic00] Tom Lokovic and Eric Veach, “Deep Shadow Maps.” SIGGRAPH 2000 Proceedings (August 2000), Addison-Wesley. [Philips95] Thomas K. Philips, Randolph Nelson, “The Moment Bound Is Tighter Than Chernoff's Bound for Positive Tail Probabilities”, The American Statistician , Vol. 49, No. 2 (May, 1995), pp. 175-178 [Lokovic00] Tom Lokovic and Eric Veach, “Deep Shadow Maps.” SIGGRAPH 2000 Proceedings (August 2000), Addison-Wesley. [Amour04] Jean-Francois St. Amour, Eric Paquette, et al.”Real Time Soft Shadows Using the PDSM Technique.” ShaderX4, edited by W. Engel. Charles River Media, Hingham, MA, 2005. [Martin04] Tobias Martin and Tiow-Seng Tan ,”Anti-aliasing and Continuity with Trapezoidal Shadow Maps”, Proceedings of Eurographics Symposium on Rendering , 21-23 June 2004, Norrköping, Sweden, page 153-160 (text) and page 412 (color plate)
  • 32. Bibliography (2/2) [Wimmer04] Michael Wimmer, Daniel Scherzer, Werner Purgathofer, “Light Space Perspective Shadow Maps” , Eurographics Symposium on Rendering 2004   [Schueler05] Schueler, Christian. “Eliminating Surface Acne with Gradient Shadow Mapping.” ShaderX4 , edited by W. Engel. Charles River Media, Hingham, MA, 2005.   [Donnelly06] William Donnelly, Andrew Lauritzen, “Variance Shadow Maps” Symposium on Interactive 3D Graphics and Games Proceedings (2006), ACM   [Engel06] Wolfgang Engel, “Cascaded Shadow Maps”, ShaderX5, edited by W. Engel. Charles River Media, Hingham, MA, 2006.   [Annen07] Thomas Annen, Tom Mertens, Philippe Bekaert, Hans-Peter Seidel, Jan Kautz, “Convolution Shadow Maps”, Rendering Techniques 2007: Eurographics Symposium on Rendering , June 2007. [Salvi08] Marco Salvi, “Rendering Filtered Shadows with Exponential Shadow Maps”, ShaderX6, edited by W. Engel. Charles River Media, Hingham, MA, 2008.
  • 33. Appendix (1/2) ESM: constant light bleeding
  • 34. Appendix (2/2) ESM, distance based light bleeding