Title: Dr' Scott Schaefer
1Shadows
2Shadows
- Shadows provide clues about depth
- Make scenes appear
- more realistic
3Shadows
- Shadows provide clues about depth
- Make scenes appear
- more realistic
4Shadow Algorithms
- Simple/Planar Shadows
- Shadow Maps
- Shadow Volumes
5Simple/Planar Shadows
- Projection of an object onto a planar
- surface (floor/wall)
- Build projection matrix
- from light to wall
- Draw object in black
- using projection matrix
Image taken from http//developer.nvidia.com/objec
t/robust_shadow_volumes.html
6Simple/Planar Shadows
- Fast and simple
- Does not account for self-shadowing
- Only works for planar
- surfaces (nothing else
- has shadows cast on it)
Image taken from http//developer.nvidia.com/objec
t/robust_shadow_volumes.html
7Shadow Maps
8Shadow Maps
- Render scene from lights perspective
9Shadow Maps
- Render scene from lights perspective
Shadow Map
10Shadow Maps
- Render scene from lights perspective
- Render scene from
- viewers perspective
11Shadow Maps
- Render scene from lights perspective
- Render scene from
- viewers perspective
- For every pixel
- Transform to world
- space
- Compare distance
- to value in shadow map
12Shadow Maps
- Render scene from lights perspective
- Render scene from
- viewers perspective
- For every pixel
- Transform to world
- space
- Compare distance
- to value in shadow map
13Shadow Maps
- Render scene from lights perspective
- Render scene from
- viewers perspective
- For every pixel
- Transform to world
- space
- Compare distance
- to value in shadow map
In shadow!
14Shadow Maps
- Render scene from lights perspective
- Render scene from
- viewers perspective
- For every pixel
- Transform to world
- space
- Compare distance
- to value in shadow map
In shadow!
15Shadow Maps
- Render scene from lights perspective
- Render scene from
- viewers perspective
- For every pixel
- Transform to world
- space
- Compare distance
- to value in shadow map
Not in shadow!
16Shadow Maps
Image taken from http//www.cse.ohio-state.edu/ha
leyb/Hardware/ggDepthBuffer.jpg
17Shadow Maps
- Advantages
- Simple to implement
- Does not depend on scene complexity (except to
render shadow map) - Disadvantages
- Fixed resolution image leads to artifacts
- Omni-directional light sources require 6 shadow
maps to cover every direction
18Perspective Shadow Maps
- Shadow maps are limited by screen resolution and
depend on object distance!
Small distance
19Perspective Shadow Maps
- Shadow maps are limited by screen resolution and
depend on object distance!
Huge distance
20Perspective Shadow Maps
- Distort viewing transformation from lights
perspective to create a more uniform sampling
from viewers perspective
Image taken from Perspective Shadow Maps
21Perspective Shadow Maps
- Distort viewing transformation from lights
perspective to create a more uniform sampling
from viewers perspective
Image taken from Perspective Shadow Maps
22Anatomy of a Shadow
Surface outsideshadow volume (illuminated)
Shadowingobject
Lightsource
Shadowvolume (infinite extent)
Eye position (note that shadows are independent
of the eye position)
Surface insideshadow volume (shadowed)
Partially
shadowed
object
23Shadow Volumes
- Build polygons for shadow
- volumes explicitly
- Render shadow volume
- polygons from viewers
- perspective and count
- inside/outside shadows
Image taken from Practical Robust Stenciled
Shadow Volumes for Hardware-Accelerated Rendering
24Shadow Volumes
Lightsource
Shadowing object
25Shadow Volumes
Lightsource
Shadowing object
zero
1
zero
2
2
1
3
26Shadow Volumes
Lightsource
Shadowing object
zero
1
zero
Unshadowedobject
2
2
1
3
Shadow Volume Count 111-1-1-1 0
27Shadow Volumes
Lightsource
Shadowing object
zero
1
zero
Shadowedobject
2
2
1
3
Shadow Volume Count 111-1 2
28Shadow Volumes
Lightsource
Shadowing object
zero
1
zero
Unshadowedobject
2
2
1
3
Shadow Volume Count 0
29Implementing Shadow Volumes
- For each surface, find silhouette edges
- Build shadow volume (viewer independent) by
extending away from light
Image taken from Practical Robust Stenciled
Shadow Volumes for Hardware-Accelerated Rendering
30Implementing Shadow Volumes
- Use stencil buffer to count intersections with
shadow volume - Render front faces and increment if closer to
viewer - Render back faces and decrement if closer to
viewer - Dont update color or depth values!!!!
- If stencil buffer is non-zero, then pixel in
shadow
Stencil value 1
Stencil value 0
Image taken from Practical Robust Stenciled
Shadow Volumes for Hardware-Accelerated Rendering
31Shadow Volumes Examples
Images taken from Practical Robust Stenciled
Shadow Volumes for Hardware-Accelerated Rendering
32Shadow Volumes Examples
Image taken from Doom 3
33Problems with Shadow Volumes
Far clipplane
zero
1
1
2
zero
3
2
Near clipplane
34Problems with Shadow Volumes
Missed shadow volume intersection due to near
clip plane clipping leads to mistaken count
Far clipplane
zero
1
1
2
zero
3
2
Near clipplane
35Problems with Shadow Volumes
Lightsource
Shadowing object
Shadow test fails!
Shadow Volume Count 0
36Solution Invert Depth Test
Lightsource
Shadowing object
Shadowed object
Shadow Volume Count -11-1-1
37Solution Invert Depth Test
Lightsource
Shadowing object
Now have problem with far clipping plane
Shadowed object
Shadow Volume Count -11-1-1
38Shadow Volumes
- Advantages
- Omni-directional light sources
- Proper self-shadowing behavior
- Pixel perfect shadows
- Disadvantages
- Surfaces must be connected closed
- Surfaces can only use planar polygons
- Silhouette computation uses CPU
- Heavy on fill-rate
- Near/Far clipping planes lead to problems
39Soft Shadows
- Point lights cause hard shadows
- Lights are not infinitely small points in reality
- Area light sources
- cause soft shadows
http//graphics.ucsd.edu/henrik/images/cbox.html
40Soft Shadows
- Point lights cause hard shadows
- Lights are not infinitely small points in reality
- Area light sources
- cause soft shadows
http//graphics.ucsd.edu/henrik/images/cbox.html
41Soft Shadows
- Simulate area lights with lots of points lights
Expensive
The cluster of point lights.
Image taken from Practical Robust Stenciled
Shadow Volumes for Hardware-Accelerated Rendering
42Soft Shadows
- Simulate area lights with lots of points lights
- Blur shadows in image space
Cheap, inaccurate
http//www.gamedev.net/reference/articles/article2
193.asp