36
AGGREGATE G-BUFFER ANTI-ALIASING Cyril Crassin 1 , Morgan McGuire 1,2 , Kayvon Fatahalian 3 , Aaron Lefohn 1 1 NVIDIA 2 Williams College 3 Carnegie Mellon University

Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGGREGATE G-BUFFER ANTI-ALIASING

Cyril Crassin1, Morgan McGuire1,2, Kayvon Fatahalian3, Aaron Lefohn1

1NVIDIA 2Williams College 3Carnegie Mellon University

Page 2: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

The Mummy – [© Universal Pictures / Digital Domain / Rhythm&Hues]

Motivation

Pixel

Page 3: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Pixel frustum

Pixel

Per-sample visibility

and shading attributes

Pixel frustum

Aggregate 0

Aggregate 1

Aggregate

shading

Overview

High frequency shading is too costly

Idea: Strong decoupling of shading rate

Shading statistical geometry distributions

Pixel frustum

Page 4: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate
Page 5: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

8

1

Page 6: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate
Page 7: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGAA (2A) MSAA 8x Single-sampled

Page 8: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGAA (2A) MSAA 8x Single-sampled

Page 9: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGAA (2A) MSAA 8x Single-sampled

Page 10: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Related work 1/2

Deferred shading

Simple/Complex [Lauritzen 2010]

Segmentation based on geometric complexity

Shading amortization:

Across same planar surface

…Or almost planar -> Quality reduction

Simple scenes + large memory requirement

Credit: Crytek [Sousa 2013]

Page 11: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Related work 2/2

Surface Based Anti-Aliasing (SBAA) [Salvi 2012]

High frequency visibility

Simplified geometry pre-pass

Only store and shade the n most contributing surfaces

Non-shaded surface information discarded

-> Aliasing in complex regions

Pixel frustum

SBAA

Pixel frustum

SBAA MSAA

[Sa

lvi 2

01

2]

SSAA

Page 12: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Aggregate

shading attributes Per-sample visibility

and shading attributes

Pixel frustum Pixel frustum

Aggregate 0

Aggregate 1

AGAA overview

Integrate ALL geometry samples

All surfaces + curvature

Accumulate and filter geometry samples in

pixel-space before shading

Per-sample visibility (Z-buffer)

Similar to texture/voxel-space pre-filtering

But pixel-space + on-the-fly aggregation

Aggregate G-Buffer statics:

Normal Distribution Function (NDF)

+ sub-pixel position distribution.

Average Albedo, Metal coef., emissive, etc.

Page 13: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Rendering with Aggregates

NDF

Mean albedo

Mean metal

AG-Buffer

Pix

el

2xAA

[2x Aggregates]

Deferred Shading

G-Buffer

Normal

Albedo

Metal

Pix

el

[8x Samples]

8xAA

G-Buffer Generation

Raster pass

Conversion AG-Buffer

Generation

Raster pass

Blend

[8x Samples]

Depth Prepass

Pix

el

Depth

Framebuffer 8xAA

Raster pass

Early depth testing

Page 14: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Rendering with Aggregates

NDF

Mean albedo

Mean metal

AG-Buffer

Pix

el

2xAA

[2x Aggregates]

Deferred Shading

AG-Buffer Generation

Raster pass

Blend

[8x Samples]

Depth Prepass

Pix

el

Depth

Framebuffer 8xAA

Raster pass

Early depth testing

Aggregate Meta Data

[Per-pixel]

Aggregate Definition

Face normal

Page 15: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Light source

Pixel frustum

Aggregate definition

Clustering visibility samples:

Cross-primitives + Disjoint surfaces

Goal: Minimize shading errors due to correlated

attributes [Bruneton and Neyret 2012]

Distance function:

Orientation + distance-based clustering

Control over characteristic length of the scene

Aggregate Meta Data

[Per-pixel]

Aggregate Definition

Face normal

[8x Samples]

Pix

el

Depth

Framebuffer 8xAA

Aggregate 1

Aggregate 0 Pixel frustum

Page 16: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Deferred Shading

Similar to shading from filtered texture maps

AGAA is independent from the shading model

We used the Blinn-Phong BRDF model

Filtering Specular component using Toksvig

[Toksvig 2005]

+Analytic approx. from Toksvig for Lambertian diffuse

[Baker and Hill 2012]

Shadowing must be filtered

NDF

Mean albedo

Mean metal

AG-Buffer

