Probabilistic Approaches to Shadow Maps Filtering (Marco Salvi - GDC 2008)

Download Probabilistic Approaches to Shadow Maps Filtering (Marco Salvi - GDC 2008)

Post on 26-Oct-2014

108 views

Category:

Documents

2 download

Embed Size (px)

TRANSCRIPT

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

| |== =NininnxNx E11xPrevious 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 Chebyshevs 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 3rd and 4th 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 nave extensions to VSM simply dont work very well PDFs Models (1/5) We can adopt an a priori distribution model for our PDFs Abandon inequalities and compute occlusion evaluating models CDF Many distribution types available Dirac, triangular, gauss, etc.. N free parameters: mean, variance, skewness, kurtosis, etc.. PDFs Models (2/5) Rendering steps 1. Render N moments Mip map and filter them! 2. Use method of moments to fit a distribution to its moments Solve a (sometimes non) linear NxN system of equations 3. Evaluate CDF to compute the occlusion term PDFs Models (3/5) A simple example Normal distribution as PDF model A function of meanand variance Fit it to first two moments ( )2 1, m m2o == + ==21 2212 221m mmmmoo 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 2212(((

||.|

\|+=o recverfocclPDFs 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) Markovs Inequality (MI) First order moment represents the whole depth distribution ( )| |RO ER O P Occlusion s > =| | O EHigher Order Moments (2/5) Higher Order Moments (3/6) No VSM-like light bleeding Because variance is not used Markovs upper bound is not good, it converges to zero too slowly Light bleeds everywhere, two LB types: 1. Translation dependant (absolute LB) 2. Translation independent (relative LB) Higher Order Moments (4/6) MI still holds if its terms are replaced withf(x), a positive and monotonically increasing function : A good candidate for f(x) is ( )| |) () () ( ) (R fO f ER f O f P s >nxHigher 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: ( ) ( ) x f k x fdxd =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 ( )kxe C x f =( ) depth k expExponential Shadow Maps (3/7) 512x512x4 bytes (fp32) 5x5 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 ( )X Y Y Xe w w x e w e w+ + +1 0 1 0lnExponential 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 ofrelative LB with a scale factorK: 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: marcotti@gmail.com 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, Norrkping, 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