Top Banner
Edge-Aware Shaders Peter-Pike Sloan and Peter Shirley NVIDIA
35

Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Mar 15, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Edge-Aware Shaders

Peter-Pike Sloan and Peter Shirley NVIDIA

Page 2: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Motivation

Page 3: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Conventional shaders unaware of edges

P

Page 4: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Conventional shaders unaware of edges

P

a

Page 5: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Inspiration PLACEHOLDER - PERMISSIONS

[Deering88] [Reshetov09]

[FXAA10] [Nehab07]

Z N RGB

Page 6: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Alternative approaches?

Explicitly model geometry/texture?

— Increases authoring time and storage

— Concave edges implicitly defined

Completely in CUDA/DXCompute?

— Rasterization turns out to be useful

Forward rendering?

— Implicit features

— Conceptually clean in deferred [Kavan11]

Page 7: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Why not use CUDA or DirectCompute?

Rasterization

— Splatting convex edges, splatting corners

Setup Draw Call parameters from GPU

— Also in DirectCompute

A (tiny) bit easier to integrate with graphics app

RWStructuredBuffer<WSCornerStruct> WSCornerBuffer; uint uPos = WSCornerBuffer.IncrementCounter(); WSCornerBufferRead[uPos].Color = float3(1,0,0);

pd3dDeviceContext->CopyStructureCount(pCountBuffer,4,m_WSCornerBufferUAV); pd3dDeviceContext->DrawIndexedInstancedIndirect(pCountBuffer,0);

Page 8: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012
Page 9: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Algorithm

Splat convex edges

Search GBuffer for edges

Flood Fill (jump flooding)

Splat existing corners

Search for new corners

Update GBuffer

Shade image

Page 10: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Edge Features

Page 11: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Line Information + Feature Buffer

Direction vector in eye space

Point on edge [*]

Feature buffer

— asfloat(distance)

— 2x12bits for location

— 1 bit concave/convex

— 2 bits for which neighbor

2x16 bits SNORM [Meyer10]

4x32 bits float

2x32 bits uint

Page 12: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Silhouette Edges

struct AuxFace { unsigned int uFlags; // 3 bits edge info, 24 bits are material ID's float3 OppNormals[3]; // opposite normals }; StructuredBuffer<AuxFace> SilAuxFaceBuffer;

Page 13: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Silhouette Edges

// now fixup these distances [branch] if (fDist.x < g_DistanceThreshold) { float fCheck = dot(P-verts[0],edgeVectors[0]); if (fCheck < 0) { fDist.x = length(P-verts[0]); } else if (fCheck > dot(edgeVectors[0],edgeVectors[0])) { fDist.x = length(P-verts[1]); } }

Page 14: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Line Textures (sparse)

Page 15: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Flood Fill

Jump Flooding

[Rong06]

Page 16: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Flood Fill

Page 17: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Corners

Page 18: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Corner Search

First Pass

— Volume of neighboring normals:

— Store distance, set candidate bit, encode neighbor

Second Pass

— Suppress corner if any 8-connected neighbor is closer

(abs(dot(N,cross(NR,ND))) > 0.2f)

struct WSCornerStruct { float3 CornerPos; // origin float3 CornerNorm; // average normal at corner float3 LineDirs[3]; // direction for each edge float3 LineNorms[3]; // needed for shading – average of faces uint LineInfo[3]; // has convex/concave bit, material pair 17 bits only... }; RWStructuredBuffer<WSCornerStruct> WSCornerBufferWrite; // IncrementCounter() to add StructuredBuffer<WSCornerStruct> WSCornerBufferRead;

Page 19: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Corner Splat

Occurs before search

Copy the number of corners into CountBuffer (GPU)

Transform corners into eye space (CountBuffer+PS)

Draw a cube for each corner, # Instances from CountBuffer

Bit in Feature Buffer set indicating corner

— Screen coordinates replaced with corner ID, neighbor replaced

with edge index in corner buffer

pd3dDeviceContext->CopyStructureCount(pCountBuffer,4,m_WSCornerBufferUAV); // Bunch of other code… pd3dDeviceContext->DrawIndexedInstancedIndirect(pCountBuffer,0);

Page 20: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Corner Fixup

Page 21: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Results

Page 22: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Original

Page 23: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Modify G-Buffer

Round edges – interpolate to average normal at edge

Paint slop – use material ID on either side + noise

Grout/Caulk – material ID on either side

Page 24: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Performance Quadro 5000

Task ms %

Compute G Buffer 882 8.78

Line Buffers (splat + search) 1360 13.53

Jump Flooding 6670 66.36

Corner splat + search 508 5.05

Shade 631 6.28

Page 25: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Performance

— Faster Jump Flooding [Rong2007]

— Compress Buffers

— Move stages to compute/CUDA?

Quality

— Interaction with FXAA? AA in general?

— LOD

Workflow/artist in the loop?

Future Work

Page 26: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

References

[Deering88] The Triangle Processor and Normal Vector Shader: a VLSI System for High Performance Graphics, SIGGRAPH 1998

[Reshetov09] Morphological Antialiasing, HPG 2009

[FXAA10] http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf

[Nehab07] Accelerating Real-Time Shading with Reverse Reprojection Caching, Graphics Hardware 2007

[Kavan11] Least Squares Vertex Baking, EGSR 2011

[Meyer10] On floating-point normal vectors, EGSR 2010

[Rong06] Jump Flooding in GPU with Applications to Voronoi Diagram and Distance Transform, I3D 2006

[Rong07] Variants of Jump Flooding Algorithm for Computing Discrete Voronoi Diagrams, 4th Symposium on Voronoi Diagrams in Science and Engineering

Page 27: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Backup slides after this…

Page 28: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Line Features

Page 29: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Line textures (sparse set of points)

Page 30: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Flood Fill

Page 31: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012

Flood Fill

Page 32: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012
Page 33: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012
Page 34: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012
Page 35: Edge-Aware Shaders for Real-Time Computer Graphics - GTC 2012