Wednesday, February 10, 2016

Screen-Space Shadows

Dynamic shadows is the one of the most slowest passes in any renderer. Especially when it comes to cascading shadows that cover huge visible region and even more. The problem is in the big number of draw calls and overdraw to the depth buffer, which is especially critical in the case of flora and grass in particular. I was thinking about ways to effectively solve this problem. As the result I developed technique called Screen-space shadows, which allows us to get soft, stable and fast shadows from grass. Also Screen-space shadows could be used for building shadows from other small objects as well as from far mountains. The technique in already has been using in one great game.





Description

Because of performance reasons the calculations can be done in half screen size.
Jitter P to E marching distance using screen-space random or random texture. 16-32 samples. Result = 1 Foreach S in (E-P) If ShouldReceive(P) and ShouldCast(S) VtoS = DistanceToEye(S) VtoT = DistanceToEye(T) If VtoS < VtoT and Abs(VtoS - VtoT) < Tolerance(S) and not OutOfScreen(T) Result = ShadowAttenuation(S) or zero End If End If End Foreach

Tolerance: function of distance from V to S
ShadowAttenuation: function of distance from P to T 

Next stages: 
Temporal stabilization, which is the key of stabilization Bilateral upscale, depends on quality settings Directional blur, depends on quality settings


Results


Figure 1. Typical shadows


Figure 2. Screen-space shadows

 Figure 3. World of Tanks. No any shadows on the grass

Figure 3. World of Tanks. Screen-space shadows on the grass



No comments: