the university of north carolina at chapel hill practical logarithmic shadow maps brandon...

60
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Practical Logarithmic Shadow Maps Brandon Lloyd UNC-CH Naga Govindaraju UNC-CH David Tuft UNC-CH Steve Molnar Nvidia Dinesh Manocha UNC-CH

Post on 22-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Practical Logarithmic Shadow Maps

Brandon Lloyd UNC-CHNaga Govindaraju UNC-CHDavid Tuft UNC-CHSteve Molnar NvidiaDinesh Manocha UNC-CH

2 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Motivation

Interactive shadow computation remains a challenge

increasing scene complexitylarge, open environmentsuser expect high quality

3 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Shadow maps

Simple two pass algorithmSupports wide range of geometric representationsCheap to render

Disadvantage: Aliasing artifacts at shadow edges

4 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Warping algorithms

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

Increase sample density where needed by reparametrizing the shadow map

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

Light-space perspective shadow maps (LSPSMs) [Wimmer et al. 2004]

5 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Comparison of parameterizations

4x4 projection matrix Logarithmic

6 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Main results

Logarithmic parameterization for directional and point lightsError analysis for point lightsHardware architecture enhancements for logarithmic rasterization

7 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Outline

Related workAliasing errorLogarithmic parameterizationHardware architectureResults

8 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Partitioning algorithms

Separate shadow maps for different parts of the sceneIncludes cascaded shadow maps

Tiled shadow maps [Arvo 2004]

Adaptive shadow maps [Fernando et al. 2001; Lefohn et al. 2006]

Plural sunlight buffers [Tadamura et al. 1999,2001]

9 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Warping + partitioning

4x4 matrixLixel for every pixel[Chong and Gortler 2004]

PSM with cube maps[Kozlov 2004]

Warping + various frustum partitioning schemes [Lloyd et al. 2006]

Dual paraboloid [Brabec et al. 2002]

10 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Specialized representations

Silhouette shadow maps[Sen et al. 2004]

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

Solves the aliasing problemGPU support requires major changes

11 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Outline

Related workAliasing errorLogarithmic parameterizationHardware architectureResults

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

12

Aliasing error

shadow plane

viewfrustum

eye

light

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

13

light beam

'wl

'wi

'wi 'wi 'wi

Aliasing error

'wl

image beam

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

14

wi

wl

light beam

image beam

θl

θi

'wi

Aliasing error

'wl

m='wl

'wicos θl

cos θi

wl

wi

Perspectivealiasing

cos θl

cos θi Projectionaliasing

wl

wi≈

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

15

wi

wl

θl

θi

'wi

Aliasing error

'wl

m='wl

'wi

wl

wi

Perspectivealiasing

wl

wi≈

light beam

image beam

cos θl

cos θi

cos θl

cos θi Projectionaliasing

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

16

wi

wl

light beam

image beam

Controlling aliasing error

To eliminate perspective aliasing:

wl ≤ wi

Light beam width depends on:

Shadow map resolutionParameterization

17 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Outline

Related workAliasing errorLogarithmic parameterization

Directional lightPoint light

Hardware architectureResults

18 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Parameterization

Standard Perspective warped

light imageplane

shadow map shadow map

light light

19 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Directional light

imagebeam

light imageplane

t

wl

light

z

1

wi

1. Light beam widths

2. Texel spacing function

3. Parameterization

[Wimmer et al. 04]

20 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Quadratic

z

beam

wid

th

Uniform

z

beam

wid

th

Linear

zbe

am w

idth

Directional lightWith 4x4 matrix With logarithm

21 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Comparison

Standard

Perspective

Logarithmic

101

102

103

104

100

102

104

106

108

f / n

Sh

ad

ow

map

texe

ls /

imag

e te

xels

frustum fov = 60○

22 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Point lights

light

view frustum

23 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Point lights

light

light imageplane

view frustum facez

y wl ~ z

24 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Point light spacing function - z

facey

zzylight

25 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Point light spacing function - z

z lighty

faceylight

y

zz

26 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Point light spacing function - z

faceylight

y

zz

27 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Point lights – parameterization

28 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Fitting the spacing function - z

Parameterization for exact function is complicatedFit two parabolas:

