• 沒有找到結果。

Shadow volumes Shadow volumes

N/A
N/A
Protected

Academic year: 2022

Share "Shadow volumes Shadow volumes"

Copied!
139
0
0

加載中.... (立即查看全文)

全文

(1)

Hard Shadows Hard Shadows

Digital Image Synthesis 1/4/2007

With slides from Eric Chan, Pradeep Sen, Marc Stamminger, Ravi Ramamoorthi, Brandon Lloyd

(2)

Why shadows Why shadows

• Crucial for spatial and depth perception

blocker

receiver

(3)

Two Algorithms from the 1970’s Two Algorithms from the 1970’s

Shadow volumes (Crow 1977)

• Object-space

• Accelerated by hardware stencil buffer

• Large fillrate consumption Shadow maps (Williams 1978)

• Image-space

• Fast and simple

• Supported in hardware

• Undersampling artifacts

NVIDIA

(4)

Shadow volumes Shadow volumes

• Create volumes of

space in shadow from a point light

• Each triangle creates 3 projecting quads

Point light source

Shadow Volume object

light vertex

eye

(5)

Using the volume Using the volume

• To test a point, count the number of

polygons between it and eye

• If more front-facing than back-facing

polygons, then it is in shadow

Point light source

Shadow Volume object

light vertex

eye

(6)

Creating volumes Creating volumes

• Use the silhouette to speed up

• What is silhouette?

N

1

N

2

V

(N

1

.V) . (N

2

.V) < 0

(7)

Shadow volume algorithm Shadow volume algorithm

• Finding volumes

• Rendering

„ Render scene into z-buffer, freeze z-buffer

„ Draw front-facing quads, increment stencil buffer

„ Draw back-facing quads, decrement stencil buffer

„ If (cnt==0) lit else shadowed

(8)

Multiple shadow volumes Multiple shadow volumes

• To test a point, count the number of polygons

between it and eye

• If more front-facing than back-facing

polygons, then it is in shadow

(9)

Shadow Mapping Shadow Mapping

Lance Williams: Brute Force in image space (shadow maps in 1978, but other similar ideas like Z buffer, bump mapping using textures and so on)

Completely image-space algorithm

„ no knowledge of scene’s geometry is required

„ must deal with aliasing artifacts

Well known software rendering technique

„ Basic shadowing technique for Toy Story, etc.

(10)

Phase 1: Render from Light Phase 1: Render from Light

Depth image from light source

(11)

Phase 1: Render from Light Phase 1: Render from Light

Depth image from light source

(12)

Phase 2: Render from Eye Phase 2: Render from Eye

Standard image (with depth) from eye

Eye

(13)

Phase 2+: Project to light for shadows Phase 2+: Project to light for shadows

Project visible points in eye view back to light source

Eye

(Reprojected) depths match for light and eye. VISIBLE

(14)

Project visible points in eye view back to light source

Eye

(Reprojected) depths from light, eye not the same. BLOCKED!!

Phase 2+: Project to light for shadows

Phase 2+: Project to light for shadows

(15)

Visualizing Shadow Mapping Visualizing Shadow Mapping

A fairly complex scene with shadows

the point the point light source light source

(16)

Visualizing Shadow Mapping Visualizing Shadow Mapping

Compare with and without shadows

with shadows

with shadows without shadowswithout shadows

(17)

Visualizing Shadow Mapping Visualizing Shadow Mapping

The scene from the light’s point-of-view

FYI: from the FYI: from the

eyeeyes points point--ofof--viewview again

again

(18)

Visualizing Shadow Mapping Visualizing Shadow Mapping

The depth buffer from the light’s point-of-view

FYI: from the FYI: from the

light

light’’s points point--ofof--viewview again

again

(19)

Visualizing Shadow Mapping

Projecting the depth map onto the eye’s view

FYI: depth map for FYI: depth map for

light

light’’s points point--ofof--viewview again

again

(20)

Visualizing Shadow Mapping Visualizing Shadow Mapping

Comparing light distance to light depth map

Green is where Green is where the light planar the light planar distance and distance and the light depth the light depth map are

