Upload
marco-salvi
View
3.596
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques
Citation preview
Probabilistic Approaches to Shadow Maps FilteringMarco SalviPS3 EngineerLucasArts
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
N
i
ni
nn x
NxE
1
1
x
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 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 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
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 mean and variance
• Fit it to first two moments
21,mm
2
212
2
1
222
1
mm
m
m
m
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
2
21
2
recverf
occl
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
R
OEROPOcclusion
OE
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:
1.Translation dependant (absolute LB)2.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
)(
)()()(
Rf
OfERfOfP
nx
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: xfkxf
dx
d
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
kxeCxf depthk exp
Exponential 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
XYYX ewwxewew 1010 ln
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&AIf you have any question, please contact me:email: [email protected]: 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