lecture06.ppt

Download Report

Transcript lecture06.ppt

CS 551/651:
Advanced Computer Graphics
Antialiasing Continued:
Prefiltering and Supersampling
David Luebke
1
7/27/2016
Recap:
The Sampling Theorem

The sampling theorem:
A continuous bandlimited function can be completely
represented by a set of equally spaced samples, if the
samples occur at more than twice the frequency of the
highest frequency component of the function
To capture a function with maximum
frequency F, sample it at frequency N = 2F.
 N is called the Nyquist limit.

David Luebke
2
7/27/2016
Recap: Fourier Theory
Can decompose any signal I(x) into a spectrum
of sine waves F(u)
 F(u) is complex; we represent it with:
|F(u)| = [Real(u)2 + Imag(u)2]1/2
Ø(u) = tan-1[Real(u)/Imag(u)]
 These are called the amplitude and phase
spectra

 Back
David Luebke
to transparencies…
3
7/27/2016
Recap: Aliasing
Sampling a function
= multiplying I(x) by sampling fn Sx
= convolving F(u) by sampling fn S1/x
= copying F(u) at regular intervals
 If the copies of F(u) overlap, high frequencies
“fold over”, appearing as lower frequencies
 This is known as aliasing

David Luebke
4
7/27/2016
Prefiltering

Eliminate high frequencies before sampling
(Foley & van Dam p. 630)




Convert I(x) to F(u)
Apply a low-pass filter (e.g., multiply F(u) by a
box function)
Then sample. Result: no aliasing!
So what’s the problem?
David Luebke
5
7/27/2016
Prefiltering

Eliminate high frequencies before sampling
(Foley & van Dam p. 630)




Convert I(x) to F(u)
Apply a low-pass filter (e.g., multiply F(u) by a
box function)
Then sample. Result: no aliasing!
Problem: most rendering algorithms generate
sampled function directly

e.g., Z-buffer, ray tracing
David Luebke
6
7/27/2016
Supersampling

The simplest way to reduce aliasing artifacts is
supersampling



Increase the resolution of the samples
Average the results down
Sometimes called postfiltering



Create virtual image at higher resolution than the
final image
Apply a low-pass filter
Resample filtered image
David Luebke
7
7/27/2016
Supersampling:
Limitations
Q: What practical consideration hampers
supersampling?
 A: Storage goes up quadratically
 Q: What theoretical problem does
supersampling suffer?
 A: Doesn’t eliminate aliasing!
Supersampling simply shifts the Nyquist limit
higher

David Luebke
8
7/27/2016
Supersampling:
Worst Case
Q: Give a simple scene containing infinite
frequencies
 A: A checkered ground plane receeding into
infinity
 Show Watt & Watt, Figure 4.9

David Luebke
9
7/27/2016
Supersampling
Despite these limitations, people still use
supersampling (why?)
 So how can we best perform it?

David Luebke
10
7/27/2016
Supersampling

The process:



Create virtual image at higher resolution than the
final image
Apply a low-pass filter
Resample filtered image
David Luebke
11
7/27/2016
Supersampling

Create virtual image at higher resolution than
the final image

This is easy
David Luebke
12
7/27/2016
Supersampling

Apply a low-pass filter



Convert to frequency domain
Multiply by a box function
Expensive! Can we simplify this?



Recall: multiplication in frequency equals
convolution in space, so…
Just convolve initial sampled image with the FT of
a box function
Isn’t this a lot of work?
David Luebke
13
7/27/2016
Supersampling:
Digital Convolution

In practice, we combine steps 2 & 3:




Create virtual image at higher resolution than the
final image
Apply a low-pass filter
Resample filtered image
Idea: only create filtered image at new sample
points

I.e., only convolve filter with image at new points
David Luebke
14
7/27/2016
Supersampling:
Digital Convolution
Q: What does convolving a filter with an
image entail at each sample point?
 A: Multiplying and summing values
 Example (also F&vD p 642):

David Luebke
15

=
1 2 1
2 4 2
1 2 1
…
1 2 1
2 4 2
1 2 1
=
1 2 1
2 4 2
1 2 1
7/27/2016
Supersampling
Q: What filter should we use in space to effect
multiplying by a box function in frequency?
 A: The sinc function (sin(x) / x)
 Q: Why is this hard?



Sinc function has infinite support
Sinc function has negative lobes
David Luebke
16
7/27/2016
Supersampling

Common filters:




Truncated sinc
Box
Triangle
Guassian
What do the frequency spectra of each of these
filters look like?
 A: see F&vD, p. 634-635

David Luebke
17
7/27/2016
Supersampling

Typical supersampling algorithm:


Compute multiple samples per pixel
Combine sample values for pixel’s value using
simple average
Q: What filter does this equate to?
 A: Box filter -- one of the worst!
 Q: What’s wrong with box filters?



Passes infinitely high frequencies
Attenuates desired frequencies
David Luebke
18
7/27/2016
Supersampling
In Practice
Sinc function: ideal but impractical
 One approximation: sinc2 (=what?)
 Another: Guassian falloff
 Q: How wide (what res) should filter be?
 A: As wide as possible (duh)
 In practice: 3x3, 5x5, at most 7x7

David Luebke
19
7/27/2016
Supersampling:
Summary





Supersampling improves aliasing artifacts by shifting
the Nyquist limit
It works by calculating a high-res image and filtering
down to final res
“Filtering down” means simultaneous convolution
and resampling
This equates to a weighted average
Wider filterbetter resultsmore work
David Luebke
20
7/27/2016
Antialiasing:
Coming Up

Stochastic supersampling



Fundamentally the same idea
Works better in practice
A-buffer

Back to the prefiltering idea
David Luebke
21
7/27/2016
Recap

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
22
7/27/2016
Recap

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
23
7/27/2016
Recap

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
24
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
25
7/27/2016
Antialiasing in the
Continuous Domain
Pixel
Grid
Filter kernel
Polygons
David Luebke
26
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
David Luebke
surface determination
27
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
28
7/27/2016
Catmull’s Algorithm



Find fragment
areas
Multiply by
fragment colors
Sum for final
pixel color
A2
A1
AB
David Luebke
A3
29
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
30
7/27/2016
The A-Buffer
Idea: approximate continuous filtering by
subpixel sampling
 Summing areas now becomes simple

David Luebke
31
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
32
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
33
7/27/2016
The A-Buffer

Comments




Watt & Watt claims this is most common algorithm
for high-quality rendering
I’m not so sure, anymore
They give much gory detail
I won’t test you on it
David Luebke
34
7/27/2016
The End
David Luebke
35
7/27/2016