74
Beyond Programmable Shading Course ACM SIGGRAPH 2010 Surveying Real-Time Rendering Algorithms Beyond Programmable Shading David Luebke NVIDIA Research

06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Embed Size (px)

Citation preview

Page 1: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Surveying Real-Time Rendering Algorithms

Beyond Programmable Shading

David Luebke

NVIDIA Research

Page 2: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

The continuum “Beyond Programmable Shading”

“Just” programmableshading: DX, OGL

Page 3: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

The continuum “Beyond Programmable Shading”

“Just” programmableshading: DX, OGL

“Pure” compute-basedgraphics: CUDA, OptiX

Page 4: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

The continuum “Beyond Programmable Shading”

“Just” programmableshading: DX, OGL

“Pure” compute-basedgraphics: CUDA, OptiX

Interesting middle ground!

Page 5: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

3 Hybrid Graphics/Compute Patterns

• Render – Analyze – Render

• Render to alternate data structure

• Rasterize to invoke spatially localized compute

7/29/2010 5Beyond Programmable Shading, SIGGRAPH 2010

Page 6: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Render – Analyze – Render

• Stochastic Transparency

• Sample Distribution Shadow Maps

Beyond Programmable Shading, SIGGRAPH 2010 67/29/2010

Page 7: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Stochastic Transparency

Eric Enderton, Erik Sintorn, Peter Shirley, David

Luebke, 2010 ACM Symposium on Interactive 3D

Graphics & Games

Beyond Programmable Shading, SIGGRAPH 2010 77/29/2010

Page 8: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Screen-door transparency

Stochastic Transparency

Page 9: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Screen-door transparency

Stochastic Transparency

Page 10: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Screen-door + multi-sampling

(“Alpha-to-coverage”)

Stochastic Transparency

Page 11: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Stochastic Transparency

Screen-door + multi-sampling + random masks.

• Correct on average, in all cases

– Foliage, Smoke, Hair, Glass. CAD. Shadows.

– Mixed together

• Fast

– One order-independent pass, one MSAA z-buffer

• But noisy

More samples

More algorithms

Page 12: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

(Reference)

Page 13: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Alg 1. Basic

8 spp

Page 14: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Alg 1. Basic

16 spp

Page 15: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Alg 1. Basic

32 spp

Page 16: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Alg 1. Basic

64 spp

Page 17: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Alg 1. Basic

512 spp

Page 18: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Alg 1. Basic

8 spp

Page 19: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

“Depth-based algorithm”, 8 spp

Analyze depth and accumulated total alpha / pixel

Page 20: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Stochastic Transparency

15,000 hairs

6,000 grass cards

shadows

12 fps 1024x768 8x MSAA

Beyond Programmable Shading, SIGGRAPH 2010 207/29/2010

Page 21: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Stochastic Transparency

Scales with MSAA

Better GPU Better image

Turns OIT into a Moore’s Law problem

Page 22: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Sample Distribution Shadow Maps

Andrew Lauritzen, Marco Salvi, Aaron Lefohn,

Advances in Real-Time Rendering in 3D Graphics and

Games, SIGGRAPH 2010 Courses

http://visual-computing.intel-research.net/art/publications/sdsm/

Beyond Programmable Shading, SIGGRAPH 2010 227/29/2010

Page 23: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

The Problem with Shadow Maps

Scene from Left 4 Dead 2, courtesy of Valve Corporation

Page 24: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Cascaded Shadow Maps

Scene from Left 4 Dead 2, courtesy of Valve Corporation 24

Page 25: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Seen from Light Space

25

Page 26: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

PSSM Partitions in Light Space

26

Page 27: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Sample Distribution Shadow Maps

• Analyze the shadow sample distribution

– Find tight Z min/max

– Partition Z range logarithmically – fully automatic!

• Compute tight light-space bounds per partition

– Axis-aligned bounding box on view samples

– Greatly increases useful shadow resolution

Beyond Programmable Shading, SIGGRAPH 2010 277/29/2010

Page 28: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

SDSM Partitions in Light Space

28

Page 29: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Light-Space Bounds for Partitions

29

Page 30: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Sample Distribution Shadow Maps

Scene from Left 4 Dead 2, courtesy of Valve Corporation

Page 31: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Compare to Cascaded Shadow Maps

Scene from Left 4 Dead 2, courtesy of Valve Corporation

Page 32: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Render to Data Structure

• Alias-Free Shadow Maps

• Append-Consume OIT

• GPU Progressive Photon Mapping

Beyond Programmable Shading, SIGGRAPH 2010 327/29/2010

Page 33: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Alias-Free Shadow Maps

