edge-aware shaders for real-time computer graphics - gtc...

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

Upload: vudang

Post on 13-Dec-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

Edge-Aware Shaders

Peter-Pike Sloan and Peter Shirley NVIDIA

Motivation

Conventional shaders unaware of edges

P

Conventional shaders unaware of edges

P

a

Inspiration PLACEHOLDER - PERMISSIONS

[Deering88] [Reshetov09]

[FXAA10] [Nehab07]

Z N RGB

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]

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);

Algorithm

Splat convex edges

Search GBuffer for edges

Flood Fill (jump flooding)

Splat existing corners

Search for new corners

Update GBuffer

Shade image

Edge Features

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

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;

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]); } }

Line Textures (sparse)

Flood Fill

Jump Flooding

[Rong06]

Flood Fill

Corners

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;

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);

Corner Fixup

Results

Original

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

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

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

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

Backup slides after this…

Line Features

Line textures (sparse set of points)

Flood Fill

Flood Fill