Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE.

Similar presentations


Presentation on theme: "CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE."— Presentation transcript:

1 CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE

2 INTRODUCTION We’re trying to render lines, curves, triangles, or parametric surfaces  continuous (in a mathematical sense) However, we are rendering these objects into a grid of pixels  discrete positions So, our rendering result is from sampling the 2D/3D scene Similar problem with getting values from textures, as we saw earlier

3 ALIASING: INTUITIVE So far, a pixel would either be “filled” or “not filled” E.g., Bresenham, where we choose one pixel or the other along the line path Lines and edges of polygons have jagged appearance  problem known as aliasing “Jaggies”  jagged edges/lines “Crawlies”  when jagged edges/lines are animated To try to alleviate this, we will use antialiasing approaches

4 SAMPLING AND FILTERING THEORY

5 Sampling = getting discrete values from a continuous signal Analogue signal  digital values Aliasing can occur whenever sampling is done Filtering = the process of reconstructing the original signal from samples For simplicity, we’ll focus on 1D uniform sampling

6 HOW OFTEN SHOULD YOU SAMPLE? Aliasing occurs when sampling at too low a frequency Nyquist rate = twice the maximum frequency of the signal Should sample at MORE than Nyquist rate to ensure you can correctly reconstruct the signal from samples Maximum frequency  implies that signal is bandlimited (meaning that there are no frequencies in the signal above a certain value) Unfortunately, 3D scenes are normally NEVER bandlimited: Polygon edges, shadow boundaries, etc. produce discontinuous changes in signal  frequencies essentially infinite  Some objects small enough to be missed entirely

7 ALIASING CAUSED BY POOR SAMPLING We can see an example of aliasing caused by poor sampling if we look at a spinning wheel  temporal aliasing Original signal Too few samples  looks like it’s rotating backwards! Exactly two samples per revolution (Nyquist limit)  can’t tell which way it’s rotating More than two samples per revolution  looks correct

8 ALIASING CAUSED BY POOR SAMPLING Less than Nyquist rate Exactly Nyquist rate

9 RECONSTRUCTION AND FILTERING Use a filter to reconstruct original signal from bandlimited sampled signal Area of filter should equal one  keeps signal same size Some different kinds of filters: Box filter = nearest neighbor Simple (often used in graphics because of this) Worst filter in terms of quality  makes noncontinuous staircase Tent filter (triangle filter) = linear interpolation of neighboring sample points Reconstruction is at least continuous Sudden slope changes at points Ideal lowpass filter = removes high frequencies (blurs output) Gives perfect reconstruction (if using sinc(f*x), where f = frequency of samples) Filter is infinite on either side (and sometimes negative)  rarely used in practice Gaussian filter Good balance of quality and simplicity

10 EXAMPLES OF FILTERS Box filter Tent filter sinc() filter

11 RECONSTRUCTION WITH BOX FILTER

12 RECONSTRUCTION WITH TENT FILTER

13 RECONSTRUCTION WITH SINC() FILTER

14 RESAMPLING Filtering gives you a continuous signal  cannot render that in computer graphics HOWEVER, we can resample reconstructed signal to a new size Resampling = used to magnify or minimize a sampled signal Example: original sample points 1 unit apart; want to resample A units apart: Upsampling  A < 1  more samples (magnification) Downsampling  A > 1  fewer samples (minification)

15 RESAMPLING: UPSAMPLING Upsampling = magnification Resample reconstructed signal  straightforward Original samples and reconstructed signal Resampled signal  magnification

16 RESAMPLING: DOWNSAMPLING Downsampling = minification Frequency of original signal too high if using sinc() as recommended before Should use sinc(x/A) to reconstruct signal from samples  ensures more high frequencies removed  then resample Original samples and reconstructed signal with sinc(x) Reconstructed signal with sinc(x/A) followed by resampling  minification

17 ANTIALIASING APPROACHES

18 INTRODUCTION There are many different ways to perform antialiasing: Lines Textures (covered this ) Screen output The antialiasing approaches we will cover here are all screen-based solutions: Performed on output samples of pipeline Do NOT need any knowledge of objects being rendered

19 GENERAL STRATEGY For each screen grid cell, instead of just grabbing one sample, we will: Use more samples per screen grid cell Blend values together in some fashion General strategy of screen-based antialiasing: Use sampling pattern Weight and sum samples to produce pixel color n = # of samples per pixel c(i,x,y) = sample color  samples locations MAY NOT BE THE SAME for each grid cell w i = weight

20 SAMPLING PATTERNS

21 SUPERSAMPLING APPROCHES Supersampling (or oversampling) approach = computes more than one full sample per pixel Two supersampling approaches: Full-Scene Antialiasing (FSAA) Accumulation Buffer

22 FULL-SCENE ANTIALIASING (FSAA) Full-Scene Antialiasing (FSAA) Renders scene at a higher resolution  then averages neighboring samples to create an image Example: original 1000 x 800  render 2000 x 1600 and sample 2x2 area Advantages: Conceptually simple Disadvantages: Costly  rendering MUCH larger image Partial solution: sometimes only double one axis and sample 2x1 or 1x2 Fixed sampling pattern

23 ACCUMULATION BUFFER Accumulation buffer Uses separate buffer  same size, higher bit depth Render, say, 4 times, shifting each image over by half a pixel in each direction  average results Can also be used for motion blur, depth of field, etc. Advantages: Can have arbitrary sample pattern  each render pass independent (can shift over as we please) Disadvantages: Costly  have to re-render scene 4 times and copy results to screen

24 MULTISAMPLING APPROACHES Problem with supersampling  each sample has to go through entire pipeline (separate shaders, depths, locations, etc.)  expensive Multisampling approaches Take more than one sample per pixel in single pass Share some computation among passes Examples of multisampling approaches: Multisample antialiasing (MSAA) Coverage sampling antialiasing (CSAA) A-Buffer

25 MULTISAMPLE ANTIALIASING (MSAA) Multisample antialiasing (MSAA) Saves time by computing fewer shading samples per fragment Example: might have 4 (x,y) sample locations (each with their own color and depth)  shade only computed once per fragment If fragment covers all samples  shading sample at center of pixel If fragment covers some of samples  shading sample can be shifted  centroid sampling or centroid interpolation Done automatically by GPU if enabled, but can return incorrect values 2x MSAA Green  shading sample Red  other samples 4x MSAA 6x MSAA (ATI) 8x MSAA (NVIDIA)

26 COVERAGE SAMPLING ANTIALIASING (CSAA) Problem with MSAA  mostly unnecessary to store separate color and depth for other samples Coverage sampling antialiasing (CSAA) Just stores coverage of fragment at a higher sampling rate Each subpixel  stores index of fragment associated with it Table with limited number of entries (4 to 8) holds colors and z-depths

27 A-BUFFER A-Buffer Similar to CSAA  both separate coverage from depth/color storage Commonly used in non-realtime rendering Coverage mask generated for each screen grid cell the polygon covers / partially covers Once all polygons sent to A-Buffer  determine percentage of coverage for each fragment  multiply by fragment’s color Advantages: lower storage requirements (especially compared to FSAA) Disadvantages: no upper limit on number of semi-transparent fragments Coverage mask: 0000 0111 1111 0111

28 RANDOM SAMPLING Stochastic sampling = random sampling to make sure we don’t miss something really small Example of jittering below

29 http://img.neoseeker.com/mgv/525490/490/100/batman_aa.jpg

30 CONCLUSION Nothing in life is perfect, especially not antialiasing That said, MSAA and CSAA offer reasonable tradeoffs between speed and quality


Download ppt "CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE."

Similar presentations


Ads by Google