310 likes | 501 Views
Pixels are for Chumps Anti-Aliasing. CSE3AGR 2009 Paul Taylor. What is AA. Anti Aliasing is the process of avoiding Aliasing. http://upload.wikimedia.org/wikipedia/commons/f/fd/Anti-aliased-diamonds.png. I can’t upscale this otherwise PowerPoint does some anti-aliasing of it!.
E N D
Pixels are for ChumpsAnti-Aliasing CSE3AGR 2009 Paul Taylor
What is AA • Anti Aliasing is the process of avoiding Aliasing
http://upload.wikimedia.org/wikipedia/commons/f/fd/Anti-aliased-diamonds.pnghttp://upload.wikimedia.org/wikipedia/commons/f/fd/Anti-aliased-diamonds.png I can’t upscale this otherwise PowerPoint does some anti-aliasing of it!
So what is Aliasing? • An Alias is another name for something. • A person with 3 names would have a real name and 2 aliases • Aliasing is an effect which causes different levels of a signal to become indistinguishable (or aliases of each other) • In this picture a sloped line is aliased into a stairway http://www.gemaga.com/2007/12/28/taking-old-games-into-the-hd-era
How does AA work? • We are stuck with a finite resolution • No more pixels to be found! • Basically we need to modify the way in which the data is represented on our screen to reduce the effect of Aliasing • This is done by blurring the aliased areas of the screen.
Blurring is kind of the wrong word, it’s more like multi-sampling the data. • This is done when up-scaling images a lot as the up-scaled image can have some huge pixels! • We take more than one render of the image at slight (sub-pixel) offsets and try to accumulate the average of each pixel. • Through this process, Solid pixels will remain solid • Pixels on the Verge (Precipice) will mix slightly with their neighbours • The degree they mix is controlled by how close the Verge is to the pixel boundary
A pretty Triangle http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
A pretty Triangle Rendered http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
A pretty Triangle Rendered with AA http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
A pretty Triangle Made Small http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
A pretty Triangle Rendered http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
A pretty Triangle Rendered with AA http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
Antialiasing Storage • The Accumulation Buffer is where we store the image http://www.meko.co.uk/glossaryimages/antialiasing.gif
Accumulation Buffer Storage • glClear(GL_ACCUM_BUFFER_BIT); \\ Clear the buffer glAccum(GL_ACCUM, 1.f / aaPasses); GL_ADD – Adds RGBA to the Accumulation Buffer GL_MULT – Multiplies each RGBA in the Acc buffer by the given Value GL_ACCUM – Adds (ReadBuffer / 2n-1 ) * Value GL_RETURN – Returns the values of the Acc buffer to the display buffer (* 2n-1 ) * value * N = Number of bits per component in selected display buffer
http://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.htmlhttp://nittech.blogspot.com/2007/05/anti-aliasing-filter-and-anisotropic.html
http://www.math.ucsd.edu/~sbuss/CourseWeb/Math155B_2004Winter/FinalProjects/chu_tak_sun/antialiasing.JPGhttp://www.math.ucsd.edu/~sbuss/CourseWeb/Math155B_2004Winter/FinalProjects/chu_tak_sun/antialiasing.JPG • http://www.schorsch.com/kbase/glossary/aliasing.html
What about Textures? • Nearest Neighbour • Bilinear Filtering • Bicubic Filtering • Trilinear • This is Bilinear Filtering done with an interpolation between Mip-Maps • Anisotrpoic (AF) • More complex and Better at retaining detail at extreme angles http://en.wikipedia.org/wiki/File:Image-resample-sample.png
http://en.wikipedia.org/wiki/File:Nearest2DInterpolExample.pnghttp://en.wikipedia.org/wiki/File:Nearest2DInterpolExample.png Nearest Neighbour
http://en.wikipedia.org/wiki/File:BilinearInterpolExample.pnghttp://en.wikipedia.org/wiki/File:BilinearInterpolExample.png Bilinear
http://en.wikipedia.org/wiki/File:BicubicInterpolationExample.pnghttp://en.wikipedia.org/wiki/File:BicubicInterpolationExample.png BiCubic
Trilinear http://en.wikipedia.org/wiki/File:Anisotropic_compare.png
Nice Clean AA • You must alter the ModelView Matrix and the Projection Matrix
Altering the Projection Matrix • Some AA can be done by altering the frustum slightly. It’s not the best approach as the closer the polygon the more effect the frustum has
Advanced AA • Dirty AA • By just moving the Projection Matrix you can get a quick and dirty version of AA running. • The lighting is not affected by moving your Projection Matrix • You WILL create artefacts • They MAY be visible!
Depth of Field • Performing AA with a Focal Point • Much like the first altering the projection matrix, but should still be done in the ModelView Matrix!!!!
Hardware Support ARB_MULTISAMPLE – This does FSAA for you Lookup NeHe OpenGL Lesson 46 - FullscreenAntiAliasing http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46