Transcript 37

Aliasing & Antialiasing
David Luebke
1
7/27/2016
Summary So Far
● Prefiltering
■ Before sampling the image, use a low-pass filter to
eliminate frequencies above the Nyquist limit
■ This blurs the image…
■ But ensures that no high frequencies will be misrepresented
as low frequencies
David Luebke
2
7/27/2016
Summary So Far
● Supersampling
■ Sample image at higher resolution than final image, then
“average down”
■ “Average down” means multiply by low-pass function in
frequency domain
■ Which means convolving by that function’s FT in space
domain
■ Which equates to a weighted average of nearby samples at
each pixel
David Luebke
3
7/27/2016
Summary So Far
● Supersampling cons
■ Doesn’t eliminate aliasing, just shifts the Nyquist limit
higher
○ Can’t fix some scenes (e.g., checkerboard)
■ Badly inflates storage requirements
● Supersampling pros
■ Relatively easy
■ Often works all right in practice
■ Can be added to a standard renderer
David Luebke
4
7/27/2016
Antialiasing in the
Continuous Domain
● Problem with prefiltering:
■ Sampling and image generation inextricably linked in most
renderers
○ Z-buffer algorithm
○ Ray tracing
■ Why?
● Still, some approaches try to approximate effect of
convolution in the continuous domain
David Luebke
5
7/27/2016
Antialiasing in the
Continuous Domain
Pixel
Grid
Filter kernel
Polygons
David Luebke
6
7/27/2016
Antialiasing in the
Continuous Domain
● The good news
■ Exact polygon coverage of the filter kernel can be
evaluated
■ What does this entail?
○ Clipping
○ Hidden surface determination
David Luebke
7
7/27/2016
Antialiasing in the
Continuous Domain
● The bad news
■ Evaluating coverage is very expensive
■ The intensity variation is too complex to integrate over the
area of the filter
○ Q: Why does intensity make it harder?
○ A: Because polygons might not be flat- shaded
○ Q: How bad a problem is this?
○ A: Intensity varies slowly within a pixel, so shape changes are more
important
David Luebke
8
7/27/2016
Catmull’s Algorithm
● Find fragment areas
A2
A1
● Multiply by fragment
colors
● Sum for final pixel
color
AB
David Luebke
A3
9
7/27/2016
Catmull’s Algorithm
● First real attempt to filter in continuous domain
● Very expensive
■ Clipping polygons to fragments
■ Sorting polygon fragments by depth (What’s wrong with
this as a hidden surface algorithm?)
● Equates to box filter (Is that good?)
David Luebke
10
7/27/2016
The A-Buffer
● Idea: approximate continuous filtering by
subpixel sampling
● Summing areas now becomes simple
David Luebke
11
7/27/2016
The A-Buffer
● Advantages:
■ Incorporating into scanline renderer reduces storage costs
dramatically
■ Processing per pixel depends only on number of visible
fragments
■ Can be implemented efficiently using bitwise logical ops
on subpixel masks
David Luebke
12
7/27/2016
The A-Buffer
● Disadvantages
■ Still basically a supersampling algorithm
■ Not a hardware-friendly algorithm
○ Lists of potentially visible polygons can
grow without limit
○ Work per-pixel non-deterministic
David Luebke
13
7/27/2016
Recap:
Antialiasing Strategies
● Supersampling: sample at higher resolution, then
filter down
■ Pros:
○ Conceptually simple
○ Easy to retrofit existing renderers
○ Works well most of the time
■ Cons:
○ High storage costs
○ Doesn’t eliminate aliasing, just shifts Nyquist limit upwards
David Luebke
14
7/27/2016
Recap:
Antialiasing Strategies
● A-Buffer: approximate prefiltering of continuous
signal by sampling
■ Pros:
○ Integrating with scan-line renderer keeps storage costs low
○ Can be efficiently implemented with clever bitwise operations
■ Cons:
○ Still basically a supersampling approach
○ Doesn’t integrate with ray-tracing
David Luebke
15
7/27/2016
Stochastic Sampling
● Sampling theory tells us that with a regular sampling
grid, frequencies higher than the Nyquist limit will
alias
● Q: What about irregular sampling?
● A: High frequencies appear as noise, not aliases
● This turns out to bother our visual system less!
David Luebke
16
7/27/2016
Stochastic Sampling
● An intuitive argument:
■ In stochastic sampling, every region of the image has a
finite probability of being sampled
■ Thus small features that fall between uniform sample
points tend to be detected by non-uniform samples
David Luebke
17
7/27/2016
Stochastic Sampling
● Integrating with different renderers:
■ Ray tracing:
○ It is just as easy to fire a ray one direction as another
■ Z-buffer: hard, but possible
○ Notable example: REYES system (?)
○ Using image jittering is easier (more later)
■ A-buffer: nope
○ Totally built around square pixel filter and primitive-to-sample
coherence
David Luebke
18
7/27/2016
Stochastic Sampling
● Idea: randomizing distribution of samples scatters
aliases into noise
● Problem: what type of random distribution
to adopt?
● Reason: type of randomness used affects spectral
characteristics of noise into which high frequencies
are converted
David Luebke
19
7/27/2016
Stochastic Sampling
● Problem: given a pixel, how to distribute points
(samples) within it?
David Luebke
20
7/27/2016
Stochastic Sampling
● Poisson distribution:
■ Completely random
■ Add points at random until area is full.
■ Uniform distribution: some neighboring samples close
together, some distant
David Luebke
21
7/27/2016
Stochastic Sampling
● Poisson disc distribution:
■ Poisson distribution, with minimum-distance constraint
between samples
■ Add points at random, removing again if they are too close
to any previous points
■ Very even-looking distribution
David Luebke
22
7/27/2016
Stochastic Sampling
● Jittered distribution
■ Start with regular grid of samples
■ Perturb each sample slightly in a random direction
■ More “clumpy” or granular in appearance
David Luebke
23
7/27/2016
Stochastic Sampling
● Spectral characteristics of these distributions:
■ Poisson: completely uniform (white noise). High and low frequencies
equally present
■ Poisson disc: Pulse at origin (DC component of image), surrounded by
empty ring (no low frequencies), surrounded by white noise
■ Jitter: Approximates Poisson disc spectrum, but with a smaller empty
disc.
David Luebke
24
7/27/2016
Stochastic Sampling
● Watt & Watt, p. 134
● See Foley & van Dam, p 644-645
David Luebke
25
7/27/2016
Nonuniform Supersampling
● We’ve discussed two nonuniform sampling
approaches
■ Adaptive supersampling:
○ Sample (say) once per pixel, then supersample if intensity changes
a lot
■ Stochastic supersampling:
○ Use multiple samples per pixel, but not on a uniform grid
● Can we filter nonuniform supersampled images?
David Luebke
26
7/27/2016
Nonuniform Supersampling
● Recall: convolution I’ of filter h with image function
I is given by:
I’(x,y) = 
 I(i, j) h(x-i, y-j)
