Download presentation
Presentation is loading. Please wait.
Published byPeter Nichols Modified over 9 years ago
1
1 Dr. Scott Schaefer Shadows
2
2/40 Shadows Shadows provide clues about depth Make scenes appear more realistic
3
3/40 Shadows Shadows provide clues about depth Make scenes appear more realistic
4
4/40 Shadow Algorithms Simple/Planar Shadows Shadow Maps Shadow Volumes
5
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 http://developer.nvidia.com/object/robust_shadow_volumes.html
6
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 http://developer.nvidia.com/object/robust_shadow_volumes.html
7
7/40 Shadow Maps
8
8/40 Shadow Maps Render scene from light’s perspective
9
9/40 Shadow Maps Render scene from light’s perspective Shadow Map
10
10/40 Shadow Maps Render scene from light’s perspective Render scene from viewer’s perspective
11
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
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
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
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
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
16/40 Shadow Maps Image taken from http://www.cse.ohio-state.edu/~haleyb/Hardware/ggDepthBuffer.jpg
17
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
18/40 Perspective Shadow Maps Shadow maps are limited by screen resolution and depend on object distance! Small distance
19
19/40 Perspective Shadow Maps Shadow maps are limited by screen resolution and depend on object distance! Huge distance
20
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
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
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
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
24/40 Shadow Volumes Shadowing object Light source Eye position
25
25/40 Shadow Volumes Shadowing object Light source zero +1 +2 +3 Eye position
26
26/40 Shadow Volumes Shadowing object Light source zero +1 +2 +3 Eye position Unshadowed object + - - - + + Shadow Volume Count = +1+1+1-1-1-1 = 0
27
27/40 Shadow Volumes Shadowing object Light source zero +1 +2 +3 Shadowed object + - + + Shadow Volume Count = +1+1+1-1 = 2 Eye position
28
28/40 Shadow Volumes Shadowing object Light source zero +1 +2 +3 Unshadowed object Shadow Volume Count = 0 Eye position
29
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
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
31/40 Shadow Volumes: Examples Images taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”
32
32/40 Shadow Volumes: Examples Image taken from “Doom 3”
33
33/40 Problems with Shadow Volumes zero +1 +2 +3 Near clip plane Far clip plane
34
34/40 Problems with Shadow Volumes zero +1 +2 +3 Near clip plane Far clip plane Missed shadow volume intersection due to near clip plane clipping; leads to mistaken count
35
35/40 Problems with Shadow Volumes Shadowing object Light source Shadow test fails! Shadow Volume Count = 0 Eye position
36
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
37/40 Soft 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
38
38/40 Soft 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
39
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/40 Soft Shadows Simulate area lights with lots of points lights Blur shadows in image space http://www.gamedev.net/reference/articles/article2193.asp Cheap, inaccurate
41
41/40
42
42/40 Solution: Invert Depth Test Shadowing object Light source Shadowed object Shadow Volume Count = -1+1-1=-1 Eye position - + -
43
43/40 Solution: Invert Depth Test Shadowing object Light source Shadowed object Shadow Volume Count = -1+1-1=-1 Eye position - + - Now have problem with far clipping plane
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.