Deferred Shading

Pix

el

2xAA

[2x Aggregates]

Depth buffer

Shadow map

Pixel frustum

Aggregate 0

Aggregate 1

Page 17: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate
Page 18: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Deferred 8x (reference)

Page 19: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

FXAA

Page 20: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGAA (1A)

Shading events: 1 /Pixel Memory: 41 MB

Page 21: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGAA (2A)

Shading events: 1.51 /Pixel Memory: 71 MB

Page 22: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Shading events: 6.68 /Pixel (Simple/Complex)

Deferred 8x (reference)

Memory: 112 MB

Page 23: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

AGAA (2A)

Shading events: 1.51 /Pixel Memory: 71 MB

Page 24: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Shading events: 1.72 /Pixel

SBAA (2S)

Memory: 88 MB

Page 25: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Shading events: 3.32 /Pixel

SBAA (6S)

Memory: 137 MB

Page 26: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

8

1

Shading events: 1.72 /Pixel

SBAA (6S)

Memory: 137 MB

Page 27: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

8

1

Shading events: 3.32 /Pixel

SBAA (6S)

Memory: 137 MB

Page 28: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

8

1

AGAA (2A)

Shading events: 1.51 /Pixel Memory: 71 MB

Page 29: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Results : Performance

Time (ms) AGAA Deferred Simple/Complex [Ref]

Scene

1. Prepass 2. Aggregate

Def. 3. AG-Buffer

Generation 4. Shading

Total

G-Buffer

Gen. Simple/

Complex Shading

Total

OldCity 2.61 0.6 3.8 3.6 10.61 5.73 0.41 10.24 16.38

Old City

54% Faster rendering than Simple/Complex

(2.84x Faster shading)

Deferred shading @8x MSAA 720p - Comparison with Simple/Complex [Lauritzen 2010] - NVIDIA GTX980 (Maxwell GM204)

UE3 FoliageMap 2 0.6 2.47 3.67 8.74 4.35 0.41 10.45 15.21

Page 30: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Results: Memory savings

% Memory relative to super-sampled G-Buffer

37% saving @8x - 2 Aggregates

20% less than SBAA @2 Surfaces - ~40% less @Iso quality

37

63

77

89

31

52

59

66

28

46 50

54

0

10

20

30

40

50

60

70

80

90

100

1 2 3 4

% m

em

rela

tive t

o G

-Buff

er

Number of Aggregates /pixel

AG-Buffer 8x MSAA 16x MSAA 32x MSAA

AGAA G-Buffer layout:

[16B/Aggregate + 6B/Sample]

G-Buffer layout: [16B/sample]

Page 31: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Constraints and Limitations

Unified material with unique shading model

No material switch (Skin, water, hair, cloth…)

All shading inputs must be filterable !

NDF precision:

A few very differently oriented surfaces

But uni-modal Gaussian distrib.

Specular sparkling

Correlation issues:

Lit green foliage + Shadowed red wall

1 Aggregate/ pixel

Page 32: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Conclusion

Path forward for very high sampling rates in real-time

Scalable: Bounded storage and shading rate

Properties:

Cross-primitives + Cross-surfaces amortization

All geometric details integrated

Remaining work on pre-filtering schemes for advanced unified

shading/material models

Page 33: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

THANK YOU ! Questions ?

Page 34: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate
Page 35: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

BACKUPS

Page 36: Aggregate g-buffer Anti-Aliasing · SSAA . Aggregate shading attributes Per-sample visibility and shading attributes Pixel frustum Aggregate 0 Aggregate 1 AGAA overview Integrate

Rasterize @ sample frequency (Eg. 8x MSAA)

Inside a set of color buffers @ Aggregate frequency (Eg. 2x) *[TIR M->N]

Per-sample early depth testing

Fragment shader:

Generates attributes for accum., weighted by visible coverage *[Post-depth coverage]

Route output attributes into one of the aggregates *[Out coverage override]

Additive blending:

Additive blending inside AG-Buffer (weighted sum)

Step 3: AG-Buffer generation

Depth Test

Prim. Coverage

Depth

Fragment Shader

*Post-depth

coverage

Blend (ADDITIVE)

Fragment

output attributes

Raster

8x MSAA

*Output coverage

(routing) …

NDF

Mean albedo

Mean metal

AG-Buffer 2xAA

Aggregate Meta Data

Depth buffer

* [Maxwell or DX12 hardware

specific features]