Docsity

Advanced Soft Shadow Mapping Techniques | CAP 4720, Study notes of Computer Graphics

Partial preview of the text

Download Advanced Soft Shadow Mapping Techniques | CAP 4720 and more Study notes Computer Graphics in PDF only on Docsity!

Advanced

Soft Shadow Mapping

Techniques

Louis Bavoil

NVIDIA Developer Technology

Why Shadow Mapping for SoftShadows?!

Most popular technique for shadows in games

! Purely image-based technique ! Works with any rasterizable geometry !

Alternative techniques exist

! Silhouette based techniques such as smoothies andpenumbra wedges ! Silhouette detection robustness issues ! Do not work with alpha-tested geometry

Outline!

Fixed-Size Penumbra

! PCF (Percentage Closer Filtering) ! VSM (Variance Shadow Maps) ! CSM (Convolution Shadow Maps) ! ESM (Exponential Shadow Maps) !

Variable-Size Penumbra

! PCSS (Percentage Closer Soft Shadows) ! PCSS + VSM/CSM ! Backprojection

Percentage Closer Filtering (PCF) !

Sample the result of (d<z) around projected point

! Filter the binary results in a given kernel !

Bilinear PCF

! NVIDIA and recent AMD GPUs implement 2x2 PCF in one fetch ! Using same sample locations and weights as for bilinear filtering

Using Bilinear PCF with DX

Texture2D tDepthMap; SamplerComparisonState ShadowSampler { ComparisonFunc = LESS; Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT; }; // … sum += tDepthMap. SampleCmpLevelZero (ShadowSampler, uv + offset, z);

Irregular PCF!

PCF with large kernels requires many samples

!

Using irregular sampling

! Trades banding for noise regular sampling irregular sampling

PCF Self-Shadowing Issue!

Traditional depth bias: write (z + bias) in shadow map

! Bias = constant bias + slope-based bias ! Issue: huge depth biases may be required for large PCF kernels

P

z d depth bias should increase Ground plane False occlusion ( z < d )

Backfaces and Large PCF kernels!

Rendering backfaces into shadow map generateslight bleeding for large PCF kernels

! Not due to FP precision or shadow map resolution ! But reverse of the surface acne issue

Non-Linearity of PCF!

PCF cannot be prefiltered as is

! Average( (d < z) ) != (Average( z ) < d) ! Filtering the depth buffer would smooth theheightfield of the shadow map ! Does not generate soft shadows ! May introduce artifacts !

Solutions: Approximate shadow test by a linearfunction which can be prefiltered

! Goal: blurring the shadow map to generate realisticsoft shadows

Variance Shadow Maps!

Consider depth values in the filter kernel as a depthdistribution [Donnelly06] [Lauritzen07] ! Approximate the depth values in the kernel by aGaussian distribution of mean μ and variance σ 2 ! σ 2 = E(z 2 ) – E(z) 2 ! μ = E(z) ! Probability of being lit ! Using Chebyshev’s inequality ! P(d < z) <= max( σ 2

σ 2

  • (d – μ

2 ), (d < μ

! E(X) = average of X in filter kernel ! So the VSM (z, z^2) can be prefiltered ! Can also be rendered using MSAA + resolve

VSM Visibility Function

μ d σ 2 = E(z 2 ) – E(z) 2 μ = E(z) ! Self-shadowing can be handled simply by clamping σ 2 to some small MinVariance parameter

Generating the VSM!

Can use R32G32F_FLOAT format

! Filterable format on all DX10-class graphic hardware ! Can also use FP16 [Donnelly06] !

Render (z, z

2

) to VSM texture

!

Where z is a linear distance

! Can use an orthographic projection ! z = mul(wPos, mObjectToLightOrtho).z !

Clear VSM to (MAX_Z, MAX_Z*MAX_Z)

Rendering everything into theVSM shadow map!

Images with and without plane rendered in VSM ! If receivers are not in the VSM, will blur the object texels withz = MAX_Z

Î

missing occlusion ! CSMs and ESMs also have this limitation ! Shadows look bad when blurring shadow map without everythingrendered into them VSM VSM