shadow algorithms non-photorealistic renderingvbz/cs130f14-14.pdfshadow maps •render scene from...
TRANSCRIPT
1
Shadow Algorithms
Non-photorealistic
Rendering
2
Shadow Algorithms
•Simple Planar Shadows
•Shadow Maps
•Shadow Volumes
2
3
Shadows
•Shadows provide clues about depth
•Make scenes appear
more realistic
4
Shadows
•Shadows provide clues about depth
•Make scenes appear
more realistic
3
5
Ray-tracing
light
light
s-ray
s-raye-ray
6
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
4
7
Simple Planar Shadows
•Fast and simple
•Does not account for self-shadowing
•Only works for planar
surfaces (nothing else
has shadows cast on it)
8
Shadow Maps
5
9
Shadow Maps
•Render scene from light’s perspective
Shadow Map
10
Shadow Maps
• Then render scene from Viewer’s perspective
6
11
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
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
7
13
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 mapIn shadow!
14
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 mapIn shadow!
8
15
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!
Shadow Maps
9
17
Shadow Maps
Shadow Maps
•Advantages
- Simple to implement
- Does not depend on scene complexity (except
to render shadow map)
•Disadvantages
- Fixed resolution image leads to artifacts
10
Shadow Maps
18
Low ResSmall Pixel
Shadow Maps
•Advantages
- Simple to implement
- Does not depend on scene complexity (except
to render shadow map)
•Disadvantages
- Fixed resolution image leads to artifacts
11
21
Anatomy of a Shadow
Shadowing
object
Partiallyshadowed 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)
22
Shadow Volumes
•Build polygons for shadow
volumes explicitly
•Render shadow volume
polygons from viewer’s
perspective and count
inside/outside shadows
12
23
Shadow Volumes
Shadowing objectLight
source
Eye
position
24
Shadow Volumes
Shadowing objectLight
source
zero
zero
+1
+1
+2 +2
+3Eye
position
13
25
Shadow Volumes
Shadowing objectLight
source
zero
zero
+1
+1
+2 +2
+3Eye
position
Unshadowed
object
+ ---+ +
Shadow Volume Count = +1+1+1-1-1-1 = 0
26
Shadow Volumes
Shadowing objectLight
source
zero
zero
+1
+1
+2 +2
+3
Shadowed
object
+ -+ +
Shadow Volume Count = +1+1+1-1 = 2
Eye
position
14
27
Shadow Volumes
Shadowing objectLight
source
zero
zero
+1
+1
+2 +2
+3
Unshadowed
object
Shadow Volume Count = 0
Eye
position
28
Implementing Shadow
Volumes
•For each surface, find silhouette edges
•Build shadow volume (viewer
independent) by extending away from
light
15
29
Shadow Volumes
30
Problems with Shadow Volumes
zero
zero
+1+1
+2
+2
+3
Near clip
plane
Far clip
plane
16
31
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
32
Problems with Shadow Volumes
Shadowing objectLight
source
Shadow test fails!
Eye
position
17
33
Solution: Invert Depth Test
Shadowing objectLight
source
Shadowed object
Shadow Volume Count = -1+1-1=-1
Eye
position
- +
-
34
Shadow Volumes
• Advantages
- Proper self-shadowing behavior
- Pixel perfect shadows
• Disadvantages
- Surfaces must use planar polygons
- Clipping plane lead to problems
- Eye in shadow problematic
18
35
Soft Shadows
•Point lights cause hard shadows
•Lights are not infinitely small points in
reality
•Area lights yield
soft shadows
36
Soft Shadows
•Point lights cause hard shadows
•Lights are not infinitely small points in
reality
•Area lights yield
soft shadows
19
37
Soft Shadows
•Simulate area lights with lots of points
lightsExpensive
The cluster of
point lights.
38
Soft Shadows
•Blur shadows in image space
Cheap, inaccurate
20
Non-photorealistic rendering
(NPR)
Non-Photorealistic
Rendering
21
41
Motivation
What is our ultimate goal in graphics?
•Photorealism- Makes synthesized pictures like
- photographs of real objects
- Includes artifacts
- (e.g. depth of field, lens flare)
•Communication- Graphics for transmitting
- information into the brain
Gray’s Anatomy
42
Non-Photorealistic
Rendering
• Uses concepts from art instead of physics
• Two fundamental visual cues
- Silhouette – the visible edges of a surface
- Hatching – the use of texture to
- indicate the local orientation
- (shading) of a surface
22
• Pen-and-Ink Illustrations
• Painterly Rendering
• Cartoon Shading
• Technical Illustrations
Pen-and-Ink Illustrations
23
Pen-and-Ink Illustrations
Pen-and-Ink Illustrations
24
Pen-and-Ink Illustrations
Painterly Rendering
25
Painterly Rendering
Painterly Rendering
26
Painterly Rendering
Painterly Rendering
27
Cartoon Shading
Cartoon Shading
28
Cartoon Shading
Technical Drawings
29
Technical Drawings
• Level of abstraction
– Accent important 3D properties
– Dimish or eliminate extraneous
details
• Do not represent reality
Scientific Visualization
30
Summary
• Many styles to choose from
• Automatic vs User Input
• Cartoon Shading temporal
• Acceptance in Art