Algorithmen fr die Echtzeitgrafik Algorithmen fr die Echtzeitgrafik - - PowerPoint PPT Presentation

algorithmen f r die echtzeitgrafik algorithmen f r die
SMART_READER_LITE
LIVE PREVIEW

Algorithmen fr die Echtzeitgrafik Algorithmen fr die Echtzeitgrafik - - PowerPoint PPT Presentation

Algorithmen fr die Echtzeitgrafik Algorithmen fr die Echtzeitgrafik Daniel Scherzer scherzer@cg.tuwien.ac.at LBI Virtual Archeology 2 Hard Shadows Shadow Mapping: First Pass Light Shadow map Render scene from light-view and save


slide-1
SLIDE 1

2

Algorithmen für die Echtzeitgrafik Algorithmen für die Echtzeitgrafik

Daniel Scherzer

scherzer@cg.tuwien.ac.at

LBI Virtual Archeology

slide-2
SLIDE 2

Hard Shadows

slide-3
SLIDE 3

4

Light

Render scene from light-view and save depth values

Shadow map

Shadow Mapping: First Pass

slide-4
SLIDE 4

5

Shadow Mapping: Second Pass

Eye Light

Render scene from light-view and save depth values Render scene from eye-view

Transform each fragment to light source space Compare zeye with zlight value stored in shadow map zeye > zlight

fragment is in shadow

Shadow map

Eye-view

slide-5
SLIDE 5

6

Why Shadow Maps?

Independent of scene complexity

Not as fill-rate limited as shadow volumes

Only one additional (depth only) render pass Handle self-shadowing correctly Handle arbitrary shadow caster/receiver constellations Problems?

slide-6
SLIDE 6

Hard Shadows

Shadow Map Aliasing

slide-7
SLIDE 7

8

Initial sampling: shadow map rendering Reconstruction: nearest neighbor, PCF, … Resampling: combined with reconstruction

polygons shadow map (regular grid) shadowed fragments

Shadow Map as Signal Reconstruction

slide-8
SLIDE 8

9

not enough sampling information in shadow map wrong results

Shadow map samples only correct at center

Shadow Map as Signal Reconstruction

slide-9
SLIDE 9

10

Main Types of Error

Undersampling

Too low initial

sampling frequency

Oversampling

No bandlimiting

Reconstruction error

Staircase

artifacts

slide-10
SLIDE 10

11

Undersampling - Perspective Aliasing

Sufficient resolution far from the

  • bserver

Insufficient resolution near the

  • bserver

aliased

  • kay
slide-11
SLIDE 11

12

Undersampling - Projection Aliasing

Shadow receiver ~ orthogonal to shadow map

slide-12
SLIDE 12

Hard Shadows

Fighting Undersampling - Fitting

slide-13
SLIDE 13

14

Fitting: Focus the Shadow Map

[Brabec et al. 2002]

Only include relevant objects

Shadow casters Light source frustum View frustum

Better use of shadow map resolution

slide-14
SLIDE 14

15

Point light Directional light

Fitting: Focus the Shadow Map

slide-15
SLIDE 15

16

Fitting: Focus the Shadow Map

slide-16
SLIDE 16

17

Focused Unfocused

Fitting: Focus the Shadow Map

slide-17
SLIDE 17

18

Fitting: Temporal Aliasing

slide-18
SLIDE 18

19

Fitting: Temporal Aliasing

slide-19
SLIDE 19

20

Fitting: Temporal Aliasing

slide-20
SLIDE 20

21

Fitting: Temporal Aliasing

slide-21
SLIDE 21

22

Fitting vs Temporal Aliasing

Commonly used Better use of shadow map resolution One cause for temporal aliasing Temporal aliasing noticeable because of insufficient resolution → warping

slide-22
SLIDE 22

Hard Shadows

Fighting Undersampling - Warping

slide-23
SLIDE 23

24

Solution for Perspective Aliasing

Insufficient resolution near eye

aliased

  • kay
slide-24
SLIDE 24

25

Insufficient resolution near eye Redistribute values in

shadow map

Solution for Perspective Aliasing

slide-25
SLIDE 25

26

Sufficient resolution near eye Redistribute values in

shadow map

Solution for Perspective Aliasing

still okay

  • kay now
slide-26
SLIDE 26

27

Shadow Map Warping

Use an additional perspective frustum

uniform shadow map warped shadow map

slide-27
SLIDE 27

28

Perspective Shadow Maps (PSM)

[Stamminger & Drettakis 2002]

Warp frustum = view frustum

