Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Probabilistic Approaches to Shadow Maps Filtering


Published on

Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques

  • Be the first to comment

Probabilistic Approaches to Shadow Maps Filtering

  1. 2. Probabilistic Approaches to Shadow Maps Filtering <ul><li>Marco Salvi </li></ul><ul><li>PS3 Engineer </li></ul><ul><li>LucasArts </li></ul>v1.0
  2. 3. Talk Breakdown <ul><li>Motivations and previous work </li></ul><ul><li>VSM extensions to many moments </li></ul><ul><li>PDFs models </li></ul><ul><li>Higher order moments </li></ul><ul><li>Exponential shadow maps </li></ul><ul><li>Conclusions and Q&A </li></ul>
  3. 4. Motivations <ul><li>PCF is very popular, but.. </li></ul><ul><ul><ul><li>..need many samples to fight aliasing </li></ul></ul></ul><ul><ul><ul><li>..only scales linearly with sample count </li></ul></ul></ul><ul><ul><ul><li>..difficult to re-use previous computations on neighbouring pixels </li></ul></ul></ul><ul><li>Can we do any better than PCF ? </li></ul><ul><ul><ul><li>ultimately inspired by VSM paper </li></ul></ul></ul>
  4. 5. Statistics 101 (in a slide..  ) <ul><li>Probability Density Function ( PDF ) of a random variable </li></ul><ul><ul><ul><li>Describe the probability that a random event can take place. </li></ul></ul></ul><ul><li>Raw nth moment </li></ul>
  5. 6. Previous Work Variance Shadow Maps (1/2) <ul><li>Depth samples are seen as an (unknown a priori) PDF </li></ul><ul><ul><ul><li>PDF represented by first two raw moments, pre-filterable with separable filters! </li></ul></ul></ul><ul><ul><ul><li>moments can be hw filtered and mip-mapped </li></ul></ul></ul><ul><li>Occlusion as an upper bound for probability of being in shadow </li></ul><ul><ul><ul><li>Chebyshev ’s inequality ( CI ) </li></ul></ul></ul>
  6. 7. Previous Work Variance Shadow Maps (2/2) <ul><li>Light bleeding </li></ul><ul><li>Only two moments are not enough to represent any PDF </li></ul>
  7. 8. Many Moments (1/2) <ul><li>Natural extension to VSM </li></ul><ul><ul><ul><li>to compute extra moments is easy </li></ul></ul></ul><ul><li>Generalize CI to higher moments </li></ul><ul><ul><ul><li>a very tough problem </li></ul></ul></ul><ul><li>First 3 rd and 4 th order moments inequalities exist.. </li></ul><ul><ul><ul><li>..expensive to evaluate </li></ul></ul></ul>
  8. 9. Many Moments (2/2) <ul><li>Numerical accuracy issues with computations involving higher order moments </li></ul><ul><ul><ul><li>Would need double precision math </li></ul></ul></ul><ul><li>VSM still more robust/looks better </li></ul><ul><ul><ul><li>These naïve extensions to VSM simply don’t work very well </li></ul></ul></ul>
  9. 10. PDFs Models (1/5) <ul><li>We can adopt an a priori distribution model for our PDFs </li></ul><ul><ul><ul><li>Abandon inequalities and compute occlusion evaluating model’s CDF </li></ul></ul></ul><ul><li>Many distribution types available </li></ul><ul><ul><ul><li>Dirac, triangular, gauss , etc.. </li></ul></ul></ul><ul><ul><ul><li>N ‘free’ parameters: mean, variance, skewness, kurtosis , etc.. </li></ul></ul></ul>
  10. 11. PDFs Models (2/5) Rendering steps <ul><li>Render N moments </li></ul><ul><ul><ul><li>Mip map and filter them! </li></ul></ul></ul><ul><li>Use method of moments to fit a distribution to its moments </li></ul><ul><ul><ul><li>Solve a (sometimes non) linear NxN system of equations </li></ul></ul></ul><ul><li>Evaluate CDF to compute the occlusion term </li></ul>
  11. 12. PDFs Models (3/5) A simple example <ul><li>Normal distribution as PDF model </li></ul><ul><ul><ul><li>A function of mean and variance </li></ul></ul></ul><ul><li>Fit it to first two moments </li></ul>
  12. 13. PDFs Models (4/5) A simple example <ul><li>Occlusion (CDF) is a function of mean, variance and receiver depth </li></ul><ul><li>Image quality comparable to VSM </li></ul><ul><ul><ul><li>Same light bleeding issues </li></ul></ul></ul>
  13. 14. PDFs Models (5/5) <ul><li>Other models possible </li></ul><ul><ul><ul><li>For example mixtures of two Dirac or Normal distributions (3 and 5 free parameters) </li></ul></ul></ul><ul><li>Require to render more moments and to iteratively solve (per pixel) complex non linear systems </li></ul>
  14. 15. Higher Order Moments (1/6) <ul><li>Markov’s Inequality ( MI ) </li></ul><ul><li>First order moment represents the whole depth distribution </li></ul>
  15. 16. Higher Order Moments (2/5)
  16. 17. Higher Order Moments (3/6) <ul><li>No VSM-like light bleeding </li></ul><ul><ul><ul><li>Because variance is not used </li></ul></ul></ul><ul><li>Markov’s upper bound is not good, it converges to zero too slowly </li></ul><ul><li>Light bleeds everywhere, two LB types : </li></ul><ul><ul><ul><li>Translation dependant (absolute LB) </li></ul></ul></ul><ul><ul><ul><li>Translation independent (relative LB) </li></ul></ul></ul>
  17. 18. Higher Order Moments (4/6) <ul><li>MI still holds if its terms are replaced with f(x) , a positive and monotonically increasing function : </li></ul><ul><li>A good candidate for f(x) is </li></ul>
  18. 19. Higher Order Moments (5/6) <ul><li>Varying n we get higher order moments : </li></ul><ul><li>No pre-filtering, one sample per pixel </li></ul>
  19. 20. Higher Order Moments (6/6) <ul><li>Higher order moments reduce light bleeding with no over darkening </li></ul><ul><li>A very simple algorithm </li></ul><ul><ul><ul><li>Render only one moment </li></ul></ul></ul><ul><ul><ul><li>MI can be evaluated with a single filtered sample and one division </li></ul></ul></ul>
  20. 21. Exponential Shadow Maps (1/7) <ul><li>How to remove absolute light bleeding? </li></ul><ul><ul><ul><li>Need a new f(x) that makes MI invariant under translations </li></ul></ul></ul><ul><li>It can be shown that such a function has to satisfy the following equation: </li></ul>
  21. 22. Exponential Shadow Maps (2/7) <ul><li>The previous well known differential equation admits a simple solution: </li></ul><ul><li>Yes, we have to render </li></ul><ul><ul><ul><li>As with VSMs we can still pre-filter and sample the ( exponential ) shadow map in the usual ways </li></ul></ul></ul>
  22. 23. Exponential Shadow Maps (3/7) 512 x 512 x 4 bytes (fp32) 5 x 5 box filter, 4 separable passes
  23. 24. Exponential Shadow Maps (4/7) <ul><li>Runs out of range pretty soon </li></ul><ul><ul><ul><li>ln (max_fp32) ≈ 88 </li></ul></ul></ul><ul><li>Workaround: render linear depth and pre-filter in ln space: </li></ul><ul><ul><ul><li>Pre-filtering is still very fast and it also simplifies occlusion computations </li></ul></ul></ul>
  24. 25. Exponential Shadow Maps (5/7) <ul><li>A detour: Convolution Shadow Maps </li></ul><ul><ul><ul><li>Assume planar receiver within a filtering region </li></ul></ul></ul><ul><ul><ul><li>Depth test approximated via Fourier expansion </li></ul></ul></ul><ul><ul><ul><li>Render N expansion terms </li></ul></ul></ul><ul><li>ESM is equivalent to CSM where depth test is approximated with exp(O-R) </li></ul><ul><ul><ul><li>Render only one term! </li></ul></ul></ul><ul><ul><ul><li>Potential light bleeding with no planar receiver </li></ul></ul></ul><ul><ul><ul><li>Can be reduced via over-darkening </li></ul></ul></ul>
  25. 26. Exponential Shadow Maps (6/7) Overdarkening can reduce light bleeding
  26. 27. Exponential Shadow Maps (7/7) <ul><li>Tweak amount of relative LB with a scale factor K : </li></ul><ul><li>Over darken shadows to control LB due to not planar receivers: </li></ul>occluder = K * depth occlusion = exp( Ko *(filtered_occluder-receiver))
  27. 28. Conclusions (1/2) <ul><li>All techniques presented: </li></ul><ul><ul><ul><li>Allow to use separable filters and hardware filtering & mipmaps support </li></ul></ul></ul><ul><ul><ul><li>Reduce shadow maps aliasing </li></ul></ul></ul><ul><ul><ul><li>Are orthogonal to exotic shadow maps projection schemes ( LiSPSM, TSM, ... ) </li></ul></ul></ul><ul><ul><ul><li>Greatly reduce self-shadowing and shadow maps acne artifacts </li></ul></ul></ul>
  28. 29. Conclusions (2/2) <ul><li>No presented technique is entirely satisfactory </li></ul><ul><li>Must get rid of light bleeding associated to non planar receivers </li></ul><ul><ul><ul><li>High order and exponential shadow maps </li></ul></ul></ul><ul><li>A lot of work still to be done! </li></ul><ul><ul><ul><li>Hope to have inspired you  </li></ul></ul></ul>
  29. 30. Q&A <ul><li>If you have any question, please contact me: </li></ul><ul><li>email: [email_address] </li></ul><ul><li>blog: </li></ul><ul><li>For more details about Exponential Shadow Maps please refer to: </li></ul><ul><li>“ Rendering Filtered Shadows with Exponential Shadow Maps” </li></ul><ul><li>Marco Salvi, ShaderX6 , edited by W. Engel. Charles River Media, 2008 . </li></ul>
  30. 31. Bibliography (1/2) [Williams83] Williams, Lance. “Pyramidal Parametrics”, SIGGRAPH83 Proceedings , Vol. 17, No. 3, July 1983&quot;. [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)
  31. 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.
  32. 33. Appendix (1/2) <ul><li>ESM: constant light bleeding </li></ul>
  33. 34. Appendix (2/2) <ul><li>ESM, distance based light bleeding </li></ul>