map are

approximately approximately equal

equal

NonNon--green is green is where

where shadows shadows should be should be

(21)

Visualizing Shadow Mapping Visualizing Shadow Mapping

Scene with shadows

Notice how Notice how specular specular highlights highlights never appear never appear in shadows in shadows

Notice how Notice how curved

curved

surfaces cast surfaces cast shadows on shadows on each other each other

(22)

Comparison Comparison

• Shadow volumes

„ Pros: accurate, high-quality

„ Cons: fill-rate limited, hard to implement robustly

• Shadow maps

„ Pros: fixed resolution, fast, simple

„ Cons: bias, aliasing

(23)

Percentage Closer filtering [Reeves 1987]

Percentage Closer filtering [Reeves 1987]

(24)

Percentage Closer filtering [Reeves 1987]

Percentage Closer filtering [Reeves 1987]

Provides anti-aliasing at shadow map edges, not soft shadows in the umbra/penumbra sense

(25)

Adaptive shadow maps [Fernando 2001]

Adaptive shadow maps [Fernando 2001]

high-resolution shadow map adaptive shadow map

(26)

Adaptive shadow maps Adaptive shadow maps

details rendering

(27)

Adaptive shadow maps Adaptive shadow maps

Pros:

• Progressive and view-dependent

• Confined to a user-specified memory limit, use LRU policy to delete nodes

Cons:

• Not easy to map to GPU; [Lefohn et. al. 2005]

has mapped it to GPU recently

(28)

Perspective Shadow Maps Perspective Shadow Maps

Marc Stamminger George Drettakis SIGGRAPH 2002

(29)

shadow map aliasing shadow map aliasing

prone to aliasing

when zooming into shadow boundaries

single shadow map pixel

(30)

Aliasing error Aliasing error

shadow plane

frustumview eye

light

(31)

light beam

' w

l

' w

i

'

w

i

w '

i

w '

i

Aliasing error

Aliasing error

' w

l

image beam

(32)

w

i

w

l

light beam

image beam

θ

l

θ

i

' w

i

Aliasing error

Aliasing error

' w

l

m= w '

l

'

w

i

cos θ

l

cos θ

i

w

l

w

i Perspective aliasing

cos θ

l

cos θ

i Projection

aliasing

w

l

w

i

w

i

d

i

r

i

shadow buffer pixel size distance to light

w

l

d

l

r

l

(33)

w

i

w

l

θ

l

θ

i

' w

i

Aliasing error

Aliasing error

' w

l

m= w '

l

' w

i

w

l

w

i Perspective aliasing

w

l

w

i

light beam

image beam

cos θ

l

cos θ

i

cos θ

l

cos θ

i Projection

aliasing

(34)

To eliminate perspective aliasing:

w

l

≤ w

i

Light beam width depends on:

„ Shadow map resolution

„ Parameterization

We have freedom to choose where and how to set up shadow buffer

It should be adaptive to view;

this means that shadow

buffer has to be recomputed for view changes

w

i

w

l

light beam

image beam

Controlling aliasing error

Controlling aliasing error

(35)

perspective transformation perspective transformation

world space post-perspective space

fixed wi normalizing transformation

[Foley] p.258-271

(36)

Parameterization Parameterization

Standard Perspective warped

light image plane

shadow map shadow map

light light

(37)

perspective shadow map perspective shadow map

standard shadow map perspective shadow map

shadow map

image

(38)

perspective shadow map perspective shadow map

standard shadow map perspective shadow map

aliased oversampled

(39)

parallel light transformation parallel light transformation

post-perspective world space

(40)

point light transformation point light transformation

post-perspective world space

(41)

discussion discussion

best case: fixed wl

„ parallel light in post-perspective space

„ no new perspective distortion

post-perspective world space

(42)

discussion discussion

non-optimal case:

„ point light close to frustum

worst case:

„ becomes uniform

shadow map

post-perspective world space

(43)

Perspective shadow map Perspective shadow map

map view map depth result

Shadow map

Perspec- tive

Shadow map

(44)

Shadow maps

Shadow maps

(45)

Perspective Shadow maps

