26
David Luebke 06/13/22 Advanced Computer Advanced Computer Graphics Graphics Antialiasing Antialiasing David Luebke David Luebke [email protected] [email protected] http://www.cs.virginia.edu/ http://www.cs.virginia.edu/ ~cs551dl ~cs551dl

Advanced Computer Graphics Antialiasing

  • Upload
    todd

  • View
    63

  • Download
    0

Embed Size (px)

DESCRIPTION

Advanced Computer Graphics Antialiasing. David Luebke [email protected] http://www.cs.virginia.edu/~cs551dl. Administrivia. Assignment 1 sample scenes. Recap. Prefiltering Before sampling the image, use a low-pass filter to eliminate frequencies above the Nyquist limit - PowerPoint PPT Presentation

Citation preview

Page 1: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Advanced Computer GraphicsAdvanced Computer GraphicsAntialiasingAntialiasing

David LuebkeDavid [email protected]@cs.virginia.edu

http://www.cs.virginia.edu/~cs551dlhttp://www.cs.virginia.edu/~cs551dl

Page 2: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

AdministriviaAdministrivia

Assignment 1 sample scenesAssignment 1 sample scenes

Page 3: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

RecapRecap

PrefilteringPrefiltering– Before sampling the image, use a low-Before sampling the image, use a low-

pass filter to eliminate frequencies pass filter to eliminate frequencies above the Nyquist limitabove the Nyquist limit

– This blurs the image… This blurs the image… – But ensures that no high frequencies But ensures that no high frequencies

will be misrepresented as low will be misrepresented as low frequenciesfrequencies

Page 4: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

RecapRecap

SupersamplingSupersampling– Sample image at higher resolution than Sample image at higher resolution than

final image, then “average down”final image, then “average down”– ““Average down” means multiply by low-Average down” means multiply by low-

pass function in frequency domainpass function in frequency domain– Which means convolving by that Which means convolving by that

function’s FT in space domainfunction’s FT in space domain– Which equates to a weighted average of Which equates to a weighted average of

nearby samples at each pixelnearby samples at each pixel

Page 5: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

RecapRecap

Supersampling consSupersampling cons– Doesn’t eliminate aliasing, just shifts the Doesn’t eliminate aliasing, just shifts the

Nyquist limit higherNyquist limit higher Can’t fix some scenes (e.g., checkerboard)Can’t fix some scenes (e.g., checkerboard)

– Badly inflates storage requirementsBadly inflates storage requirements Supersampling prosSupersampling pros

– Relatively easyRelatively easy– Often works all right in practiceOften works all right in practice– Can be added to a standard rendererCan be added to a standard renderer

Page 6: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Antialiasing in the Antialiasing in the Continuous DomainContinuous Domain

Problem with prefiltering:Problem with prefiltering:– Sampling and image generation inextricably Sampling and image generation inextricably

linked in most rendererslinked in most renderers Z-buffer algorithmZ-buffer algorithm Ray tracingRay tracing

– Why?Why? Still, some approaches try to Still, some approaches try to

approximate effect of convolution in the approximate effect of convolution in the continuous domaincontinuous domain

Page 7: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Antialiasing in the Antialiasing in the Continuous DomainContinuous Domain

PixelGrid

Polygons Filter kernel

Page 8: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Antialiasing in the Antialiasing in the Continuous DomainContinuous Domain

The good newsThe good news– Exact polygon coverage of the filter Exact polygon coverage of the filter

kernel can be evaluatedkernel can be evaluated– What does this entail?What does this entail?

ClippingClipping Hidden surface determinationHidden surface determination

Page 9: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Antialiasing in the Antialiasing in the Continuous DomainContinuous Domain

The bad newsThe bad news– Evaluating coverage is very expensiveEvaluating coverage is very expensive– The intensity variation is too complex to The intensity variation is too complex to

integrate over the area of the filterintegrate over the area of the filter Q: Q: Why does intensity make it harder?Why does intensity make it harder? A: Because polygons might not be flat- shadedA: Because polygons might not be flat- shaded Q: Q: How bad a problem is this?How bad a problem is this? A: Intensity varies slowly within a pixel, so A: Intensity varies slowly within a pixel, so

shape changes are more importantshape changes are more important

Page 10: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Catmull’s AlgorithmCatmull’s Algorithm

AB

A1A2

A3

Find fragment Find fragment areasareas

Multiply by Multiply by fragment colorsfragment colors

Sum for final Sum for final pixel colorpixel color

Page 11: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Catmull’s AlgorithmCatmull’s Algorithm

First real attempt to filter in First real attempt to filter in continuous domaincontinuous domain

Very expensive Very expensive – Clipping polygons to fragmentsClipping polygons to fragments– Sorting polygon fragments by depth Sorting polygon fragments by depth

((What’s wrong with this as a hidden What’s wrong with this as a hidden surface algorithm?surface algorithm?))

Equates to box filter (Equates to box filter (Is that good?Is that good?))

Page 12: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

