Filtering theory Battling Aliasing with Antialiasing Tomas AkenineMller
Filtering theory: Battling Aliasing with Antialiasing Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology
Why care at all? Quality!! l Example: Final fantasy l – – 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 a SAMPLING & FILTERING process! l Pixels DEMO l Texture l Time Tomas Akenine-Mőller © 2003
Sampling and reconstruction l l l 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 theorem l 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: Reconstruction Assume we have a bandlimited signal (e. g. , a texture) l Use filters for reconstruction l Tomas Akenine-Mőller © 2003
Reconstruction with box filter (nearest neighbor) Tomas Akenine-Mőller © 2003
Reconstruction with tent filter Nearest neighbor Linear 32 x 32 texture Tomas Akenine-Mőller © 2003
Reconstruction with sinc filter In theory, the ideal filter l Not practical (infinite extension, negative) l Tomas Akenine-Mőller © 2003
Resampling Enlarging or diminishing signals l Assume samples are at unit-intervals, i. e. , 0, 1, 2, 3, 4, … l Resample so that they are a apart l – – a< 1 gives magnification a>1 gives minification Tomas Akenine-Mőller © 2003
Resampling Magnification l Assume we want to half sample distance Tomas Akenine-Mőller © 2003
Resampling Minification l Assume we want to double the distance between samples l Gives a blur effect – LP filter Tomas Akenine-Mőller © 2003
Screen-based Antialiasing Hard case: edge has infinite frequency l Supersampling: use more than one sample per pixel l Tomas Akenine-Mőller © 2003
Formula and… examples of different schemes wi are the weights in [0, 1] l c(i, x, y) is the color of sample i inside pixel l Tomas Akenine-Mőller © 2003
Jittered sampling l l l 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-buffer Multisampling technique Takes >1 samples per pixel, and shares compuations between samples inside a pixel l Supersampling does not share computations l Examples: l – – l 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’d To deal better with edges: use a coverage mask per pixel l Coverage mask, depth, & color make up a fragment l During rendering fragments are discarded when possible (depth test) l When all polygons have been rendered, the fragments are merged into a visible color l – – Allows for sorting transparent surfaces as well But costs memory Tomas Akenine-Mőller © 2003
Another multisampling techniqe Quincunx l l Generate 2 samples per pixel at the same time w 1=0. 5, w 2=0. 125, w 3=0. 125, w 4=0. 125, w 5=0. 125 (2 D 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 Ge. Force 3 and up Tomas Akenine-Mőller © 2003
Yet another scheme: FLIPQUAD multisampling l Recap, RGSS: – One sample per row and column l Combine good stuff from RGSS and Quincunx l Weights: 0. 25 per sample Performs better than Quincunx l DEMO Tomas Akenine-Mőller © 2003
More on filtering theory and practice Especially important for texturing and filtering of textures l More about this in next lecture l Tomas Akenine-Mőller © 2003
- Slides: 20