Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute...

38
Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand

Transcript of Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute...

Page 1: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Rendering Fake Soft Shadows with Smoothies

Laboratory for Computer ScienceMassachusetts Institute of

Technology

Eric Chan Frédo Durand

Page 2: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Goals: Interactive framerates Hardware-accelerated Good image quality Dynamic environments

Applications: Game engines (e.g. Doom 3) Interactive walkthroughs

Challenge: balancing quality and performance

Real-Time Shadows

NVIDIA

Page 3: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

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

Page 4: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Soft Shadow Volumes

Penumbra wedges:

Shadow polygons wedges

Compute penumbra with pixel shaders

Accurate approximation

Papers:

Assarsson et al. (EGRW 2002, SIGGRAPH 2003, HWWS 2003)

But: much higher fillrate needed

Assarsson and Akenine-Möller

wedge

Page 5: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Soft Shadow Maps

Ideas: Filtering Stochastic sampling Image warping

Examples: Percentage closer filtering (Reeves et al., SIGGRAPH 1987) Deep shadow maps (Lokovic and Veach, SIGGRAPH 2000) Image-based soft shadows (Agrawala et al., SIGGRAPH

2000) Multisampling hard shadows (Heckbert and Herf, TR 1997)

But: need dense sampling to minimize artifacts

Agrawala et al.

Page 6: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Soft Shadow Maps (cont.)

Approximations

Examples: Convolution (Soler and Sillion, SIGGRAPH 1998)

Linear lights (Heidrich et al., EGRW 2000)

Outer surfaces (Parker et al., TR 1998)

Plateaus (Haines, JGT 2001)

Penumbra maps (Wyman and Hansen, EGSR 2003)

Soler and Sillion

Page 7: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Overview

Extend basic shadow map approach

Use extra primitives (smoothies) to soften shadows

light’s view (blockers only) light’s view (blockers + smoothies)

Page 8: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Fake Soft Shadows

Shadows not geometrically correct

Shadows appear qualitatively like soft shadows

Hard shadows Fake soft shadows

Page 9: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Contributions

Smoothie shadow algorithm:

Creates soft shadow edges

Hides aliasing artifacts

Efficient (object / image space)

Hardware-accelerated

Supports dynamic scenes

Page 10: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

1. Create Shadow Map

Render blockers into depth map

light’s view

observer’s view

Page 11: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

2. Identify Silhouette Edges

Find blockers’ silhouette edges in object space

object-spacesilhouettes

observer’s view

light’s view

Page 12: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

3. Construct Smoothies

Blocker only:

silhouette vertex

silhouette edges

blocker exterior

Page 13: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

3. Construct Smoothies (cont.)

Blocker + smoothies:

silhouette vertex

silhouette edges

smoothie edge

smoothie corner

t

t

blocker exterior

Page 14: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

3. Construct Smoothies (cont.)

Smoothie edges are rectangles in screen space with a fixed width

Smoothie corners connect adjacent smoothie edges

t

t

geometry shading

Page 15: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

4. Render Smoothies

Store depth and alpha values into smoothie bufferSmoothie Buffer (depth) Smoothie Buffer (alpha)

light’s viewpoint

Page 16: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

5. Compute Shadows

Compute intensity using depth comparisons

smoothie

light source

blocker

receiver

Page 17: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

5. Compute Shadows

Image sample behind blocker (intensity = 0)

smoothie

light source

blocker

receivercompletely in shadow

Page 18: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

5. Compute Shadows

Image sample behind smoothie (intensity = )

partially in shadow

smoothie

light source

blocker

receiver

Page 19: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

5. Compute Shadows

Image sample illuminated (intensity = 1)

illuminated

smoothie

light source

blocker

receiver

Page 20: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Computing Alpha Values

Intuition:

Alpha defines penumbra shape

Should vary with ratio b/r

blocker

smoothie

receiver

light source

r b

Page 21: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Computing Alpha Values (cont.)

1. Linearly interpolate alpha

2. Remap alpha at each pixel using ratio b/r:

’ = / (1 – b/r)

original remapped result

Page 22: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Multiple Blockers and Receivers

Page 23: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Multiple Receivers

light’s view

same thickness

Smoothie buffer(linearly-interpolated )

1

2

Page 24: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Multiple Receivers (cont.)

light’s view

Smoothie buffer(remapped )

different thickness

1

2

Page 25: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Multiple Receivers (cont.)

Final image

observer’s view

different thickness

Page 26: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Multiple Blockers

What happens when smoothies overlap?

smoothie overlap

Page 27: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Multiple Blockers (cont.)

Minimum blending: just keep minimum of alpha values

smoothie ray tracer

Page 28: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Comparison to Penumbra Maps

Penumbra maps (Wyman and Hansen, EGSR 2003)

Same idea, different details

Smoothie depth: Extra storage + comparison Handles surfaces that act only as receivers

cones and sheets quads

blockers only blockers + smoothies

Geometry:

Store depth:

Penumbra Maps Smoothies

Page 29: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Results

System information:

2.6 GHz Intel Pentium 4

NVIDIA Geforce FX 5800 Ultra

Page 30: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Video

Page 31: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Hiding Aliasing (256 x 256)

shadow map bicubic filter

smoothie (t = 0.02) smoothie (t = 0.08)

16 ms 129 ms

19 ms 19 ms

Page 32: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Hiding Aliasing (1024 x 1024)

shadow map bicubic filter

smoothie (t = 0.02) smoothie (t = 0.08)

17 ms 142 ms

22 ms 24 ms

Page 33: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Comparison to Ray Tracer

smoothie ray tracer

increasing sizeof light source

Page 34: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Video

original md2shader demo courtesy of Mark Kilgard

Page 35: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Discussion

Shadow maps: Assumes directional light or spotlight Discrete buffer samples

Shadow volumes: Assumes blockers are closed triangle

meshes Silhouettes identified in object space

Smoothies: Rendered from light’s viewpoint Occupy small screen area inexpensive

Page 36: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Summary

Contribution:

Simple extension to shadow maps

Shadows edges are fake, but look like soft shadows

Fast, maps well to graphics hardware

Page 37: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Trends in Real-Time Shadows

Architectures and algorithms go together

Currently, architectures algorithms:

Store per-pixel data at full precision

But also, algorithms architectures:

Shadow maps

Shadow volume depth bounds

Aggressive early z and stencil reject

Page 38: Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand.

Acknowledgments

Hardware, drivers, and bug fixes Mark Kilgard, Cass Everitt, David Kirk, Matt

Papakipos (NVIDIA)

Michael Doggett, Evan Hart, James Percy (ATI)

Writing and code Sylvain Lefebvre, George Drettakis, Janet Chen, Bill

Mark

Xavier Décoret, Henrik Wann Jensen

Funding ASEE NDSEG Fellowship