fast soft self-shadowing on dynamic height fields john snyder microsoft research derek...
TRANSCRIPT
Fast Soft Self-Shadowing on Dynamic Height Fields
John Snyder
Microsoft Research
Derek Nowrouzezahrai
University of Toronto
Related Work
• horizon mapping [Max88; …]
– hard shadows– precomputed for static geometry
[Sloan&Cohen00]
Related Work
• shadow map filtering [Reeves87; …]
– light “bleeding” artifacts– small light sources– no complex environmental lighting
[Donnelly06]
Related Work
• ambient occlusion [Bunnell05; Kontkanen05; …]
– AO in screen-space [Shanmugam07;…]
– “cone” blocker model [Heidrich00;…]
[Oat07]
[Dimitrov08]
Related Work
• static relighting [Sloan02; Ng04; …]
• dynamic relighting [Bunnell05, Ren06, Sloan07]
Goals
• strong response to lighting direction (cast shadows)
low-frequency SH [Ren06]ambient occlusion
Goals
• strong response to lighting direction (cast shadows)• environmental + directional lighting
Goals
• strong response to lighting direction (cast shadows)• environmental + directional lighting• dynamic geometry (not precomputed)• real-time performance
• limitation: geometry is height field• applications:
– terrain rendering (flight simulators, games, mapping/navigation)– data visualization
1. approximate horizon map via multi-resolution- create height field pyramid [Burt81]- sample height differences from each pyramid level- use coarser levels as distance to receiver increases- reduces sampling
2. convert horizon map to SH visibility for soft shadowing- use visibility wedges [Dimitrov08]- get good directional lighting response- sharpen shadows by restricting wedges azimuthally- fast: {2D lookup + SH z rotation + Σ over wedges}
Summary of Main Ideas
Horizon Map [Max88]
height field: z=f(x)=f(x,y), point: p(x) = (x,f(x))
horizon angle: (x,) max angle horizon makes at p
in azimuthal direction
Sample at all points x along set of directions i.
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
t
Calculating the Horizon Map
t
yxftytxft
),()sin,cos(tanmax),( 1
),0(
x
Problem: aliasing – need many samples in t.Solution: prefilter height field, apply multi-scale derivative.
t
max
As t ↑, i ↑ : sample coarser levels further from x.
Multi-Resolution Approximation
i
iiiiii d
yxfdydxfdfD
),()sin,cos(),,,(
x
kii ld 2
multi-scale derivative
sampling distance for level i
if pyramid level i
fi fi-1 fi-2 fi-3
di di-1
di-2di-3
i i-1 i-2 i-3
Multi-Resolution Horizon Angle
horizon angle sample i
di di-1
di-2di-3
),,,(tan 1iii dfD x
Up-sample coarser levels with 2D B-splines:
Reconstruct blocking angle function with 1D B-splines:
)),,(),...,,,(,(spline-b),,( 1100 NN dxdxx
i i-1 i-2 i-3
Multi-Resolution Horizon Angle
knot
mid
Take max over sample knots and midpoints:),,(max),(
}1,0{
xx
N
Pyramid Level Step
• k = 1 (standard power-of-2 pyramid) abrupt transitions
• k = 4 smoothes transitions
k = 1 k = 2 k = 3 k = 4
Pyramid Level Offset
• pyramid level bias when sampling height differences• increasing bias increases shadow sharpness• increases sampling requirements
o = 0 o = 1 o= 2 o = 3 o = 4
1. approximate horizon map via multi-resolution- create height field pyramid [Burt81]- sample height differences from each pyramid level- use coarser levels as distance to receiver increases- reduces sampling
2. convert horizon map to SH visibility for soft shadowing- use visibility wedges [Dimitrov08]- get good directional lighting response- sharpen shadows by restricting wedges azimuthally- fast: {2D lookup + SH z rotation + Σ over wedges}
Summary of Main Ideas
Reconstructing Visibility
• so far discussed sampling in single azimuthal direction• large lights sample multiple azimuthal directions• linearly interpolate horizon angle as function of
• sequential pairs of i determine visibility wedges
Projecting Visibility to SH
• Project visibility wedge to SH (order 4)
• fix i = 0 and Δφ. Store as 2D table
• Visibility for a single wedge
otherwise. 1,
)( and ] ,[ if ,0),( 1
iiv
S
ibabai dsv )(),,(),( sysv
Reconstruct Full Visibility
• (N – 1) table lookups + (N – 1) SH Z-rotations
rotate wedge from i = 0 to azimuthal direction
• Sum over all wedges
• N azimuthal sampling directions N horizon angles• (N – 1) adjacent horizon angle pairs (wedge boundaries)
All operations (including horizon angle calculation) in a single
GPGPU shader. See [Snyder08] for full source code.
Azimuthal Swaths
• azimuthal swaths contain many visibility wedges– key lights: restrict swath
– env lights: use complete swath
get sharper shadowsacts as a geometric maskonly sample where necessary
Soft Shadowed Shading with SH
xV visibility vector at x
diffuse reflectance: clamped
cosine around normal Nx
L lighting environment
)( xH N
xN
wedges
izrot ) ,(
Soft Shadowed Shading with SH
LHV xx ),(, N SH triple product
xV )( xH N
or
BRDF x Visibility SH Product
and dot with lighting
xT
LTx ,
Comparison with Ground Truth
ground truth k = 1, o = 1 k = 2, o = 2 k = 3, o = 3 k = 4, o = 4
Measured PerformanceHF resolution pyramid levels FPS (key only) FPS (env + key)
256x256(130k triangles)
33 165 57.2
512x512(522k triangles)
37 34.5 11.5
1024x1024(2.1M triangles)
41 7.05 2.48
Image Results
Video Results
Clip 1
Clip 2
Conclusions
• multi-resolution approximation for horizon map• soft shadowing via fast SH projection• key + env lighting decomposition• simple GPU implementation• real-time up to 512x512 dynamic height fields• performance independent of geometric content
Thanks! Any questions?