Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 1
interactive shadows
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 2
direct illumination
• point lights
• area lights
• distant lights
• environment lights
),(cos),,()(),( SPPP VLL ioiilighto !!!"!! =
),(cos),,()(),( iioiilighto VLL !!!!"!! PPP =
! "=A
lighti
oilighto dVr
LLS
SSPPSP ),(coscos
),,()(),(2
####$#
! "#=
iiiioiilighto dVLL
$$$$$$%$$ ),(cos),,()(),( PPP
note: more on this in Comp. Graphics course slides
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 3
why shadows?
[Akenine-Möller/Haines]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 4
where do shadow come from?
no shadow shadow
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 5
soft vs. hard shadows
[Akenine-Möller/Haines]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 6
soft vs. hard shadows
point source
umbra
area source
umbrapenumbra
[Akenine-Möller/Haines]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 7
interactive shadow algorithms
Shadowvolumes
Light maps
Projectedplanarshadows
Hybridapproaches
[NV
IDIA
/Kilg
ard
et a
l.]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 8
interactive shadow algorithms
• raytracing– not interactive … yet will not cover
• shadow mapping– image space algorithm
• shadow volumes– object space algorithm
• projective shadows– cannot do self shadowing
• light maps– not dynamic
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 9
shadow mapping
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 10
shadow mapping principle
• render image from the light
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 11
shadow mapping principle
• store distance to closest surface
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 12
shadow mapping principle
• render the image from the view
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 13
shadow mapping principle
• project in shadow map: shadow if distance < map
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 14
shadow mapping principle
• otherwise not shadow
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 15
shadow mapping algorithm
• pass 1: render scene from light view• pass 1: store distance from the light (in texture)
• pass 2: render scene from eye view• pass 2: transform each sample to light space• pass 2: compare current light dist. to stored one• pass 2: if current < stored then shadow
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 16
shadow mapping visualization[N
VID
IA/E
verit
t et a
l.]
camera view light view shadow buffer
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 17
shadow mapping visualization
[NV
IDIA
/Eve
ritt e
t al.]
camera view light distance projected shadow buffer
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 18
shadow mapping limitations
• not enough resolution: blocky shadows– pixels in shadow buffer too large when projected
[Fer
nand
o et
al.,
200
2]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 19
shadow mapping limitations
• soft edges: percentage closer filtering– cannot average a shadow map then compare to it– perform all comparisons and then average results– used for reducing flickering, “incorrectly” blur edges
[NV
IDIA
/Kilg
ard
et a
l.]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 20
shadow map limitations recap
• hard shadows– due to render light for one point of view only– use fake blurred edges, but does not look right
• blocky shadows: shadow map aliasing– due to too large shadow pixels– increase shadow map resolution
• shadow “acne”: shadow map biasing– due to floating point comparison– use epsilon, also known as shadow map bias
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 21
shadow mapping extensions
• shadow map aliasing– new parameterizations (PSM)– hierarchical algorithms (ASM)
• handle non-transparent objects / hairs– store multiple distance values per shadow pixel (DSM)
• soft shadow edges– lots of hacks, none works well enough in all cases
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 22
shadow volumes
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 23
shadow volume principle
• objects blocking a light …
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 24
shadow volume principle
• objects blocking a light define shadow volumes
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 25
shadow volume principle
• all points in the volume are in shadow
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 26
shadow volumes principles
• count enter/exit to determine if in the volume
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 27
shadow volumes principle
• ok for multiple objects; internal edges cancel out
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 28
shadow volumes algorithm
• [pass 0: compute silhouettes for shadowpolygons]
• pass 1: draw depth in camera buffer• pass 2: draw font-facing shadow polygons
– increment buffer
• pass 3: draw back-facing shadow polygons– decrement buffer
• pass 4: draw scene only if count == 0
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 29
shadow volumes visualization
shadowed scene shadow volume
light
[NVIDIA/Everit et al.]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 30
shadow volumes visualization
shadowed scene shadow volume
light
[NVIDIA/Everit et al.]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 31
shadow volumes visualization
shadowed scene shadow volume
light
[NVIDIA/Everit et al.]
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 32
shadow mapping/volumes comparison
• shadow mapping– image space algorithm: blocky shadows, …– efficient use of hardware– scales linearly with geometry– can blur shadow edges
• shadow volumes– object space algorithm: sharp shadows– inefficient use of hardware
• lots of wasted memory bandwidth– require silhouettes computations– very hard to make it robust (will not cover in details)
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 33
shadow volume demo
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 34
shadow mapping demo
Topics in Computer Graphics • Interactive Shadows © 2008 Fabio Pellacini • 35
shadow mapping is the winner!
Top Related