Sei sulla pagina 1di 60

Practical Logarithmic Shadow Maps

Brandon Lloyd Naga Govindaraju David Tuft Steve Molnar Dinesh Manocha UNC-CH UNC-CH UNC-CH Nvidia UNC-CH

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Motivation
Interactive shadow computation remains a challenge
increasing scene complexity large, open environments user expect high quality

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Shadow maps
Simple two pass algorithm Supports wide range of geometric representations Cheap to render Disadvantage: Aliasing artifacts at shadow edges
3 The UNIVERSITY of NORTH CAROLINA at CHAPEL

Warping algorithms
Increase sample density where needed by reparametrizing the shadow map
Light-space perspective shadow maps (LSPSMs) [Wimmer et al. 2004]

Perspective shadow maps (PSMs) [Stamminger and Drettakis 2002]


4

Trapezoidal shadow maps (TSMs) [Martin and Tan 2004]

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Comparison of parameterizations

4x4 projection matrix


5

Logarithmic
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Main results
Logarithmic parameterization for directional and point lights Error analysis for point lights Hardware architecture enhancements for logarithmic rasterization
6

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Outline
Related work Aliasing error Logarithmic parameterization Hardware architecture Results

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Partitioning algorithms
Separate shadow maps for different parts of the scene Includes cascaded shadow maps

Adaptive shadow maps


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

Plural sunlight buffers


[Tadamura et al. 1999,2001] 8

Tiled shadow maps [Arvo 2004]


The UNIVERSITY of NORTH CAROLINA at CHAPEL

Warping + partitioning
4x4 matrix
Lixel for every pixel
[Chong and Gortler 2004] [Kozlov 2004]

PSM with cube maps Warping + various frustum partitioning schemes [Lloyd et al. 2006]

Dual paraboloid

[Brabec et al. 2002]

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Specialized representations
Silhouette shadow maps
[Sen et al. 2004]

Irregular shadow maps


[Johnson et al. 2004,2005; Aila and Laine 2004]

Solves the aliasing problem GPU support requires major changes

10

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Outline
Related work Aliasing error Logarithmic parameterization Hardware architecture Results

11

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Aliasing error
light

shadow plane

eye view frustum


12 The UNIVERSITY of NORTH CAROLINA at CHAPEL

Aliasing error
light beam

w'l w'i w'i w'i

image beam

w'i

w'l

13

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Aliasing error
light beam image beam

wl l

w'l wl cos i m= w cos w'i i l wl Perspective wi aliasing

i wi w'i w'l

cos i cos l

Projection aliasing

14

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Aliasing error
light beam image beam

wl l

w'l wl cos i m= w cos w'i i l wl Perspective wi aliasing

i wi w'i w'l

cos i cos l

Projection aliasing

15

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Controlling aliasing error


light beam image beam
To eliminate perspective aliasing:

wl wi

wl wi

Light beam width depends on:


Shadow map resolution Parameterization

16

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Outline
Related work Aliasing error Logarithmic parameterization
Directional light Point light

Hardware architecture Results


17 The UNIVERSITY of NORTH CAROLINA at CHAPEL

Parameterization
light light image plane light

shadow map

shadow map

Standard
18

Perspective warped
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Directional light
light

1. Light beam widths

2. Texel spacing function

t z

1
light image plane

3. Parameterization

wl
[Wimmer et al. 04] 19

wi

image beam

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Directional light
With 4x4 matrix
Uniform
beam width

With logarithm

Linear

z
Quadratic
beam width

beam width

z z

20

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Comparison
Shadow maptexels / image texels
10
8

Standard

10

10

Perspective

10

Logarithmic
10
0

10

10

10

10

f/n
21

frustum fov = 60

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Point lights
light

view frustum

22

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Point lights
light

light image plane

y z
23

wl ~ z
view frustum face
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Point light spacing function -z

y ylight z

face z

24

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Point light spacing function -z

y ylight z

face z

25

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Point light spacing function -z

y ylight z

face z

26

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Point lights parameterization

27

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Fitting the spacing function -z


Point light spacing function

Parameterization for exact function is complicated Fit two parabolas:

Parameterization:
z

28

The UNIVERSITY of NORTH CAROLINA at CHAPEL

4x4 matrix + logarithm


To NDC coords. To screen coordinates

vc = P v vn= vc /wc
vc : vn : v:

s = a0ln( a1xn + a2 ) + a3 t = b0ln( b1zn + b2 ) + b3


