Title: Anti-aliasing and Continuity using Trapezoidal Shadow Maps
1Anti-aliasing and ContinuityusingTrapezoidal
Shadow Maps
- Speaker Tobias Martin
- Co-Author Tiow-Seng Tan
- National University of Singapore
-
Standard Shadow Maps
2Content
- Shadows in Computer Graphics
- Standard Shadow Maps (SSM)
- Problems with SSM
- Problem 1 Aliasing/Resolution
- Problem 2 Polygon Offset
- Problem 3 Continuity
- Trapezoidal Shadow Maps
- Conclusion
3Shadows in Computer Graphics
- Why?
- Spatial relationship between objects is better
perceivable - Realism is enhanced
- Our Requirements
- Robust shadows in real-time
(Screenshots taken from shadowcast.exe by Mark
J. Kilgard, NVIDIA)
4Standard Shadow Maps (SSM)
- 1. Shadow Map Generation
- Transform scene into post-perspective space (PPS)
of light, i.e. vL PL ? CL ? W ? v - Render scene from this space
- Copy depth buffer into shadow map
- 2. Shadow Determination
- Render scene in eyes PPS and perform shadow test
per-fragment - Fragment is in shadow iff zp gt shadowmapxp, yp,
where xp, yp and zp is fragment in PPS of light
(Screenshots taken from shadowcast.exe by Mark
J. Kilgard, NVIDIA)
5Standard Shadow Maps (SSM)
- Problem 1 Resolution ProblemJagged shadow
boundary appears due to low resolution in shadow
map - ? Trivial solutionIncrease shadow map size to
increase resolution improve quality
6Standard Shadow Maps (SSM)
- Problem 2 Polygon OffsetDue to finite
precision, surfaces can cast wrong shadows on
themselves - ?Practical Solution Adding offset to depth
values to move shadow slightly away from light
7Current Solutions
- Problem 3 Continuity (1)
- Straightforward approximation can result in
shadow discontinuities - e.g. in Perspective Shadow Maps (PSM)Stamminger
and Drettakis 2002 - e.g. in the Bounding Box Approximation (BB)
Brabec et al. 2002
Frame i 1
Frame i
8Current Solutions
- Problem 3 Continuity (2)
- What happens if shadow map depends on dynamic
scene geometry?
light
light
scenes bounding box
eye
eye
scenes bounding box
n frames later
?expanded hull contains shadow occluders
?shadow map quality worsened
?tight hull contains shadow occluders ?good
shadow map quality
9Trapezoidal Shadow Maps (TSM)
- Solution to Problem 1 (Resolution)
- Shadow map generation focuses on area potentially
visible to the eye - Solution to Problem 2 (Polygon Offset)
- Depth values are preserved, so that problem is
not worsened - Solution to Problem 3 (Continuity)
- Frame coherent technique resulting in a
continuous change in shadow map resolution
10Trapezoidal Shadow Maps (TSM)
PPSof light
NT
A
trapezoidal space
Shadow map resolution is increased
Shadow aliasing is reduced
11Trapezoidal Shadow Maps (TSM)
- Solution to Problem 1
- SSM algorithm is slightly modified
- Calculate shadow map in the trapezoidal space,
and perform the shadow test there as well,
i.e.vT NT ? PL ? CL ? W ? v - ?Except for the calculation of NT the algorithm
can completely be mapped to graphics hardware!
12Trapezoidal Shadow Maps (TSM)
- Side effect of the trapezoidal transformation
(b)
(a)
Non-uniform distribution
Uniform distribution
- a) Approximation of an eye's frustum with a
trapezoid - b) Applying NT may lead to severe polygon offset
problems - ? Different distribution of z-values require
different offsets
13Trapezoidal Shadow Maps (TSM)
- Solution to (worsened) Problem 2
- Apply NT only to the x- and y-values
- Maintain z in PPS of light
- ? Store (xT , yT , zL) in the shadow map
Simply applying NT
Applying modified NT
14Trapezoidal Shadow Maps (TSM)
- 1st pass (Shadow Map Generation)
- Vertex stage
- vT NT ? PL ? CL ? W ? v
- vL PL ? CL ? W ? v
- Fragment stage
- shadowmapxT, yT zL instead of zT
- ?Use additional texture coordinate vL and replace
zT with zL per fragment
15Trapezoidal Shadow Maps (TSM)
- 2nd pass (Shadow Determination)
- Vertex stage
- vE PE ? CE ? W ? v
- vT NT ? PL ? CL ? W ? v
- vL PL ? CL ? W ? v
- Fragment stage
- Fragment in shadow iff zL gt shadowmapxT, yT
- ? Use additional texture coordinate vL and use zL
for shadow map comparison
16Trapezoidal Shadow Maps (TSM)
- Solution to Problem 3
- Base and Top Lines
Center Line
2D-Convex Hull
Base Top Line
l
lt
lb
CHE
- Center line governs the choices of top and base
line ? top and base line transit smoothly from
frame to frame
17Trapezoidal Shadow Maps (TSM)
- Side Lines 80 rule governs the choices
0
Focus region of the eye
80 line
Trapezoidal approximation in L
Trapezoidal space due to 80 rule
18Trapezoidal Shadow Maps (TSM)
q
- Calculate NT that pL is mapped to 80 line in T
- Calculate q using 1D perspective projection
map to y1
?
lt
map to y?
?
pL
?
map to y-1
E
lb
l
- (Minus signs in the proceedings got eaten up by
the printer)
19Trapezoidal Shadow Maps (TSM)
20Trapezoidal Shadow Maps (TSM)
- Indication for Continuity
- Plot of the total area covered by focus region in
shadow map - Change in frustum are color encoded
21Trapezoidal Shadow Maps (TSM)
light
light
light
- General case
- Eyes frustum E is not completely within then
lights frustum L - Algorithm can be easily adjusted
- Singularities are avoided
eye
eye
eye
22Results
- Fantasy World
- BB vs. PSM vs. TSM
- Urban Model
- PSM vs. TSM
23Conclusion
- TSM addresses
- Resolution Problem
- Polygon Offset Problem
- Continuity Problem
- following the 3 principles
- Effectiveness of 80 rule
- Simplicity which is difficult to achieve
- Continuity rather than correctness
- Q and A
TSM
http//www.comp.nus.edu.sg/tants/tsm.html
24Literature
- BRABEC, S., ANNEN T., AND SEIDEL, H. 2002.
Practical Shadow Mapping. Journal of Graphics
Tools 7(4), 918. - CROW, F. C. 1977. Shadow Algorithms for Computer
Graphics. In - Proceedings of SIGGRAPH 1977, 242248.
- STAMMINGER, M., AND DRETTAKIS, G. 2002.
Perspective Shadow Maps. - WILLIAMS, L. 1978. Casting curved shadows on
curved surfaces. In - Proceedings of SIGGRAPH 1978, 270274.
- WOO, A., POULIN, P., AND FOURNIER, A. 1990. A
survey of shadow algorithms. IEEE Computer
Graphics and Applications, 10(6), 1332.