Slides from Sample Based Visibility for Soft Shadows

using Alias-free Shadow Maps by Sintorn, Eisemann,

and Assarsson, EGSR 2008.

See related publications (Irregular Z-buffer and Alias-

Free Shadow Maps) in speaker notes

Page 34: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

34

The Problem With Shadow Maps:Multiple View Samples per Light Sample

Scene rendered as seenfrom camera

Scene rendered as seenfrom lightDepth of closest fragments Are rendered to shadowmap

Several screen samples endUp in the same light-space texel

Page 35: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

35

Shadow Map Data Structure: Compact List of View Samples per Light Texel

Transform and project view-samples into lightspace, then store in a compact datastructure with a list per lightspace texel

Page 36: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

36

Using the Shadow Map: Test all light-space triangles against view samples

Render all geometry (conservatively) from lights point of view and for each generated fragment, test all view-samples in that list against the triangle and set the corresponding bit in the outputif occluding.

Page 37: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

37

Using the Shadow Map: Look up each view-space sample as needed

Finally, use the result from the previous stepand the SM datastructure in a fullscreen passover the camera-view image to find shadowinginformation for each pixel

Page 38: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Append-Consume OIT

Real-Time Concurrent Linked List Construction on the GPU,

Yang, Hensley, Grün, and Thibieroz, AMD

EGSR 2010 paper and presented in Advances in Real-Time

Rendering in 3D Graphics and Games, SIGGRAPH 2010

Courses

Page 39: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

The Problem with Transparency

Sorting is hard!39

With Sorting

No Sorting

Skeleton hidden

Arm appears in

front of body

Page 40: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Solution: Sort Fragments Per Pixel

• Store linked list of fragments per pixel

– Each list record stores color, alpha, depth

– Thread linked lists through DirectCompute UAV

• A “resolve” pass sorts then blends fragments

Beyond Programmable Shading, SIGGRAPH 2010 407/29/2010

Page 41: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Create Linked List

-1 -1 -1 -1 -1 -1

-1 -1 -1 -1 -1 -1

-1 -1 -1 -1 -1 -1Render Target

Start Offset Buffer

Fragment and Link Buffer

-1 -1 -1 -1 -1 -1-1 -1 -1 -1 -1 -1

-1 -1 -1 -1 -1 -1

0 1 2 3 4 5 6 …

Page 42: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Create Linked List

-1 -1 -1 -1 -1 -1

-1 0 -1 -1 -1 -1

-1 -1 -1 -1 -1 -1

0.87-1

-1 -1 -1 -1 -1 -1

-1 -1 -1 -1 -1 -1-1 -1 -1 -1 -1 -1

Page 43: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Create Linked List

-1 -1 -1 -1 -1 -1

-1 0 -1 -1 -1 -1

-1 -1 -1 -1 -1 -1

0.87-1

0.89-1

0.90-1

-1 -1 -1 -1 -1 -1

-1 -1 -1 1 2 -1-1 -1 -1 -1 -1 -1

Page 44: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Create Linked List

-1 -1 -1 -1 -1 -1

-1 3 4 -1 -1 -1

-1 -1 -1 -1 -1 -1

0.87-1

0.89-1

0.90-1

0.650

0.65-1

-1 -1 -1 -1 -1 -1

-1 -1 -1 1 2 -1-1 -1 -1 -1 -1 -1

Page 45: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Create Linked List

-1 -1 -1 -1 -1 -1

-1 5 4 -1 -1 -1

-1 -1 -1 -1 -1 -1

0.87-1

0.89-1

0.90-1

0.650

0.65-1

0.713

-1 -1 -1 -1 -1 -1

-1 -1 -1 1 2 -1-1 -1 -1 -1 -1 -1

Page 46: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Render Fragments

-1 -1 -1 -1 -1 -1

-1 5 4 -1 -1 -1

-1 -1 -1 -1 -1 -1

0.87-1

0.89-1

0.90-1

0.650

0.65-1

0.713

-1 -1 -1 -1 -1 -1

-1 -1 -1 1 2 -1-1 -1 -1 -1 -1 -1

Walk the list and store in

temporary array

0.71 0.65 0.87

Page 47: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Render Fragments

-1 -1 -1 -1 -1 -1

-1 5 4 -1 -1 -1

-1 -1 -1 -1 -1 -1

0.87-1

0.89-1

0.90-1

0.650

0.65-1

0.713

-1 -1 -1 -1 -1 -1

-1 -1 -1 1 2 -1-1 -1 -1 -1 -1 -1

Sort temporary array

Blend colors and write out

0.65 0.71 0.87

Page 48: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

GPU Progressive Photon Mapping

