1 Dr. Scott Schaefer Shadows
2/40 Shadows Shadows provide clues about depth Make scenes appear more realistic
3/40 Shadows Shadows provide clues about depth Make scenes appear more realistic
4/40 Shadow Algorithms Simple/Planar Shadows Shadow Maps Shadow Volumes
5/40 Simple/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
6/40 Simple/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
7/40 Shadow Maps
8/40 Shadow Maps Render scene from light’s perspective
9/40 Shadow Maps Render scene from light’s perspective Shadow Map
10/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective
11/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective For every pixel Transform to world space Compare distance to value in shadow map
12/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective For every pixel Transform to world space Compare distance to value in shadow map
13/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective For every pixel Transform to world space Compare distance to value in shadow map In shadow!
14/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective For every pixel Transform to world space Compare distance to value in shadow map In shadow!
15/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective For every pixel Transform to world space Compare distance to value in shadow map Not in shadow!
16/40 Shadow Maps Image taken from
17/40 Shadow 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
18/40 Perspective Shadow Maps Shadow maps are limited by screen resolution and depend on object distance! Small distance
19/40 Perspective Shadow Maps Shadow maps are limited by screen resolution and depend on object distance! Huge distance
20/40 Perspective Shadow Maps Distort viewing transformation from light’s perspective to create a more uniform sampling from viewer’s perspective Image taken from “Perspective Shadow Maps”
21/40 Perspective Shadow Maps Distort viewing transformation from light’s perspective to create a more uniform sampling from viewer’s perspective Image taken from “Perspective Shadow Maps”
22/40 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)
23/40 Shadow Volumes Build polygons for shadow volumesexplicitly Render shadow volume polygons from viewer’s perspective and count inside/outside shadows Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”
24/40 Shadow Volumes Shadowing object Light source Eye position
25/40 Shadow Volumes Shadowing object Light source zero Eye position
26/40 Shadow Volumes Shadowing object Light source zero Eye position Unshadowed object Shadow Volume Count = = 0
27/40 Shadow Volumes Shadowing object Light source zero Shadowed object Shadow Volume Count = = 2 Eye position
28/40 Shadow Volumes Shadowing object Light source zero Unshadowed object Shadow Volume Count = 0 Eye position
29/40 Implementing 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”
30/40 Implementing 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 Don’t update color or depth values!!!! If stencil buffer is non-zero, then pixel in shadow Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering” Stencil value 1 Stencil value 0
31/40 Shadow Volumes: Examples Images taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”
32/40 Shadow Volumes: Examples Image taken from “Doom 3”
33/40 Problems with Shadow Volumes zero Near clip plane Far clip plane
34/40 Problems with Shadow Volumes zero Near clip plane Far clip plane Missed shadow volume intersection due to near clip plane clipping; leads to mistaken count
35/40 Problems with Shadow Volumes Shadowing object Light source Shadow test fails! Shadow Volume Count = 0 Eye position
36/40 Shadow Volumes Advantages Omni-directional light sources Proper self-shadowing behavior Pixel perfect shadows Disadvantages Surfaces can only use planar polygons Silhouette computation uses CPU Heavy on fill-rate Near/Far clipping planes lead to problems
37/40 Soft Shadows Point lights cause hard shadows Lights are not infinitely small points in reality Area light sources cause soft shadows
38/40 Soft Shadows Point lights cause hard shadows Lights are not infinitely small points in reality Area light sources cause soft shadows
39/40 Soft Shadows Simulate area lights with lots of points lights Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering” Expensive The cluster of point lights.
40/40 Soft Shadows Simulate area lights with lots of points lights Blur shadows in image space Cheap, inaccurate
41/40
42/40 Solution: Invert Depth Test Shadowing object Light source Shadowed object Shadow Volume Count = =-1 Eye position - + -
43/40 Solution: Invert Depth Test Shadowing object Light source Shadowed object Shadow Volume Count = =-1 Eye position Now have problem with far clipping plane