Light Space Perspective Shadow Maps (LiSPSM)

[Wimmer et al. 2004]

Warp frustum view plane orthogonal to light view plane Optimal parameter choice

Trapezoidal Shadow Maps (TSM)

[Martin & Tan 2004]

Similar to LiSPSM Parameter choice based on heuristic

Shadow Map Warping

slide-28
SLIDE 28

29

Perspective Shadow Maps

[Stamminger & Drettakis 2002]

Want to account for perspective warping of eye Shadow map in post-perspective eye space Reduce perspective aliasing world space post-perspective space

slide-29
SLIDE 29

30

PSM Problems

world space post-perspective space

Shadows from behind

slide-30
SLIDE 30

31

PSM Problems

world space post-perspective space

Shadows from behind

Require move back due to singularity Changes resulting quality of shadow

slide-31
SLIDE 31

32

Post Perspective Space - Depth

slide-32
SLIDE 32

33

Post Perspective Space – x or y

slide-33
SLIDE 33

34

Parallel Light Transformation

post-perspective world space

slide-34
SLIDE 34

35

Point Light Transformation

post-perspective world space

slide-35
SLIDE 35

36

Shadows from behind

Require move back due to singularity Changes resulting quality of shadow

Lights change their type (point/directional)

Many special cases Non-intuitive post-perspective space

View-dependent shadow quality

PSM Problems

slide-36
SLIDE 36

37

PSM Problems

Most severe: uneven z-distribution

Good near viewer, very bad far away! Can be reduced by pushing near plane away

post-perspective space world space

slide-37
SLIDE 37

38

Observation

Want to redistribute samples in shadow map Perspective transform is a good option

Supported by hardware

BUT: why choose perspective based on observer transform???

slide-38
SLIDE 38

39

Light Space Perspective Shadow Maps

Use an additional perspective frustum in light space

uniform shadow map LiSPSM shadow map

slide-39
SLIDE 39

40

Light Space

light space

slide-40
SLIDE 40

41

Advantages of LiSPSM

No singularities in relevant part of the scene

… by construction

Directional lights remain directional lights

… and direction remains the same

Points lights are converted to directional lights

… perspective point light transformation already done in light space

Easy construction, general and robust Smooth quality changes Most important: control over shadow quality

… by choice of free parameter

slide-41
SLIDE 41

42

LiSPSM Overview

Focus shadow map Construct light space Create perspective transform Apply

slide-42
SLIDE 42

43

Light and view vector define yz-plane

y z x light view

LiSPSM Fitting and Warp Construction

slide-43
SLIDE 43

44

Find a tight perspective frustum on focused region

In light space!

LiSPSM Fitting and Warp Construction

slide-44
SLIDE 44

45

LiSPSM Construction

slide-45
SLIDE 45

46

Free Parameter n

Controls warping effect

n

n infinity : uniform shadow maps n = zn : PSM

n zn

slide-46
SLIDE 46

47

Free Parameter n

very small n very big n

slide-47
SLIDE 47

48

Free Parameter n

slide-48
SLIDE 48

49

slide-49
SLIDE 49

50

Sampling Error Analysis

Aliasing error:

Parameterization Perspective Projection eye dz ds dp β α z zn

slide-50
SLIDE 50

51

How to Choose the Free Parameter n?

Recall error analysis

  • > 1 shadow map undersampling

Projection aliasing cannot be changed Counter perspective aliasing with new shadow map

parameterization s

Goal: ~ 1

slide-51
SLIDE 51

52

Error Analysis

Uniform shadow maps Perspective shadow maps

Linear increase in error!

Perfect: logarithmic re-parameterization

Hardware support? [Lloyd 2007, 2008]

s´ s´ s´

1

slide-52
SLIDE 52

53

Error Analysis: LiSPSM Optimal Choice

For LiSPSM, depends on n

Gives between uniform and perspective

Optimal choice:

ds dp ds dp

n

slide-53
SLIDE 53

54

Error Comparison

LiSPSM optimal choice Measured along view dir LiSPSM vs PSM for same depth range, LiSPSM error much lower More advanced analysis was done in [Lloyd 2006]

znear zfar

slide-54
SLIDE 54

55

Error Comparison

Caveat: only measured along view direction What about ?

  • for PSM, slightly worse for LiSPSM

More advanced analysis was done in [Lloyd 2006]

Result: “storage factor” constant for n in [1, nopt] But: best error distribution for nopt

t ~ x s ~ z

dt dp 1 ~ dt dp

slide-55
SLIDE 55

56

Comparison