Perspective Shadow maps

(46)

conclusion conclusion

perspective shadow maps

„shadow map in post-perspective space

„just another shadow map matrix

„non-uniform shadow map resolution

„not always possible to find a good solution

„needs recomputation per frame

„minimal overhead for dynamic scenes

(47)

Shadow Silhouette Maps Shadow Silhouette Maps

Pradeep Sen

Mike Cammarano Pat Hanrahan

SIGGRAPH 2003

(slides from Eric Chan)

(48)

Motivation Motivation

Why another shadow algorithm?

Why not use perspective shadow maps?

Stamminger and Drettakis, SIGGRAPH 2002

(49)

Perspective Shadow Maps Perspective Shadow Maps

Addresses perspective aliasing

Optimizes distribution of depth samples Difficulties:

Does not handle projection aliasing Dueling frusta problem

(50)

Dueling Frusta Problem

Dueling Frusta Problem

(51)

Observation Observation

Shadow maps

undersampling can occur anywhere artifacts visible only at shadow edges

(52)

How To Fix Silhouettes?

How To Fix Silhouettes?

depth map silhouette map

One solution:

use a better silhouette approximation

(53)

Shadow Map (Review) Shadow Map (Review)

light source

blocker

receiver

(54)

Shadow Map (Review) Shadow Map (Review)

depth map

(55)

Shadow Map (Review) Shadow Map (Review)

depth map

(56)

Shadow Map (Review) Shadow Map (Review)

depth map

(57)

Depth Mesh Depth Mesh

depth mesh (sampling grid)

(58)

Depth Mesh Depth Mesh

depth mesh + dual mesh original grid (blue)

dual grid (red)

(59)

Depth Mesh Depth Mesh

original grid (blue) dual grid (red)

discrete silhouette boundary

depth mesh + dual mesh

(60)

Depth Mesh Depth Mesh

original grid (blue) dual grid (red)

discrete silhouette boundary

continuous silhouette boundary (green)

depth mesh + dual mesh

(61)

Depth Mesh Depth Mesh

original grid (blue) dual grid (red)

discrete silhouette boundary

continuous silhouette boundary (green)

silhouette map pixels

depth mesh + dual mesh

(62)

Depth Mesh Deformation Depth Mesh Deformation

deformed depth mesh Move depth samples

to lie on silhouette curve

(63)

Depth Mesh Deformation Depth Mesh Deformation

adjusted depth samples

deformed depth mesh

(64)

Depth Mesh Deformation Depth Mesh Deformation

adjusted depth samples

deformed depth mesh

(65)

Better Approximation Better Approximation

piecewise-linear approximation

(66)

Silhouette Map Silhouette Map

silhouette map depth map

deformed depth map

Decomposition of

deformed depth map

(67)

What is a Silhouette Map?

What is a Silhouette Map?

Many ways to think about it:

„ Edge representation

„ 2D image, same resolution as depth map

„ Offset from depth map by ½ pixel in x, y

„ Stores xy-coordinates of silhouette points

„ Stores only one silhouette point per texel

„ Piecewise-linear approximation

(68)

Algorithm

(69)

Algorithm Properties Algorithm Properties

Scalable

Treats perspective and projection aliasing

Supports dynamic scenes Maps to graphics hardware

(70)

Algorithm Overview Algorithm Overview

Image-space algorithm

(71)

Algorithm Overview Algorithm Overview

Create depth map

Step 1

(72)

Algorithm Overview Algorithm Overview

Create silhouette map

Step 2

(73)

Algorithm Overview Algorithm Overview

Render scene and shadows

Step 3

(74)

Create Depth Map Create Depth Map

Same as in regular shadow maps

(75)

Identify Silhouette Edges Identify Silhouette Edges

Find object-space silhouettes (light’s view)

(76)

Create Silhouette Map Create Silhouette Map

Rasterize silhouette edges (light’s view) Find points that lie on silhouette edges Store one such point per texel

silhouette edges silhouette points

(77)

Compute Silhouette Points Compute Silhouette Points

Example:

silhouette edges

point of view of light

(78)