Pre-publication preview

Toshiya Hachisuka & Henrik Wann Jensen, UC San Diego

Page 49: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Progressive Photon Mapping

• [Hachisuka et al. 08, 09]

Eye Pass Photon Pass

Page 50: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Key Idea

• New stochastic hashed-grid algorithm

– Only keep a single photon stochastically

– Data-parallel and uniform work distribution

12

3

4

Grid Hash

1 42

3

Standard Hashing

12

3

4

Grid Hash

2

3

Stochastic Hashing

Page 51: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Algorithm

Photons Eye ray hit points

Hash entries

Hash counters

3

2 2

1

3 3

5

2

4

Stochastic Hashed Grid

Scatter

(overwrite)

Gather

(mul)

Hash

Hash

Scatter

(atomic inc)

Page 52: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Results: Path Tracing vs PPM

Full global illumination

Rendering time: 10min

Same ray tracing core

Path

Tra

cin

gP

PM

Page 53: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Rasterization as spatialized compute

• Image Space Photon Mapping

• Ambient Occlusion Volumes

• Stochastic Rasterization

Beyond Programmable Shading, SIGGRAPH 2010 537/29/2010

Page 54: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Image-Space Photon Mapping

Hardware-Accelerated Global Illumination by Image Space

Photon Mapping, by Morgan McGuire and David Luebke

High Performance Graphics 2009

Page 55: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Image Space Photon Mapping

Beyond Programmable Shading, SIGGRAPH 2010 557/29/2010

First bounce:

bounce map

Final bounce:

photon volumes

Page 56: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

ISPM Radiance Estimate

• Traditional photon mapping: gather• Per pixel

• k-NN search in k-d tree

• World-space (3D)

• Image space photon mapping: scatter• Per photon

• Hardware rasterization using photon volumes

• Image space (2D)

Page 57: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

• Invoke an illumination contribution on all pixels

for which a photon might be a valid estimate of

incident radiance

• Not virtual point lights (a.k.a. instant radiosity)

• Not 2D splatting

Photon Volumesphoton

Page 58: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

58

Page 59: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

59

Page 60: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

60

Page 61: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Ambient Occlusion Volumes

Ambient occlusion volumes by Morgan McGuire, High

Performance Graphics 2010

Two Methods for Fast Ray-Cast Ambient Occlusion by Samuli

Laine and Tero Karras, EGSR 2010.

Page 62: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Ambient Occlusion in Theory

• Occlusion of incoming ambient light

Light from these

directions reaches

the surface

Light from these directions does

not reach the surface

Page 63: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

What It Looks Like

Page 64: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Ray Casts for Ambient Occlusion

• Cast a number of rays from the point to be shaded

• Determine occlusion distance, apply falloff, sum

Page 65: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Occlusion of a Triangle

• Combine four precomputed bitwise occlusion masks

Page 66: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Rasterize Triangle Regions of Influence

Page 67: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Multiple choices for bounding volume

• Large triangles: construct hexagonal prism

• Small triangles: construct hemispherical billboard

Bounding the Region of Influence

Large triangle Small triangle

Page 68: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Ambient Occlusion Volumes

68Visualization of a similar analytic approach (McGuire, HPG2010)

Page 69: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

Stochastic Rasterization

Real-Time Stochastic Rasterization on Conventional GPU

Architectures, by McGuire, Enderton, Shirley, Luebke

High Performance Graphics 2010

Page 70: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Stochastic Rasterization

• Rasterize bound of time-continuous triangle

• Intersect in fragment shader

Beyond Programmable Shading, SIGGRAPH 2010 707/29/2010

Page 71: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Summary

• Three interesting computational graphics patterns

1. Render analyze render

2. Render directly to alternate data structure

3. Rasterize to invoke spatially localized computation

• A frequent theme: deferred shading

Beyond Programmable Shading, SIGGRAPH 2010 717/29/2010

Page 72: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Many more examples!

72From Metro 2033, © THQ and 4A Games

Real-Time Lens Blur Effects and

Focus Control, Lee et al.,

SIGGRAPH 2010

Page 73: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Acknowledgements

Many thanks for use of their slides & images:

Samuli Laine Tero Karras Morgan McGuire

Eric Enderton Justin Hensley Jason Yang

Mike Houston Aaron Lefohn Andrew Lauritzen

Sungkil Lee Toshiya Hachisuka Metro 2033

Beyond Programmable Shading, SIGGRAPH 2010 737/29/2010

Page 74: 06 Luebke Survey Rendering Algorithms BPS SIGGRAPH2010

Beyond Programmable Shading CourseACM SIGGRAPH 2010

THANK YOU

[email protected]