[xc zc yc wc]T [xn zn yn 1]T [x z y 1]T - world
The UNIVERSITY of NORTH CAROLINA at CHAPEL

- clip -

coordinate normalized device coordinate coordinate


29

P:

perspective or orthographic

Parameterization summary
Spacing functions from 4x4 matrix + log
without log with log Directional x: Point

Actual spacing functions

z:

30

The UNIVERSITY of NORTH CAROLINA at CHAPEL

persp.

ortho.

Outline
Related work Aliasing error Logarithmic parameterization Hardware architecture Results

31

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Logarithmic parameterization
view frustum

Unwarped

32

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Vertex program
Transform vertices on the GPU Requires finely tesselated model
Increases burden on vertex processor

Adaptive tesselation complicated


Easier with DX10 geometry shaders

33

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Fragment program
Brute force rasterization
Render bounding primitive Transform fragments to original triangle Discard if not inside

10x slow down Computing bounding primitive is complicated


Easier with DX10 geometry shaders

34

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Graphics pipeline
vertex processor clip & back-face cull rasterizer fragment processor alpha, stencil, & depth tests blending
35

memory interface depth compression color compression


The UNIVERSITY of NORTH CAROLINA at CHAPEL

Rasterizing equations
Coverage determination
use sign of edge distance equations

Attribute interpolation
depth, color, texture coordinates, etc.

36

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Rasterizing equations
Edge distance and attribute interpolation:

Parameterization:

37

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Incremental computation

1 MULT + 2 ADD per step


38 The UNIVERSITY of NORTH CAROLINA at CHAPEL

Depth compression

First order

Second order

Compressed tiles shown in red


39 The UNIVERSITY of NORTH CAROLINA at CHAPEL

Feasibility
Current hardware trend
Computational power increasing rapidly Bandwidth lags behind

Log shadow maps


Increase computation Reduce memory/bandwidth consumption

40

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Nonlinear rasterization
Configurable rasterizer Other rasterization functions are possible Might be useful for other effects
Reflections, refractions, caustics, general multi-view perspective [Hou et
al. 06]

41

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Outline
Previous work Aliasing error Logarithmic parameterization Hardware implementation Results

42

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

Power plant
13 Mtris

Oil tanker
82 Mtris

Town scene
59 Ktris

43

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

Standard

Perspective warping Logarithmic

44

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

Perspective warping
45

Logarithmic
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

Perspective warping
46

Logarithmic
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Comparison to zpartitioning
Shadow map texels / image texels
10
8

k=1

Perspective with k z-partitions

10

10

k=2

10

k=4 k=8

Logarithmic

10

10

10

10

10

f/n

47

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

z-partitioning (k=4)
48

Logarithmic
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

49

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

Perspective warping
50

Logarithmic
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results

Perspective warping
51

Logarithmic
The UNIVERSITY of NORTH CAROLINA at CHAPEL

Results Point lights

high error

high error Standard Perspective warping Logarithmic

52

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Advantages
Logarithmic shadow maps require less bandwidth and storage Smoother parameterization than z-partitioning

53

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Disadvantages
Does not handle projection aliasing Requires multiple shadow maps
Up to 5 directional light Up to 4 per frustum face for point light

Warped depth values


54 The UNIVERSITY of NORTH CAROLINA at CHAPEL

Conclusion
Logarithmic parameterization
Lower error than previous methods

Hardware architecture for log rasterization


Requires only small enhancements to current graphics hardware Exploits current hardware trends

55

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Future work
More details for hardware implementation
precision requirements filtering shadow map bias

Other applications for nonlinear rasterization

56

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Acknowledgements
Aaron Lefohn for the town model Supported in part by:
NSF Graduate Fellowship ARO Contracts DAAD19-02-1-0390 and W911NF-04-1-0088 NSF awards 0400134 and 0118743 ONR Contract N00014-01-1-0496 DARPA/RDECOM Contract N61339-04-C-0043 Intel

57

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Questions?
http://gamma.cs.unc.edu/logsm

58

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Coordinate systems
light

y z x
view

warping frustum

shadow map

zt s x

view frustum

Light space
59

[Wimmer et al. 04]


The UNIVERSITY of NORTH CAROLINA at CHAPEL

Directional light - general case


light shadow map

Highest error (wl /wi) occurs at the faces Partition frustum to handle each face separately

wl
60

The UNIVERSITY of NORTH CAROLINA at CHAPEL

Potrebbero piacerti anche