Nima Kalantari
CSCE 441 - Computer Graphics
Shadows
Some slides from Scott Schaefer
Shadows
Shadows
Outline
Simple/Planar Shadows
Image taken NVIDIA
Simple/Planar Shadows
How to project an object to a planar surface?
Image taken NVIDIA
Ray Equation
unit direction
origin
“time”
point along ray
Ray equation:
Example:
Ray is defined by its origin and a direction vector
Plane Equation
Plane is defined by normal vector and a point on plane
Example:
Plane Equation:
normal vector
any point
all points on plane
Ray Intersection With Plane
Ray equation:
Plane equation:
Solve for intersection
Check:
How to project an object to a planar surface?
Image taken NVIDIA
Problem
How to project an object to a planar surface?
Image taken NVIDIA
Fixed
Simple/Planar Shadows
Fast and simple
Only for planar surfaces (nothing else has shadows cast on it)
Does not account for self-shadowing
Image taken NVIDIA
Outline
Shadow Maps
Shadow Maps
Shadow Maps
Shadow Map
Shadow Maps
perspective
Shadow Maps
perspective
in shadow map
Shadow Maps
perspective
in shadow map
Shadow Maps
perspective
in shadow map
In shadow!
Shadow Maps
perspective
in shadow map
In shadow!
Shadow Maps
perspective
in shadow map
Not in shadow!
Shadow Maps
Image taken from http://www.cse.ohio-state.edu/~haleyb/Hardware/ggDepthBuffer.jpg
Shadow map
Shadow map
Shadow map
depth
Shadow map
Shadow map
depth
Shadow map
Shadow map
depth
xyz in Light NDC
Shadow map
Shadow map
depth
xyz between [0, 1]
Shadow map
Shadow map
depth
xyz between [0, 1]
Problem
Shadow map
e is a small number e.g., 0.001
Shadow map
depth
xyz between [0, 1]
Fixed
Problem
Problem
Outside the light
camera view!
Problem
Outside the light
camera view!
z’ = 0
Blue point in shadow!
Hacky solution
Correct solution
Shadow Maps
Shadow Map Resolution
Rendered Image
Shadow Map
Outline
Anatomy of a Shadow
Shadowing�object
Partially
shadowed
object
Light�source
Eye position
(note that shadows are independent of the eye position)
Surface inside�shadow volume
(shadowed)
Surface outside�shadow volume
(illuminated)
Shadow�volume
(infinite extent)
Shadow Volumes
perspective and count inside/outside shadows
Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”
Shadow Volumes
Shadowing object
Light�source
Eye�position
Shadow Volumes
Shadowing object
Light�source
Eye�position
Unshadowed�object
+
-
-
-
+
+
Shadow Volume Count = +1+1+1-1-1-1 = 0
Shadow Volumes
Shadowing object
Light�source
Shadowed�object
Shadow Volume Count = +1+1+1-1 = 2
Eye�position
+
-
+
+
Shadow Volumes
Shadowing object
Light�source
zero
zero
+1
+1
+2
+2
+3
Unshadowed�object
Shadow Volume Count = 0
Eye�position
Implementing Shadow Volumes
Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”
Implementing Shadow Volumes
Shadow Volumes
Shadowing object
Light�source
Shadowed�object
+
-
+
+
Shadow Volume Count = +1+1+1-1 = 2
Eye�position
Shadow Volumes: Examples
Image taken from “Doom 3”
Shadow Volumes
Problems with Shadow Volumes
zero
zero
+1
+1
+2
+2
+3
+
-
+
+
-
-
Unshadowed�object
Shadow Volume Count = +1+1+1-1-1-1 = 0
Problems with Shadow Volumes
zero
zero
+1
+1
+2
+2
+3
Near clip�plane
Far clip�plane
Missed shadow volume intersection due to near clip plane clipping; leads to mistaken count
Unshadowed�object
Shadow Volume Count = +1+1-1-1-1 = -1
-
+
+
-
-
Problems with Shadow Volumes
Shadowing object
Light�source
Shadow test fails because
eye in shadow
Shadow Volume Count = 0
Eye�position
Outline
Soft Shadows
cause soft shadows
http://graphics.ucsd.edu/~henrik/images/cbox.html
Soft Shadows
cause soft shadows
http://graphics.ucsd.edu/~henrik/images/cbox.html
Soft Shadows
Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”
The cluster of point lights.
Soft Shadows
http://www.gamedev.net/reference/articles/article2193.asp