Parameterization:0

z

Point light spacing function

29 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

4x4 matrix + logarithm

vc : [xc zc yc wc]T - clip coordinate

vn : [xn zn yn 1]T - normalized device coordinate

v : [x z y 1]T - world coordinate

P :perspective or orthographic projection matrix

a0-a3 : constants

b0-b3 : constants

To screen coordinates

s = a0ln( a1xn + a2 ) + a3

t = b0ln( b1zn + b2 ) + b3

To NDC coords.

vc = P vvn= vc /wc

30 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Parameterization summary

Directional Point

x:

z:

without log with log

ort

ho

.p

ersp

.

Actual spacing functions Spacing functions from4x4 matrix + log

31 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Outline

Related workAliasing errorLogarithmic parameterizationHardware architectureResults

32 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Logarithmic parameterization

Unwarped

viewfrustum

33 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Vertex program

Transform vertices on the GPURequires finely tesselated model

Increases burden on vertex processor

Adaptive tesselation complicated

Easier with DX10 geometry shaders

34 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Fragment program

Brute force rasterization

Render bounding primitiveTransform fragments to original triangleDiscard if not inside

10x slow downComputing bounding primitive is complicated

Easier with DX10 geometry shaders

35 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Graphics pipeline

fragment processor

vertex processor

rasterizer

alpha, stencil, & depth tests

blending

clip & back-face cull

memoryinterface

depthcompression

colorcompression

36 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Rasterizing equations

Coverage determination

use sign of edge distance equations

Attribute interpolation

depth, color, texture coordinates, etc.

37 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Rasterizing equations

Parameterization:

Edge distance and attribute interpolation:

38 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Incremental computation

1 MULT + 2 ADDper step

39 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Depth compression

First order Second order

Compressed tiles shown in red

40 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Feasibility

Current hardware trendComputational power increasing rapidlyBandwidth lags behind

Log shadow mapsIncrease computationReduce memory/bandwidth consumption

41 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Nonlinear rasterization

Configurable rasterizerOther rasterization functions are possibleMight be useful for other effects

Reflections, refractions, caustics, general multi-view perspective [Hou et al. 06]

42 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Outline

Previous workAliasing errorLogarithmic parameterizationHardware implementationResults

43 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

Power plant13 Mtris

Oil tanker82 Mtris

Town scene59 Ktris

44 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

Standard Perspective warping Logarithmic

45 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

Perspective warping Logarithmic

46 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

Perspective warping Logarithmic

47 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Comparison to z-partitioning

101

102

103

104

100

102

104

106

108

k=1

k=2

k=4

k=8

f / n

Sh

ad

ow

ma

p t

ex

els

/ i

ma

ge

te

xe

ls Perspective with kz-partitions

Logarithmic

48 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

z-partitioning (k=4) Logarithmic

49 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

50 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

Perspective warping Logarithmic

51 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

Perspective warping Logarithmic

52 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results – Point lights

Standard Perspective warping Logarithmic

high error

higherror

53 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Advantages

Logarithmic shadow maps require less bandwidth and storageSmoother parameterization than z-partitioning

54 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Disadvantages

Does not handle projection aliasingRequires multiple shadow maps

Up to 5 directional lightUp to 4 per frustum face for point light

Warped depth values

55 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Conclusion

Logarithmic parameterizationLower error than previous methods

Hardware architecture for log rasterization

Requires only small enhancements to current graphics hardwareExploits current hardware trends

56 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Future work

More details for hardware implementation

precision requirementsfilteringshadow map bias

Other applications for nonlinear rasterization

57 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Acknowledgements

Aaron Lefohn for the town modelSupported in part by:

NSF Graduate FellowshipARO Contracts DAAD19-02-1-0390 and W911NF-04-1-0088 NSF awards 0400134 and 0118743ONR Contract N00014-01-1-0496DARPA/RDECOM ContractN61339-04-C-0043Intel

58 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Questions?

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

59 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Coordinate systems

view

y

zx

warping frustum

viewfrustum

light

shadow map

t

s

Light space [Wimmer et al. 04]

z

x

60 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Directional light - general case

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

wl

light

shadow map t

z