Sample Based Visibility for Soft Shadows using Alias-free Shadow Maps

birdsowlSoftware and s/w Development

Dec 2, 2013 (3 years and 8 months ago)

72 views

Sample Based Visibility for Soft
Shadows using Alias
-
free Shadow Maps

Erik Sintorn


erik.sintorn@chalmers.se

Ulf Assarsson


uffe at chalmers dot se

ElmarEisemann


elmar.eisemann@inrialpes.fr

Introduction


Shadow Map Aliasing

A common technique for rendering shadows is Shadow Maps
(Williams L, 1978)

Scene rendered as seen

from camera

Scene rendered as seen

from light

Depth of closest fragments

Are rendered to shadow

map

Several screen samples end

Up in the same light
-
space

texel

Introduction


Shadow Map Aliasing (cont)


To get rid of aliasing several methods have been suggested


Shadow Volumes (Crow F C, 1977)


Methods for better adaption of shadow map


Martin T, Tan T.
-
S: Antialiasing and continuity with trapezoidal shadow
maps


Wimmer M, Scherzer D, Purgathofer W: Light space perspective
shadow maps


Lefohn A E, Sengupta S, Owens J D: Resolution mapped shadow maps


Alias free shadow maps


Aila T, Laine S: Alias free shadow maps


Johnson G S, Lee J, Burns C A, Mark W R: The irregular z
-
buffer:
Hardware acceleration for irregular data structures


Arvo J, Alias free shadow maps using graphics hardware

Introduction


Soft Shadows


There is no such thing as point lights

umbra

umbra

penumbra

Introduction


Soft Shadows


In raytracing, several random rays are shot towards the light volume

Introduction


Soft Shadows (cont)


Very much work has been done on soft
shadows


The papers most related to ours are:


Laine S, Aila T, Assarsson U, Akenine
-
Möller T: Soft
Shadow Volumes for ray tracing.


Lethinen J, Laine S, Aila T: An improved physically
based soft shadow algorithm.


Eisemann E, Décorét X: Visibility Sampling on GPU
and applications

Alias Free Hard Shadows

Transform and project view
-
samples into lightspace,
then store in a compact datastructure with a list per
lightspacetexel

1: Construction of Alias Free Shadow Map

Alias Free Hard Shadows

Render all geometry (conservatively) from lights point of view

and for each generated fragment, test all view
-
samples in that list

against the triangle and set the corresponding bit in the output

if occluding.

1:

2: Usage of Alias Free Shadow Map

Alias Free Hard Shadows

Finally, use the result from the previous step

and the SM datastructure in a fullscreen pass

over the camera
-
view image to find shadowing

information for each pixel

1:

2:

3: Applying shadow map

Alias Free Hard Shadows

1:

2:

3:

Creating the SM Data Structure in CUDA

Atomically increase
the size for the
corresponding list

2

3

0

0

1

0

0

1

1

2

1

0

1

0

1

0

1

1

0

2

Transform light sample to light space

And save the
previous value for
each view
-
sample

0

1

0

1

2









0





















Kernel

Alias Free Hard Shadows

1:

2:

3:

Creating the SM Data Structure in CUDA

2

3

0

0

1

0

0

1

1

2

1

0

1

0

1

0

1

1

0

2

0

2

5

5

5

6

6

6

7

8

10 11 11 12 12

13 13 14 15 15

Running

Sum Scan

2

2

Alias Free Hard Shadows

1:

2:

3:

Creating the SM Data Structure in CUDA

2

3

0

0

1

0

0

1

1

2

1

0

1

0

1

0

1

1

0

2

0

2

5

5

5

6

6

6

7

8

10 11 11 12 12

13 13 14 15 15

0

1

0

1

2









0





















The size of each
list

Starting index of
each list

List index of each
view
-
sample

Compact array of
lists

Resulting SM Data Structure:

Alias Free Hard Shadows

1:

2:

3:

Render geometry in lightspace, like classic Shadow Maps but:

For each triangle

For each generated fragment


Fragment coordinates gives us size of list and list pointer

Loop over all samples and set corresponding bit if
triangle occludes sample


Blending with OR operation finally gives us occlusion information for
each view sample

2

3

0

0

1

0

0

1

1

2

1

0

1

0

1

0

1

1

0

2

0

1

0

1

2









0





















Alias Free Hard Shadows

1:

2:

3:

2

3

0

0

1

0

0

1

1

2

1

0

1

0

1

0

1

1

0

2

0

1

0

1

2









0





















In a final pass we draw a fullscreen quad over the image

For each pixel, the view
-
sample is obtained and is reprojected into lightspace

With the lightspace coordinates we can look
-
up the occlusion result

The list index for each sample tells us which bit to check

Draw shadow if bit is set

Conservative Rasterization


We use a simplified version of Jon
Hasselgren,TomasAkenineMöllers and LennartOlssons
method from GPU gems 2, with the modification that we:


Always output six vertices per triangle


Easily implemented in a geometry shader


Can be overconservative by at most one pixel per vertex

Alias free hard shadows results

44k triangles, 66 fps

Tiny demo

Soft Shadows


To render soft shadows we need only minor
changes to the last two steps of the algorithm

1:

2:

3:

umbra

penumbra

Soft Shadows


To render soft shadows we need only minor
changes to the last two steps of the algorithm

1:

2:

3:

1

0

1

0

0

0

1

0

1

1

0

1

1

0

1



View Sample: 1 2 3 4 5 6 7 8 9 10 11 12



n

Visibility of view
-
sample 11 from light source

Occlusion result for hard shadows:

1

0

1

0

0

0

1

0

1

1

0

1

1

0

1



View Sample: 1 2 3


N

Visibility of view
-
sample 3 from light
-
sample 3

Light Sample: 1 2 3 4 1 2 3 4 1 2 3 4


… 2 3 4

Occlusion result for soft shadows:

Soft Shadows


Finding occlusion results for all light
-
samples

1:

2:

3:

Light Samples

View
-
sample

Soft Shadows


Plane makes two angles and a distance with
the light source

1:

2:

3:

distance

Soft Shadows


Plane makes two angles and a distance with
the light source

1:

2:

3:

Soft Shadows


Texture lookup gives us all samples NOT
occluded: texelFetch(d,
ϕ, θ)=0000
1
0000

1:

2:

3:

Soft Shadows

1:

2:

3:

0000
1
0000

0
111
00000

000000
111

OR

OR

000110111

0
111
1
0
111

0
11
11
11
11

000
1
1
1111

1
111
1
0
111

AND

AND

AND

0
111
1
0
111

Edge results are OR:ed

for each triangle

Triangle results are AND:ed

per view
-
sample

Soft Shadows

1:

2:

3:

Receiver Plane

Volumetric Light Source

Influence Region

Soft Shadows

1:

2:

3:

2

3

0

0

1

0

0

1

1

2

1

0

1

0

1

0

1

1

0

2

0

1

0

1

2









0





















The shadow is now written as the fraction of bits set in the occlusion

test result for each fragment

Results

Results

256 light samples, ~6k triangles

Results

379k triangles:

Shadow Rays (P4 3.06 GHZ): 964 seconds

Modelled by SamuliLaine

Soft Shadow Volumes: 75 seconds


Soft Shadows using alias free shadow maps: 1.5 sec


Demo