Uniform LiSPSM PSM

slide-56
SLIDE 56

57

Warping: Problems

Only works if large z-range visible from light

Outdoor scenes

Bad: Dueling frusta case But: Fitting often alleviates this

slide-57
SLIDE 57

Hard Shadows

Fighting Undersampling - Partitioning

slide-58
SLIDE 58

59

Z-Partitioning: Idea

Parallel Split Shadow Maps [Zhang 2007] Cascaded Shadow Maps [Engel 2007][Zhang2009] x z

slide-59
SLIDE 59

60

Z-Partitioning: Idea

Parallel Split Shadow Maps [Zhang 2007] Cascaded Shadow Maps [Engel 2007][Zhang2009] x z

slide-60
SLIDE 60

61

Partition view frustum into

n sub-frusta

Calculate separate shadow

map for each

Z-Partitioning

slide-61
SLIDE 61

62

Works even in cases where warping

fails

Light from behind, dueling frusta

Z-Partitioning

slide-62
SLIDE 62

63

Z-Partitioning vs LiSPSM

slide-63
SLIDE 63

64

Z-Partitioning

How to choose partition sizes?

Uniform Logarithmic/self-similar Linear blend between the two

slide-64
SLIDE 64

65

Z-Partitioning and Warping

x

slide-65
SLIDE 65

66

Z-Partitioning and Warping

Partitioning Partitioning + warping

slide-66
SLIDE 66

67

Optimal shadow map texel spacing Spacing from a 4x4 projective transform Partitioning gives a better fit image beam shadow map

z

Z-Partitioning

slide-67
SLIDE 67

68

Face partitioning

Problem: warping not good for all light directions

Especially from behind

Solution: Partition frustum according to faces Can be combined with z-partitioning

view frustum from behind face partitioning + z-partitioning

slide-68
SLIDE 68

69

Full Error Analysis

[Lloyd 2006]

slide-69
SLIDE 69

70

Adaptive Partitioning

Warping and z-partitioning are global resampling schemes

Deal with perspective aliasing Projection aliasing needs local scene adaptive resampling!

Adaptive partitioning adaptively splits shadow map

Usually quad-tree subdivision

Algorithms mainly differ in

termination criteria

slide-70
SLIDE 70

71

Tiled shadow maps

[Arvo 2004]

Split according to heuristics Based on depth discontinuities, distances, …. Allows to trade speed against quality

slide-71
SLIDE 71

72

Adaptive shadow maps

[Fernando et al. 2001; Lefohn et al. 2006]

High resolution only needed at edges Search for edge (slow)

If edge split

slide-72
SLIDE 72

73

Queried/Fitted Virtual Shadow Maps

Queried Virtual Shadow Maps [Giegl 2006]

Render 4 shadow maps of a quad-tree node Check if this was necessary (occlusion query)

Fitted Virtual Shadow Maps [Giegl 2007] Resolution Matched Shadow Maps [Lefohn 2007]

Project pixel footprints into shadow map Generate quad-tree FVSM: CPU, RMSM: GPU

slide-73
SLIDE 73

74

Fitted Virtual Shadow Maps

[Giegl & Wimmer 2007]

slide-74
SLIDE 74

75

Fitted Virtual Shadow Maps

[Giegl & Wimmer 2007]

slide-75
SLIDE 75

Hard Shadows

Fighting Undersampling - Irregular Sampling

slide-76
SLIDE 76

77

Shadow Mapping Sampling

slide-77
SLIDE 77

78

What Samples Do We Want?

Idea: use eye space samples to generate shadow map samples

slide-78
SLIDE 78

79

Regular vs Irregular Sampling

slide-79
SLIDE 79

80

Irregular z-Buffer

[Johnson et al. 2004]

Proposes hardware extension

slide-80
SLIDE 80

81

Irregular z-Buffer

slide-81
SLIDE 81

82

Alias Free Shadow Maps

[Aila and Laine 2004]

= Irregular Z-Buffer [Johnson 2004] in software Transform and project view-samples into light-space Rasterize blocker geometry using them as sampling points

Test if sampling point covered Hierarchical processing of sampling points (axis-aligned 2D BSP) In software

slide-82
SLIDE 82

83

Alias Free Hard Shadows

[Sintorn et al. 2008]

Transform and project view-samples into light-space Store in a compact data structure with a list per light-space texel

slide-83
SLIDE 83

84

Alias Free Hard Shadows

[Sintorn et al. 2008]

Render all geometry (conservatively) from lights point of view For each generated fragment, test all view-samples in list against triangle Set corresponding output bit

