cse 167: introduction to computer graphics lecture #16: shadows
TRANSCRIPT
![Page 1: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/1.jpg)
CSE 167:
Introduction to Computer GraphicsIntroduction to Computer Graphics
Lecture #16: Shadows
Jürgen P. Schulze, Ph.D.
University of California, San Diego
Fall Quarter 2011
![Page 2: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/2.jpg)
Announcements
� Important dates:
� Final project outline due November 23rd
� Email to me at [email protected]
� Final project presentations: Friday December 2nd, 1-3pm
� Final Exam: December 9th, 3-6pm
� TA Evaluation for Gregory Long OR Jorge Schwarzhaupt
� Pick the TA you interacted more with
2
![Page 3: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/3.jpg)
Lecture Overview
� Ambient Occlusion
� Shadow Mapping
3
![Page 4: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/4.jpg)
Screen Space Ambient Occlusion
� Screen Space Ambient Occlusion = SSAO
� Rendering technique for approximating ambient occlusion in real time
� Developed by Vladimir Kajalin while working at Crytek
� First use in 2007 PC game Crysis
4 SSAO component
![Page 5: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/5.jpg)
SSAO Demo
� Video
5
![Page 6: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/6.jpg)
SSAO Algorithm
� Copy frame buffer to texture
� Pixel shader samples depth values around current pixel and tries to compute amount of occlusion
� Occlusion depends on depth difference between sampled point and current point
Nvidia’s documentation:� Nvidia’s documentation:
� http://developer.download.nvidia.com/SDK/10.5/direct3d/Source/ScreenSpaceAO/doc/ScreenSpaceAO.pdf
� SSAO shader code from Crysis:
� http://69.163.227.177/forum.php?mod=viewthread&tid=772
� Another implementation:
� http://www.gamerendering.com/2009/01/14/ssao/6
![Page 7: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/7.jpg)
SSAO Discussion
� Advantages:
� Independent from scene complexity.
� No pre-processing, no memory allocation in RAM
� Works with dynamic scenes
� Works in the same way for every pixel
No CPU usage: executed completely on GPU� No CPU usage: executed completely on GPU
� Disadvantages:
� Local and view-dependent (dependent on adjacent texeldepths)
� Hard to correctly smooth/blur out noise without interfering with depth discontinuities, such as object edges
7
![Page 8: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/8.jpg)
Lecture Overview
� Ambient Occlusion
� Shadow Mapping
8
![Page 9: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/9.jpg)
Why Are Shadows Important?
� Give additional cues on scene lighting
9
![Page 10: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/10.jpg)
Why Are Shadows Important?
� Contact points
� Depth cues
10
![Page 11: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/11.jpg)
Why Are Shadows Important?
� Realism
Without self-shadowing With self-shadowing
11
![Page 12: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/12.jpg)
Terminology
� Umbra: fully shadowed region
� Penumbra: partially shadowed region
(area) light source
occluder
receiver shadow
occluder
umbra
penumbra
12
![Page 13: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/13.jpg)
Hard and Soft Shadows
� Point and directional lights lead to hard shadows, no penumbra
� Area light sources lead to soft shadows, with penumbra
point directional areapoint directional area
umbra penumbra
13
![Page 14: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/14.jpg)
Hard and Soft Shadows
Hard shadow from
point light source
Soft shadow from
area light source
14
![Page 15: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/15.jpg)
Shadows for Interactive Rendering
� In this course: hard shadows only
� Soft shadows hard to compute in interactive graphics
� Two most popular techniques:
� Shadow mapping
� Shadow volumes
� Many variations, subtleties
� Active research area
15
![Page 16: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/16.jpg)
Lecture Overview
� Shadows
� Shadow mapping
16
![Page 17: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/17.jpg)
Shadow Mapping
Main Idea
� A scene point is lit by the light source if visible from the light source
� Determine visibility from light source by placing a camera at the light source position and rendering the scene from therescene from there
Scene points are lit if
visible from light source
Determine visibility from
light source by placing camera
at light source position
17
![Page 18: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/18.jpg)
Two Pass Algorithm
First Pass
� Render scene by placing camera at light source position
� Store depth image (shadow map)
depth value
Depth image as seen
from light source18
![Page 19: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/19.jpg)
Two Pass Algorithm
Second Pass
� Render scene from camera position
� At each pixel, compare distance to light source with value in shadow map
vb is in
shadow pixel seen
from eye vb
with value in shadow map
� If distance is larger, pixel is in shadow
� If distance is smalleror equal, pixel is lit
Final image with shadows
19
![Page 20: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/20.jpg)
Issues With Shadow Maps
� Limited field of view of shadow map
� Z-fighting
� Sampling problems
20
![Page 21: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/21.jpg)
Limited Field of View
� What if a scene point is outside the field of view of the shadow map?
field of
view
21
![Page 22: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/22.jpg)
Limited Field of View
� What if a scene point is outside the field of view of the shadow map?� Use six shadow maps, arranged in a cube
shadow
maps
� Requires a rendering pass for each shadow map
22
![Page 23: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/23.jpg)
� Depth values for points visible from light source are equal in both rendering passes
� Because of limited resolution,
Z-Fighting
Camera image
Shadow map
Image
pixels� Because of limited resolution, depth of pixel visible from light could be larger than shadow map value
� Need to add bias in first pass to make sure pixels are lit
pixels
Shadow map
pixels Pixel is
considered
in shadow!
Depth
of pixel
Depth of
shadow map
23
![Page 24: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/24.jpg)
Solution: Bias
� Add bias when rendering shadow map
� Move geometry away from light by small amount
� Finding correct amount of bias is tricky
Correct bias Not enough bias Too much bias
24
![Page 25: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/25.jpg)
Bias Adjustment
Not enough Too much
Just right25
![Page 26: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/26.jpg)
Sampling Problems
� Shadow map pixel may project to many image pixels� Stair-stepping artifacts
26
![Page 27: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/27.jpg)
Solutions
� Increase resolution of shadow map� Not always sufficient
� Split shadow map into several tiles
� Tweak projection for shadow map rendering� Light space perspective shadow maps (LiSPSM)
http://www.cg.tuwien.ac.at/research/vr/lispsm/
� Combination of splitting and LiSPSM� Basis for most serious implementations
27
![Page 28: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/28.jpg)
LiSPSM
Basic shadow map Light space perspective
shadow map
28
![Page 29: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/29.jpg)
Video
29
![Page 30: CSE 167: Introduction to Computer Graphics Lecture #16: Shadows](https://reader031.vdocuments.mx/reader031/viewer/2022020703/61fb28762e268c58cd5ad62a/html5/thumbnails/30.jpg)
Next Lecture
� Shadow Maps cont’d
� Procedural Modeling
30