The A-BufferThe A-Buffer

Idea: approximate continuous filtering by subpixel samplingIdea: approximate continuous filtering by subpixel sampling Summing areas now becomes simpleSumming areas now becomes simple

Page 13: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

The A-BufferThe A-Buffer

Advantages: Advantages: – Incorporating into scanline renderer Incorporating into scanline renderer

reduces storage costs dramaticallyreduces storage costs dramatically– Processing per pixel depends only on Processing per pixel depends only on

number of visible fragmentsnumber of visible fragments– Can be implemented efficiently using Can be implemented efficiently using

bitwise logical ops on subpixel masksbitwise logical ops on subpixel masks

Page 14: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

The A-BufferThe A-Buffer

DisadvantagesDisadvantages– Still basically a supersampling Still basically a supersampling

algorithmalgorithm– Not a hardware-friendly algorithmNot a hardware-friendly algorithm

Lists of potentially visible polygons can Lists of potentially visible polygons can grow without limitgrow without limit

Work per-pixel non-deterministicWork per-pixel non-deterministic

Page 15: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

The A-BufferThe A-Buffer

CommentsComments– Book claims this is most common Book claims this is most common

algorithm for high-quality renderingalgorithm for high-quality rendering– I’m not so sure, anymoreI’m not so sure, anymore– Book gives much gory detailBook gives much gory detail– I won’t test you on itI won’t test you on it

Page 16: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Sampling theory tells us that with a Sampling theory tells us that with a regular sampling grid, frequencies regular sampling grid, frequencies higher than the Nyquist limit will aliashigher than the Nyquist limit will alias

Q: What about Q: What about irregularirregular sampling? sampling? A: High frequencies appear as noise, A: High frequencies appear as noise,

not aliasesnot aliases This turns out to bother our visual This turns out to bother our visual

system less!system less!

Page 17: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

An intuitive argument:An intuitive argument:– In stochastic sampling, every region of In stochastic sampling, every region of

the image has a finite probability of the image has a finite probability of being sampledbeing sampled

– Thus small features that fall between Thus small features that fall between uniform sample points tend to be uniform sample points tend to be detected by non-uniform samplesdetected by non-uniform samples

Page 18: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Integrating with different renderers:Integrating with different renderers:– Ray tracing: Ray tracing:

It is just as easy to fire a ray one direction as It is just as easy to fire a ray one direction as anotheranother

– Z-buffer: hard, but possibleZ-buffer: hard, but possible Notable example: Notable example: REYESREYES system ( system (??)) Using Using Image jitteringImage jittering is easier (more later) is easier (more later)

– A-buffer: nopeA-buffer: nope Totally built around square pixel filter and Totally built around square pixel filter and

primitive-to-sample coherenceprimitive-to-sample coherence

Page 19: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Idea: randomizing distribution of Idea: randomizing distribution of samples scatters aliases into noisesamples scatters aliases into noise

Problem: what type of random Problem: what type of random distribution to adopt?distribution to adopt?

Reason: type of randomness used Reason: type of randomness used affects spectral characteristics of affects spectral characteristics of noise into which high frequencies are noise into which high frequencies are convertedconverted

Page 20: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Problem: given a pixel, how to Problem: given a pixel, how to distribute points (samples) within it?distribute points (samples) within it?

Page 21: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

PoissonPoisson distribution: distribution: – Completely randomCompletely random– Add points at random until area is full.Add points at random until area is full.– Uniform distribution: some neighboring Uniform distribution: some neighboring

samples close together, some distantsamples close together, some distant

Page 22: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Poisson discPoisson disc distribution: distribution: – Poisson distribution, with minimum-Poisson distribution, with minimum-

distance constraint between samplesdistance constraint between samples– Add points at random, removing again Add points at random, removing again

if they are too close to any previous if they are too close to any previous pointspoints

– Very even-looking distributionVery even-looking distribution

Page 23: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

JitteredJittered distribution distribution– Start with regular grid of samplesStart with regular grid of samples– Perturb each sample slightly in a Perturb each sample slightly in a

random directionrandom direction– More “clumpy” or granular in More “clumpy” or granular in

appearanceappearance

Page 24: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Spectral characteristics of these Spectral characteristics of these distributions:distributions:– Poisson: completely uniform (Poisson: completely uniform (white noisewhite noise). ).

High and low frequencies equally presentHigh and low frequencies equally present– Poisson disc: Pulse at origin (DC component Poisson disc: Pulse at origin (DC component

of image), surrounded by empty ring (no low of image), surrounded by empty ring (no low frequencies), surrounded by white noisefrequencies), surrounded by white noise

– Jitter: Approximates Poisson disc spectrum, Jitter: Approximates Poisson disc spectrum, but with a smaller empty disc.but with a smaller empty disc.

Page 25: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23

Stochastic SamplingStochastic Sampling

Watt & Watt, p. 134Watt & Watt, p. 134

Page 26: Advanced Computer Graphics Antialiasing

David Luebke 04/22/23