Compute Silhouette Points Compute Silhouette Points

silhouette map (dual grid)

(79)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

(80)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

pick an edge

(81)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

rasterize edge conservatively:

be sure to generate fragments for silhouette pixels

(82)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

for each fragment:

pick a point on the edge

(83)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

silhouette points

(84)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

do the same for other edges

(85)

Compute Silhouette Points Compute Silhouette Points

rasterization of silhouettes

completed silhouette map subtle issues:

• only one point per texel

• new values overwrite old ones

how to pick silhouette points?

(86)

Picking Silhouette Points Picking Silhouette Points

Pick a point on the line that lies inside the texel

?

(87)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

(88)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

pick the vertex itself

(89)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

test for intersection against two diagonals

one

intersection

Case 2:

(90)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

pick the intersection point itself

Case 2:

one

intersection

(91)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

Case 2:

one

intersection

Case 3:

two

intersections

(92)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

Case 2:

one

intersection

Case 3:

two

intersections

use midpoint

(93)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

Case 2:

one

intersection

Case 3:

two

intersections

Case 4:

no

intersections

(94)

Silhouette Point Algorithm Silhouette Point Algorithm

Case 1:

vertex inside

Case 2:

one

intersection

Case 3:

two

intersections

Case 4:

no

intersections

(95)

Render scene Render scene

How to compute shadows?

Split problem into two parts:

non-silhouette pixels: use shadow map silhouette pixels: use silhouette map

(96)

Find Silhouette Pixels Find Silhouette Pixels

Project sample into light space

Compare depth against 4 nearest samples in shadow map

shadow map samples sample to be shaded

(projected to light space)

(97)

L

L S

S Find Silhouette Pixels

Find Silhouette Pixels

S

S S

S

results agree:

non-silhouette pixel

results disagree:

silhouette pixel

Case #1 Case #2

(98)

L

L L

L Treat Non-Silhouette Pixels Treat Non-Silhouette Pixels

S

S S

S

in shadow illuminated

Easy: use depth comparison result

(99)

Treat Silhouette Pixels Treat Silhouette Pixels

fetch five silhouette points

Reconstruct edge using silhouette map

L

L S

S

(100)

Treat Silhouette Pixels Treat Silhouette Pixels

Reconstruct edge using silhouette map

L

L S

splits cell into four quadrants

S

(101)

Treat Silhouette Pixels Treat Silhouette Pixels

Shade sample according to quadrant

L

L S

example: sample in shadow

S

(102)

Six Combinations Six Combinations

S

S S

S

L

S S

S

L

L S

S

L

S S

L

L

L S

L

L

L L

L

(103)

Algorithm Recap Algorithm Recap

Image-space algorithm

(104)

Algorithm Recap (1 of 3) Algorithm Recap (1 of 3)

Create depth map

Easy: just like regular shadow map

(105)

Algorithm Recap (2 of 3) Algorithm Recap (2 of 3)

Pick silhouette points, 1 per texel

Create silhouette map

Rasterize silhouette edges

(106)

Algorithm Recap (3 of 3) Algorithm Recap (3 of 3)

Render scene and shadows

Reconstruct shadow edge Fetch local silhouette points

(107)

Examples and Analysis

(108)

Example 1 Example 1

shadow maps shadow volumes silhouette maps

(109)

Example 1 (closeup) Example 1 (closeup)

shadow maps shadow volumes silhouette maps

(110)

Example 2 Example 2

shadow maps

(111)

Example 2 Example 2

projected silhouette map

(112)

Example 2 Example 2

shadows using silhouette map

(113)

Quality Comparison Quality Comparison

silhouette map shadow map

(114)

Artifacts Artifacts

Silhouette map: one point per texel Multiple edges inside a texel

(115)

Artifacts Artifacts

shadow maps shadow volumes silhouette maps

(116)

Artifacts (closeup) Artifacts (closeup)

shadow maps shadow volumes silhouette maps

Artifacts due to multiple edges More noticeable when animated

(117)

Algorithm Comparison Algorithm Comparison

Perspective Shadow Maps:

„ same generality as shadow maps

