Filtering Approaches for Real-Time Anti-Aliasing

Slides:



Advertisements
Similar presentations
Stupid OpenGL Shader Tricks
Advertisements

Accelerating Real-Time Shading with Reverse Reprojection Caching Diego Nehab 1 Pedro V. Sander 2 Jason Lawrence 3 Natalya Tatarchuk 4 John R. Isidoro 4.
Filtering Approaches for Real-Time Anti-Aliasing
Exploration of advanced lighting and shading techniques
POST-PROCESSING SET09115 Intro Graphics Programming.
Filtering Approaches for Real-Time Anti-Aliasing
An Optimized Soft Shadow Volume Algorithm with Real-Time Performance Ulf Assarsson 1, Michael Dougherty 2, Michael Mounier 2, and Tomas Akenine-Möller.
Filtering Approaches for Real-Time Anti-Aliasing
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Frame Buffer Postprocessing Effects in DOUBLE-S.T.E.A.L (Wreckless)
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
RealityEngine Graphics Kurt Akeley Silicon Graphics Computer Systems.
Filtering Approaches for Real-Time Anti-Aliasing
Image Processing Lecture 4
The Art and Technology Behind Bioshock’s Special Effects
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Hilal Tayara ADVANCED INTELLIGENT ROBOTICS 1 Depth Camera Based Indoor Mobile Robot Localization and Navigation.
David Luebke1/19/99 CS 551/651: Antialiasing David Luebke
Week 7 - Wednesday.  What did we talk about last time?  Transparency  Gamma correction  Started texturing.
Filtering Approaches for Real-Time Anti-Aliasing
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Fast GPU Histogram Analysis for Scene Post- Processing Andy Luedke Halo Development Team Microsoft Game Studios.
Image Indexing and Retrieval using Moment Invariants Imran Ahmad School of Computer Science University of Windsor – Canada.
MSU CSE 803 Stockman Linear Operations Using Masks Masks are patterns used to define the weights used in averaging the neighbors of a pixel to compute.
Aliasing and Anti-Aliasing Copyright Zachary Wartell, University of North Carolina at Charlotte, All Rights Reserved Revision: 10/24/2007 3:38:00 AM ©Zachary.
MSU CSE 803 Linear Operations Using Masks Masks are patterns used to define the weights used in averaging the neighbors of a pixel to compute some result.
Filtering Approaches for Real-Time Anti-Aliasing /
Filtering theory: Battling Aliasing with Antialiasing Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Spring 2012Meetings 5 and 6, 7:20PM-10PM Image Processing with Applications-CSCI567/MATH563/MATH489 Lectures 8, 9, 10,11: Spatial Filtering 8. Linear Filters,
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Image Synthesis Rabie A. Ramadan, PhD 3. 2 Our Problem.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Visual quality techniques.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
1 Rendering Geometry with Relief Textures L.Baboud X.Décoret ARTIS-GRAVIR/IMAG-INRIA.
CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE.
Fast Cascade VSM By Zhang Jian.
Hardware-accelerated Rendering of Antialiased Shadows With Shadow Maps Stefan Brabec and Hans-Peter Seidel Max-Planck-Institut für Informatik Saarbrücken,
03/28/03© 2005 University of Wisconsin NPR Today “Comprehensible Rendering of 3-D Shapes”, Takafumi Saito and Tokiichiro Takahashi, SIGGRAPH 1990 “Painterly.
GEOMETRIC OPERATIONS. Transformations and directions Affine (linear) transformations Translation, rotation and scaling Non linear (Warping transformations)
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
Stencil Routed A-Buffer
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Learning to Detect Faces A Large-Scale Application of Machine Learning (This material is not in the text: for further information see the paper by P.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
1 Dr. Scott Schaefer Antialiasing. 2/70 What is aliasing?
Digital Image Processing CSC331
1 Per-Pixel Opacity Modulation for Feature Enhancement in Volume Rendering Speaker: 吳昱慧 Date:2010/11/16 IEEE TRANSACTIONS ON VISUALIZATION AND COMPUTER.
COMPUTER GRAPHICS CS 482 – FALL 2015 NOVEMBER 10, 2015 VISIBILITY CULLING HIDDEN SURFACES ANTIALIASING HALFTONING.
Non-linear filtering Example: Median filter Replaces pixel value by median value over neighborhood Generates no new gray levels.
Antialiasing. What is alias? Alias - A false signal in telecommunication links from beats between signal frequency and sampling frequency (from dictionary.com)
CS4670 / 5670: Computer Vision Kavita Bala Lec 27: Stereo.
Combining Edges and Points for Interactive High-Quality Rendering
Deferred Lighting.
The Graphics Rendering Pipeline
Computer Vision Lecture 16: Texture II
Static Image Filtering on Commodity Graphics Processors
UMBC Graphics for Games
Lecture 13 Clipping & Scan Conversion
Linear Operations Using Masks
Unreal Engine 短期課程 指導老師: 資訊工程系 胡敏君 老師 教育部資通訊軟體創新人才推升推廣計畫
RADEON™ 9700 Architecture and 3D Performance
Feature descriptors and matching
Presentation transcript:

Filtering Approaches for Real-Time Anti-Aliasing

Filtering Approaches for Real-Time Anti-Aliasing Jimenez’s MLAA & SMAA: Subpixel Morphological Anti- Aliasing Jorge Jimenez Universidad de Zaragoza

Practical Morphological Anti-Aliasing In GPU Pro 2: Advanced Rendering Techniques The Team Jose I. Echevarria Universidad de Zaragoza Belen Masia Universidad de Zaragoza Fernando Navarro Lionhead Studios Diego Gutierrez Universidad de Zaragoza Jorge Jimenez Universidad de Zaragoza

Practical Morphological Anti- Aliasing In GPU Pro 2: Advanced Rendering Techniques SMAA: Subpixel Morphological Anti-Aliasing Technical Report

Key Features Practical Morphological Anti-Aliasing In GPU Pro 2: Advanced Rendering Techniques

Key Features Practical Morphological Anti-Aliasing In GPU Pro 2: Advanced Rendering Techniques

Key Features Practical Morphological Anti-Aliasing In GPU Pro 2: Advanced Rendering Techniques

Key Features Practical Morphological Anti-Aliasing In GPU Pro 2: Advanced Rendering Techniques

Key Features Practical Morphological Anti-Aliasing In GPU Pro 2: Advanced Rendering Techniques

Key Ideas Translate MLAA to use simple textures Use pre-computed textures: ★ Avoid dynamic branching ★ Avoid calculating areas on the fly Leverage bilinear filtering to the limit Share calculations between pixels (pixels share edges!) Mask operations by using the stencil buffer

MLAA High-Level Algorithm

Problems Searching for ends is slow Fetching for crossing edges is costly Revectorization is branchy: 2 4 =16 cases! Area calculation is not cheap Up to 4 lines per pixel! Searchs Crossing Edges

Problems Searching for ends is slow Fetching for crossing edges is costly Revectorization is branchy: 2 4 =16 cases! Area calculation is not cheap Up to 4 lines per pixel!

Problems Searching for ends is slow Fetching for crossing edges is costly Revectorization is branchy: 2 4 =16 cases! Area calculation is not cheap Up to 4 lines per pixel!

Solutions Searching for line ends is slow Fetching for crossing edges is costly ★ Solution: introduce bilinear filtering to post processing antialiasing This allows to fetch multiple values in a single access!

Solutions Calculating the revectorization is not easy nor fast Accurate area calculation is not cheap ★ Solution: avoid branchy code by using a precomputed texture distances crossing edges area

Solutions Up to 4 lines can pass through a pixel ★ Solution: stupid observation; pixels share edges, don’t repeat calculations!

New Problem! We now require three full-screen passes ★ Solution: use the stencil buffer!

Workflow Original ImageEdges textureBlending weights texture Antialiased Image

Workflow Original ImageEdges textureBlending weights texture Antialiased Image 1st

Workflow Original ImageEdges textureBlending weights texture Antialiased Image 1st 2nd

Workflow Original ImageEdges textureBlending weights texture Antialiased Image 1st 2nd 3rd

Edge Detection1 st Pass Color: (ITU-R Recommendation BT.709) –Y' = · R' · G' · B’ Depth: cheaper and more clean edges, but cannot work at all object scales Instance ids/depth + normals: the best if you have this information available 1st

Edge Detection1 st Pass Color: (ITU-R Recommendation BT.709) –Y' = · R' · G' · B’ Depth: cheaper and more clean edges, but cannot work at all object scales Instance ids/depth + normals: the best if you have this information available 1st

Edge Detection1 st Pass Color: (ITU-R Recommendation BT.709) –Y' = · R' · G' · B’ Depth: cheaper and more clean edges, but cannot work at all object scales Instance ids/depth + normals: the best if you have this information available 1st

Edge Detection1 st Pass Color: (ITU-R Recommendation BT.709) –Y' = · R' · G' · B’ Depth: cheaper and more clean edges, but cannot work at all object scales Instance ids/depth + normals: clean, sharp but more expensive 1st

Edge Detection1 st Pass float4 ColorEdgeDetectionPS(float4 position : SV_POSITION, float2 texcoord : TEXCOORD0) : SV_TARGET { float3 weights = float3(0.2126,0.7152, ); /** * Luma calculation requires gamma-corrected colors, and thus 'colorTex' should * be a non-sRGB texture. */ float L = dot(colorTex.SampleLevel(PointSampler, texcoord, 0).rgb, weights); float Lleft = dot(colorTex.SampleLevel(PointSampler, texcoord, 0, -int2(1, 0)).rgb, weights); float Ltop = dot(colorTex.SampleLevel(PointSampler, texcoord, 0, -int2(0, 1)).rgb, weights); float Lright = dot(colorTex.SampleLevel(PointSampler, texcoord, 0, int2(1, 0)).rgb, weights); float Lbottom = dot(colorTex.SampleLevel(PointSampler, texcoord, 0, int2(0, 1)).rgb, weights); float4 delta = abs(L.xxxx - float4(Lleft, Ltop, Lright, Lbottom)); float4 edges = step(threshold.xxxx, delta); if (dot(edges, 1.0) == 0.0) discard; return edges; } Color version: 1st

Edge Detection1 st Pass float4 ColorEdgeDetectionPS(float4 position : SV_POSITION, float2 texcoord : TEXCOORD0) : SV_TARGET { /** * Luma calculation requires gamma-corrected colors, and thus 'colorTex' should * be a non-sRGB texture. */ float4 topLeft = lumaTex.Gather(LinearSampler, texcoord + PIXEL_SIZE * float2(-0.5, -0.5), 0); float4 bottomRight = lumaTex.Gather(LinearSampler, texcoord + PIXEL_SIZE * float2(0.5, 0.5), 0); float L = topLeft.g; float Lleft = topLeft.r; float Ltop = topLeft.b; float Lright = bottomRight.b; float Lbottom = bottomRight.r; float4 delta = abs(L.xxxx - float4(Lleft, Ltop, Lright, Lbottom)); float4 edges = step(threshold.xxxx, delta); if (dot(edges, 1.0) == 0.0) discard; return edges; } Color version: 1st

Blending Weights Calculation2 nd Pass It consists on three parts: ★ Searching for distances d left and d right to the end of current line ★ Fetching crossing edges e left and e right ★ Calculating the coverage a of this pixel, using d and e 2nd

Searching for Distances Done by exploiting bilinear filtering: 2nd

Searching for Distances Done by exploiting bilinear filtering: 2nd

Searching for Distances Done by exploiting bilinear filtering: 2nd

Searching for Distances Done by exploiting bilinear filtering: 2nd

Searching for Distances float SearchXLeft(float2 texcoord) { texcoord -= float2(1.5, 0.0) * PIXEL_SIZE; float e = 0.0; // We offset by 0.5 to sample between edgels, thus fetching two in a row for (int i = 0; i < maxSearchSteps; i++) { e = edgesTex.SampleLevel(LinearSampler, texcoord, 0).g; // We compare with 0.9 to prevent bilinear access precision problems [flatten] if (e < 0.9) break; texcoord -= float2(2.0, 0.0) * PIXEL_SIZE; } // When we exit the loop without founding the end, we want to return // -2 * maxSearchSteps return max(-2.0 * i * e, -2.0 * maxSearchSteps); } Search example code: 2nd

Fetching crossing edges 2nd

Fetching crossing edges Again, done by exploiting bilinear filtering 0.5 2nd

Fetching crossing edges ★ Solution: offset the coordinates! nd

Calculating the coverage We use a pre-computed texture to avoid: ★ Dynamic branching ★ Expensive area calculations 2nd

Calculating the coverage 2nd

Calculating the coverage 2nd

Calculating the coverage 2nd

Calculating the coverage 2nd

Area Texture Advatanges 2nd Symetrical handling of patterns Asymetric revectorization → patterns fine tuning

Blending Weights Calculation2 nd Pass float4 BlendingWeightCalculationPS(float4 position : SV_POSITION, float2 texcoord : TEXCOORD0) : SV_TARGET { float4 weights = 0.0; float2 e = edgesTex.SampleLevel(PointSampler, texcoord, 0).rg; [branch] if (e.g) { // Edge at north // Search distances to the left and to the right: float2 d = float2(SearchXLeft(texcoord), SearchXRight(texcoord)); // Now fetch the crossing edges. Instead of sampling between edgels, we // sample at -0.25, to be able to discern what value has each edgel: float4 coords = mad(float4(d.x, -0.25, d.y + 1.0, -0.25), PIXEL_SIZE.xyxy, texcoord.xyxy); float e1 = edgesTex.SampleLevel(LinearSampler, coords.xy, 0).r; float e2 = edgesTex.SampleLevel(LinearSampler, coords.zw, 0).r; // Ok, we know how this pattern looks like, now it is time for getting // the actual area: weights.rg = Area(abs(d), e1, e2); } Shader code (I): 2nd

Blending Weights Calculation2 nd Pass [branch] if (e.r) { // Edge at west // Search distances to the top and to the bottom: float2 d = float2(SearchYUp(texcoord), SearchYDown(texcoord)); // Now fetch the crossing edges (yet again): float4 coords = mad(float4(-0.25, d.x, -0.25, d.y + 1.0), PIXEL_SIZE.xyxy, texcoord.xyxy); float e1 = edgesTex.SampleLevel(LinearSampler, coords.xy, 0).g; float e2 = edgesTex.SampleLevel(LinearSampler, coords.zw, 0).g; // Get the area for this direction: weights.ba = Area(abs(d), e1, e2); } return weights; } Shader code (II): 2nd

Neighborhood Blending3 rd Pass We blend with the neighborhood using the areas calculated in previous pass 3rd c new = (1 - a) · c old + a · c opp

Neighborhood Blending3 rd Pass We leverage bilinear filtering (yet again): c new = (1 - a) · c old + a · c opp 3rd

Neighborhood Blending3 rd Pass float4 NeighborhoodBlendingPS(float4 position : SV_POSITION, float2 texcoord : TEXCOORD0) : SV_TARGET { // Fetch the blending weights for current pixel: float4 topLeft = blendTex.SampleLevel(PointSampler, texcoord, 0); float bottom = blendTex.SampleLevel(PointSampler, texcoord, 0, int2(0, 1)).g; float right = blendTex.SampleLevel(PointSampler, texcoord, 0, int2(1, 0)).a; float4 a = float4(topLeft.r, bottom, topLeft.b, right); // Up to 4 lines can be crossing a pixel (one in each edge). So, we perform // a weighted average, where the weight of each line is 'a' cubed, which // favors blending and works well in practice. float4 w = a * a * a; Shader code (I): 3rd

Neighborhood Blending3 rd Pass // There is some blending weight with a value greater than 0.0? float sum = dot(w, 1.0); [branch] if (sum > 0.0) { float4 o = a * PIXEL_SIZE.yyxx; float4 color = 0.0; // Add the contributions of the possible 4 lines that can cross this // pixel: color = mad(colorTex.SampleLevel(LinearSampler, texcoord + float2( 0.0, -o.r), 0), w.r, color); color = mad(colorTex.SampleLevel(LinearSampler, texcoord + float2( 0.0, o.g), 0), w.g, color); color = mad(colorTex.SampleLevel(LinearSampler, texcoord + float2(-o.b, 0.0), 0), w.b, color); color = mad(colorTex.SampleLevel(LinearSampler, texcoord + float2( o.a, 0.0), 0), w.a, color); // Normalize the resulting color and we are finished! return color / sum; } else { return colorTex.SampleLevel(LinearSampler, texcoord, 0); } } Shader code (II): 3rd

SRGB and linear blending Blending should be done in linear space 3rd MLAA (Gamma Blend) MSAA 8x

SRGB and linear blending Blending should be done in linear space. 3rd MLAA (Linear Blend) MSAA 8x

Performance on a GeForce GTX 470 if Gather4 is not used Assasin's Creed0,3680,10 Bioshock0,3520,12 Crysis0,3480,12 Dead Space0,3120,12 Devil May Cry 40,2560,05 GTA IV0,2340,01 Modern Warfare 20,2480,02 NFS Shift0,260,04 Split / Second0,2760,04 S.T.A.L.K.E.R.0,290,04 Grand Average0,29440,08 Measured with screen captures

SMAA Subpixel Morphological Antialiasing

Temporal AA Great subpixel features! SMAA: Subpixel Morphological Antialiasing MLAA Great gradrients! MSAA Great subpixel features!

Temporal AA Good subpixel features! SMAA: Subpixel Morphological Antialiasing MLAA Great gradients! MSAA Great subpixel features!

SMAA: Subpixel Morphological Antialiasing MLAAMSAA 2xPost-Resolve MLAA

SMAA: Subpixel Morphological Antialiasing MLAA MSAA 8xPre-Resolve MLAA

SMAA: Subpixel Morphological Antialiasing

Better fallbacks: everything is processed ★ Zones with low contrast are antialiased by multi/supersampling MLAASMAA S2xSSAA 16x

SMAA: Subpixel Morphological Antialiasing Improves pattern handling ★ Diagonals MLAASMAA S2xSSAA 16x

SMAA: Subpixel Morphological Antialiasing Improves pattern handling ★ Sharp geometric features detection (good for text!) InputSMAA 1xMLAA (Insane: 256 patterns!) Extended Area Texture

Accurate searches SMAA: Subpixel Morphological Antialiasing

Accurate searches SMAA: Subpixel Morphological Antialiasing

Take neighborhood lumas into account SMAA: Subpixel Morphological Antialiasing

Take neighborhood lumas into account SMAA: Subpixel Morphological Antialiasing

Take neighborhood lumas into account SMAA: Subpixel Morphological Antialiasing

What’s under the hood ★ The fast and accurate distance searches ★ The local contrast awareness ★ Specific patterns tuning ★ Calculating the four possible lines that can cross a pixel, and smartly average them

SMAA: Subpixel Morphological Antialiasing Modular ★ SMAA 1ximproved pattern handling ★ SMAA T2x1x + temporal supersampling ★ SMAA S2x1x + spatial multisampling ★ SMAA 4x1x + 2x temporal supersampling + 2x spatial multisampling Performance of SMAA 4x (on a GTX 580) ★ 1.06 ★ 0.5 not taking into account 2x render overhead

SMAA: Subpixel Morphological Antialiasing Modular ★ SMAA 1ximproved pattern handling ★ SMAA T2x1x + temporal supersampling ★ SMAA S2x1x + spatial multisampling ★ SMAA 4x1x + 2x temporal supersampling + 2x spatial multisampling Performance of SMAA 4x (on a GTX 580) ★ 1.06 ★ 0.5 not taking into account 2x render overhead

Visit our project pages: SMAA technical paper: Github page: Thanks to: ★ Stephen Hill ★ Jean-Francois St-Amour ★ Naty Hoffman ★ Natasha Tatarchuk ★ Johan Andersson Visit us!