slide-84
SLIDE 84

85

Alias Free Hard Shadows

[Sintorn et al. 2008]

Final screen-space pass Use bitmask from previous pass for shadowing

slide-85
SLIDE 85

Hard Shadows

Fighting Undersampling - Temporal Reprojection

slide-86
SLIDE 86

87

Fighting Temporal Aliasing

Quick fix: texel snapping

Fix coordinate system in world space Shadow maps move at integral multiples of a texel width Gives up warping Popping when zooming

slide-87
SLIDE 87

95

Confidence and Temporal Smoothing

Confidence is weight for temporal smoothing cache(n):= conf∗ s(n) + (1−conf )∗ cache(n−1)

slide-88
SLIDE 88

Hard Shadows

Fighting Undersampling - Conclusion

slide-89
SLIDE 89

97

Conclusions

Fastest speed, single shadow map: warping

Good for outdoor

Fast speed, better quality, multiple shadow maps:

z-partitioning

High quality, lower speed: adaptive partitioning Reference quality, even slower: irregular sampling

slide-90
SLIDE 90

Hard Shadows

Depth Biasing

slide-91
SLIDE 91

99

Depth Biasing – Incorrect Self Shadowing

Polygon

slide-92
SLIDE 92

100

Depth Biasing – Incorrect Self Shadowing

Numerical instabilities caused by undersampling

Polygon

zeye > zlight Incorrect self-shadowing

slide-93
SLIDE 93

101

Depth Biasing

Polygon

zeye > zlight Incorrect self-shadowing zeye < zlight No self-shadowing

slide-94
SLIDE 94

102

How to Choose the Bias?

Slope-scale biasing Constant biasing No biasing

slide-95
SLIDE 95

103

Depends…

Too little bias, everything begins to shadow Too much bias, shadow starts too far back

How Much Bias?

Just right

slide-96
SLIDE 96

104

Second-Depth Shadow Mapping

[Wang and Molnar 94]

Normally: render front-side

polygons into SM

Now: render back-side

polygons

slide-97
SLIDE 97

105

Undersampling

Improve initial sampling Depth Biasing

Reconstruction error

Use different reconstruction algorithm

(Silhouette Shadow Maps)

Use better reconstruction filters

(PCF, PCF with Poisson disk sampling)

Oversampling

Use bandlimiting filters

(Convolution Shadow Maps etc., see later)

Error Overview

slide-98
SLIDE 98

Hard Shadows

Reconstruction

slide-99
SLIDE 99

107

Forward Shadow Mapping

[Zhang 1998]

slide-100
SLIDE 100

108

Shadow Silhouette Maps

[Sen et al. 2003]

Use a better silhouette approximation Store additional information of shadow edge

slide-101
SLIDE 101

109

Shadow Silhouette Maps

[Sen et al. 2003]

  • 1. Create shadow map
  • 2. Find silhouette edges
  • 3. Rasterize silhouettes
  • a. Find points that lie on silhouette edges
  • b. Store such points into silhouette map
slide-102
SLIDE 102

110

Shadow Silhouette Maps

[Sen et al. 2003]

  • 1. Create shadow map
  • 2. Find silhouette edges
  • 3. Rasterize silhouettes
  • a. Find points that lie on silhouette edges
  • b. Store such points into silhouette map
  • 4. Compute shadows
  • a. Non-silhouette pixels use standard

shadow map

  • b. Silhouette pixels use silhouette map
slide-103
SLIDE 103

111

Shadow Silhouette Maps

[Sen et al. 2003] Fragment Silhouette points

I interior + 4 external

Create quadrants Shade fragment according to shadow test result at corner point

slide-104
SLIDE 104

112

Shadow Silhouette Maps

[Sen et al. 2003]

silhouette map shadow map

slide-105
SLIDE 105

113

Shadow Silhouette Maps

[Sen et al. 2003]

113

slide-106
SLIDE 106

114 114

Shadow Silhouette Maps

[Sen et al. 2003]

slide-107
SLIDE 107

115

Deep Shadow Maps

[Lokovic and Veach 2000]

High quality shadows Smoke, hair, fur, … Stores function for each texel

115

slide-108
SLIDE 108

116

Deep Shadow Maps

[Lokovic and Veach 2000]

Transmittance function

Calculate reduction of light

Store compressed version

Piecewise linear Fixed number of function samples – store in array

116

slide-109
SLIDE 109

117

Deep Shadow Maps

[Lokovic and Veach 2000]

with self-shadowing without self-shadowing