filtering theory: battling aliasing with antialiasing tomas akenine-möller department of computer...
TRANSCRIPT
Filtering theory:Filtering theory:Battling Aliasing with AntialiasingBattling Aliasing with Antialiasing
Tomas Akenine-Möller
Department of Computer Engineering
Chalmers University of Technology
Tomas Akenine-Mőller © 2003
Why care at all?Why care at all?
Quality!!Example: Final fantasy
– The movie against the game– In a broad way, and for most of the scenes, the
only difference is in the number of samples and the quality of filtering
Tomas Akenine-Mőller © 2003
Computer graphics is aComputer graphics is aSAMPLING & FILTERING process!SAMPLING & FILTERING process!Pixels
Texture
Time
DEMO
Tomas Akenine-Mőller © 2003
Sampling and reconstructionSampling and reconstruction
Sampling: from continuous signal to discrete Reconstruction recovers the original signal Care must be taken to avoid aliasing Nyquist theorem: the sampling frequency should
be at least 2 times the max frequency in the signal Often impossible to know max frequency
(bandlimited signal), or the max frequency is often infinite…
Tomas Akenine-Mőller © 2003
Sampling theoremSampling theorem
Nyquist theorem: the sampling frequency should be at least 2 times the max frequency in the signal
f=1 rpm
1 sample per revolution
A little more than 1 sample/revolution
2 samples per revolution
>2 samples per revolution
Tomas Akenine-Mőller © 2003
Sampling is simple, now turn to: Sampling is simple, now turn to: ReconstructionReconstruction
Assume we have a bandlimited signal (e.g., a texture)
Use filters for reconstruction
Tomas Akenine-Mőller © 2003
Reconstruction with box filter Reconstruction with box filter (nearest neighbor)(nearest neighbor)
Tomas Akenine-Mőller © 2003
Reconstruction with tent filterReconstruction with tent filter
32x32texture
Nearest neighbor Linear
Tomas Akenine-Mőller © 2003
Reconstruction with sinc filterReconstruction with sinc filter
In theory, the ideal filterNot practical (infinite extension, negative)
Tomas Akenine-Mőller © 2003
ResamplingResampling
Enlarging or diminishing signalsAssume samples are at unit-intervals,
i.e., 0,1,2,3,4,…Resample so that they are a apart
– a< 1 gives magnification– a>1 gives minification
Tomas Akenine-Mőller © 2003
ResamplingResamplingMagnificationMagnification
Assume we want to half sample distance
Tomas Akenine-Mőller © 2003
ResamplingResamplingMinificationMinification
Assume we want to double the distance between samples
Gives a blur effect – LP filter
Tomas Akenine-Mőller © 2003
Screen-basedScreen-basedAntialiasingAntialiasing
Hard case: edge has infinite frequencySupersampling: use more than one
sample per pixel
Tomas Akenine-Mőller © 2003
Formula and…Formula and…examples of different schemesexamples of different schemes
wi are the weights in [0,1]c(i,x,y) is the color of sample i inside pixel
),,(),(1
yxiwyxn
ii
cp
Tomas Akenine-Mőller © 2003
Jittered samplingJittered sampling Regular sampling cannot eliminate aliasing – only
reduce it! Why? Because edges represent infinite frequency Jittering replaces aliasing with noise Example:
Tomas Akenine-Mőller © 2003
The A-bufferThe A-bufferMultisampling techniqueMultisampling techniqueTakes >1 samples per pixel, and shares
compuations between samples inside a pixel
Supersampling does not share computations
Examples:– Lighting may be computed once per pixel– Texturing may be computed once per pixel
Strength: aliasing edges and properly handling transparency
Tomas Akenine-Mőller © 2003
The A-buffer --- cont’dThe A-buffer --- cont’dTo deal better with edges:
use a coverage mask per pixelCoverage mask, depth, & color
make up a fragmentDuring rendering fragments are
discarded when possible (depth test)When all polygons have been rendered,
the fragments are merged into a visible color– Allows for sorting transparent surfaces as well– But costs memory
Tomas Akenine-Mőller © 2003
Another multisampling techniqeAnother multisampling techniqeQuincunxQuincunx
Generate 2 samples per pixel at the same time w1=0.5, w2=0.125, w3=0.125, w4=0.125, w5=0.125
(2D tent filter) All samples gives the same effect on the image
(mid pixel = 0.5, corner pixels = 4*0.125=0.5) Is available on NVIDIA GeForce3 and up
Tomas Akenine-Mőller © 2003
Yet another scheme:Yet another scheme:FLIPQUAD multisamplingFLIPQUAD multisampling Recap, RGSS:
– One sample per row and column
Combine good stuff from RGSS and Quincunx
Weights: 0.25 per sample Performs better than Quincunx
DEMO
Tomas Akenine-Mőller © 2003
More on filtering More on filtering theory and practicetheory and practice
Especially important for texturing and filtering of textures
More about this in next lecture