● Can we use this equation for nonuniform sampling?
● Implicit in this equation is a normalizing factor: we
assume the filter weights sum to unity
David Luebke
27
7/27/2016
Nonuniform Supersampling
Pixel
David Luebke
28
7/27/2016
Nonuniform Supersampling
Sampling Grid
David Luebke
29
7/27/2016
Nonuniform Supersampling
Polygon
David Luebke
30
7/27/2016
Nonuniform Supersampling
Adaptive Sampling
David Luebke
31
7/27/2016
Nonuniform Supersampling
● Problem:
■ Many more purple samples than
white samples
■ But final pixel actually more white
than purple!
■ Simple filtering will not handle this
correctly
Final Samples
David Luebke
32
7/27/2016
Nonuniform Supersampling
● Approximate answer: weighted average filter
■ Divide total value of samples X filter
by total value of filter at sample points:
  I(i, j) h(x-i, y-j)
I’(x,y) =   h(x-i, y-j)
David Luebke
33
7/27/2016
Nonuniform Supersampling
● Correct answer: multistage filtering
■ Use weighted-average filters in cascade, sequentially
applying filters with lower and lower cutoff frequencies
David Luebke
34
7/27/2016
Nonuniform Supersampling
● Real-world answer: ignore the problem
■ Keep random components small compared to filter width
■ Use standard supersampling filter
■ Cook ‘87 (REYES) uses 4x4 jittered supersampling
David Luebke
35
7/27/2016
Antialiasing and
Texture Mapping
● We may want to apply antialiasing techniques to the
texture mapping process separately from the rest of
the rendering process
● Why?
David Luebke
36
7/27/2016
Antialiasing and
Texture Mapping
● Texture mapping is uniquely harder
■ Coherent textures present pathological artifacts
■ Correct filter shape changes
● Texture mapping is uniquely easier
■ Textures are known ahead of time
■ They can thus be prefiltered
David Luebke
37
7/27/2016