Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fast Cascade VSM By Zhang Jian.

Similar presentations


Presentation on theme: "Fast Cascade VSM By Zhang Jian."— Presentation transcript:

1 Fast Cascade VSM By Zhang Jian

2 Dynamic Shadow Tech Shadow Volume Shadow Map PCF VSM CSM ESM PSM LiPSM
Basic Algorithm PCF VSM CSM ESM Soft Shadow PSM LiPSM TSM CSM Perspective Alias Convolution Shadow Cascaded Shadow trap·e·zoid PSSM 2D CSM 3D CSM Cascade Selection Per Object Shadow Deferred Shadow Rendering Stage

3 Outline Basic Shadow Map and problems Variance Shadow Map
Cascade Shadow Map In Our Engine Shadow Mask

4 1. Shadow Map Basic Idea: If a light can see a point, the point will be lit by the light.

5 1. Shadow Map 1.Render a texture by using light as a camera, that’s shadow map, the pixel value is depth value. 2. Transform the current position into shadow map space (light space), test if it’s occluded by corresponding shadow map pixel. 3. Done! ?

6 1.Shadow Map Peter panning Perspective Alias

7 1. Shadow Map Self-shadow Acne Peter panning ac·ne, ai kene
discrete buffer Orthographic projection Self-shadow Acne

8 1.Shadow Map Peter Panning

9 1.Shadow Map Hard Edge

10 1. Shadow Map Dynamic Alias: Unstable resolution( PSM)
Edge swimming effect There are bunch of shadow techniques has unstable problem, like PSM unstable is very annoying, sometimes, it is even worse than low quality.

11 2.Variance Shadow Map Soft Shadow

12 2.Variance Shadow Map Probability theory
dr is the current receiver depth d0 is the random variable to represent the occluder depth. VSM is based on Probability theory. Treat Shadow map depth as a random variable , Represents the occluder depth distribution function Our goal : define some states between shadow and lit.

13 2.Variance Shadow Map Chebyshev’s inequality (when dr > μ)
moments M 1 and M 2 μis mean σ2 is variance, sigma squre

14 2.Variance Shadow Map Understand VSM by your way.
float d = ( vLightSpacePos.z ) - Depth; float p_Shadow = 1; if (d > 0) { float variance = ( DepthSquare ) - ( Depth * Depth ); p_Shadow = variance / ( variance + d*d );} moments M 1 and M 2 μis mean σ2 is variance

15 VSM In Our Engine Render Z and Z2 into a 2 channels render target
G16R16 ( hardware filter, 1 cycle) 4x MSAA on Xenon ( Free, No predict-tilling) RGBA8 on PC ( may provide multiple solutions for difference GPU) Prefilter: 2 pass Gaussian blur Generate Mipmaps on Xenon. VSM shadow testing.

16 2.Variance Shadow Map The good:
Very cheap Soft shadow: Support Pre-filter, Blur == PCF. Much Better self shadow quality ( solve the shadow bias perfectly) The ability to use high quality texture filter( trilinear, anistropic filter) Remember the dilemma between shadow bias and peter panning .

17 2.Variance Shadow Map The Bad: Light leaking.
Remember the dilemma of shadow bias and peter panning .

18 2.Variance Shadow Map Light leaking.
Reduce Geometry complexity, use Low Lod for shadow caster. Tune parameters.(remapping the result)

19 3. Cascaded Shadow Map Resolution problem

20 Cascaded Shadow Map Fix resolution problem:
if we fix shadow map resolution for conventional shadow mapping The far objects require SM cover an area as big as possible, so the far object can cast shadow. The near objects require SM cover an area as small as possible, so the near object can cover enough SM Texel's

21 Cacade Alignment What will happen if the camera direction changes. See video EdgeShrim.avi

22 Parallel Split Shadow Map

23 2D CSM

24 Z precision problem 3D CSM Side view of ViewFrustum and Light Frustum

25 Cacade Coverage Optimization
PushAway

26 Cacade Transition

27 Interlace updating

28 4. Shadow Mask Just an optimization

29 4.Shadow Mask Basic Idea

30 Shadow Mask Why? Shadow calculation can increase shader complexity a lot. For most case, it can avoid overdraw. More aggressive, Postprocess shadow multiply Why shadow mask

31 Shadow solution

32 Result Memory: ~5M( 3M Vsm + 2M shadow mask)
Performance(ShadowMap+shadowMask): 4 cascade: ms 3 cascade: ms 2 cascade: ms 1 cascade: 1.0~2.0 ms

33

34 Future Works Optimization Special Mesh LOD for shadow.
Unshadow sky Early out. Shader optimization Transparency shadow (e.g.. Smoke shadow)

35 Q&A

36 Declaration This is from one of my internal presentations. I implemented the shadow tech in our game engine, and shared tips and explanations here. It’s not an official paper, So I don’t have a reference docs list here,


Download ppt "Fast Cascade VSM By Zhang Jian."

Similar presentations


Ads by Google