„ minimal overhead (2 passes)

„ doesn’t address aliasing in all cases

Shadow Silhouette Maps:

„ addresses aliasing more generally

„ more overhead (3 passes + big shaders)

„ less general than shadow maps

(118)

Combination of Algorithms Combination of Algorithms

Why not combine techniques?

Perspective shadow map:

Optimizes depth sample distribution More samples closer to viewer

Shadow silhouette map:

Optimizes depth sample information Exact silhouette edge locations

(119)

Summary Summary

Image-space algorithm

Silhouette map: deformed depth map Piecewise-linear approximation

Scalable

Compared to (perspective) shadow maps:

Removes aliasing in more cases

Additional overhead and requirements

(120)

An Efficient Hybrid Shadow Rendering Algorithm

An Efficient Hybrid Shadow Rendering Algorithm

Eric Chan

Fedro Durand EGSR 2004

(121)

Not Another Talk on Shadows?!

Not Another Talk on Shadows?!

Main ideas:

• combination of shadow maps + shadow volumes

• computation masks

+

(122)

Fillrate Problem Fillrate Problem

Lots and lots of fillrate!

• rasterization

• stencil updates

Why?

• polygons have large screen area

• polygons overlap

(123)

Fillrate Problem Fillrate Problem

Lots and lots of fillrate!

• rasterization

• stencil updates

Why?

• polygons have large screen area

• polygons overlap

But is this really a problem?

(124)

But Is This Really A Problem?

But Is This Really A Problem?

Case study: Doom 3 engine (id Software)

• bump mapping

• per-pixel surface shading

• dynamic and projected lights

• atmospheric effects

• particle effects

• shadow volumes

50%

50%

“Shadowing accounts for about half of the game’s rendering time.”

— John Carmack

(125)

Two Observations (shadow maps) Two Observations (shadow maps)

Shadow-map aliasing is ugly

But — only noticeable at shadow silhouettes

shadow silhouette

(126)

Two Observations (shadow volumes) Two Observations (shadow volumes)

Shadow volumes are accurate everywhere But — accuracy is only needed at silhouettes

few silhouette pixels

(127)

Hybrid Approach Hybrid Approach

Decompose the problem:

• use shadow volumes at silhouettes

• use shadow maps everywhere else

shadow map + shadow volume

(128)

Algorithm Algorithm

1. 3.

2. 4.

(129)

Algorithm Algorithm

1. 3.

2. 4.

create a shadow map

(130)

Algorithm Algorithm

1. 3.

2. 4.

find silhouette pixels

(131)

Algorithm Algorithm

1. 3.

2. 4.

apply shadow volumes only at silhouette pixels

(132)

Algorithm Algorithm

1. 3.

2. 4.

apply shadow maps everywhere else

(133)

Test Scenes

Test Scenes

(134)

Image Quality

Image Quality

(135)

Shadow maps

(136)

Silhouettes

(137)

Reconstruction

(138)

Hybrid Shadow maps

Time: 19 ms Time: 5 ms

(139)

Shadow volumes Hybrid

Time: 48 ms Time: 19 ms

參考文獻

相關文件

‹ Based on the coded rules, facial features in an input image Based on the coded rules, facial features in an input image are extracted first, and face candidates are identified.

Most of teachers agree with positive effects of the 99 curriculum on practical instruction in school, however, they seem to concern inequalities of content between volumes and

Given a sample space  and an event  in the  sample space  , let 

基本的原理是假設我們知道 light source 在那裡,找出 shadow edge,light source 和 shadow edge 可以求得 shadow plane,加上有 calibrate 後的 camera 知道那物體上一 點 p

 Presents a metric selection framew ork for online anomaly detection i n utility cloud.. ◦ Select most essential metrics by appl ying metric selection and

Soft Shadow Volume Algorithm Using

• Li-Yi Wei, Marc Levoy, Fast Texture Synthesis Using Tree-Structured Vector Quantization, SIGGRAPH 2000. Jacobs, Nuria Oliver, Brian Curless,

1 camera sample and 16 shadow samples per pixel. 16 camera samples and each with 1 shadow sample