Presentation is loading. Please wait.

Presentation is loading. Please wait.

Antialiasing CAP4730: Computational Structures in Computer Graphics.

Similar presentations


Presentation on theme: "Antialiasing CAP4730: Computational Structures in Computer Graphics."— Presentation transcript:

1 Antialiasing CAP4730: Computational Structures in Computer Graphics

2 Outline n What is antialiasing? n How do we see the affects of antialiasing? n What can we do about it? n Math behind antialiasing n Antialiasing in modern day graphics cards n Advanced stuff on AA

3 Let’s Revisit a pixel n A pixel is which of these things (theoretically)? –point –circle/disk –square/rectangle –has area –has a location –sample

4 White Picket Fence n What happens when we back away? –1: with a camera /eye –2: with OpenGL –3: with ray- tracing n What’s the cause of the difference? n A pixel could be too BIG!

5 A New Thought about Images n Images are really a 2D function n Here’s an image plotted as a height field n Now we store this image as an “array” of points. What does that mean?

6 We Sample the Image Function n Here is the sampling function. It is called the delta function

7 Thus we are “sampling” a continuous image function n We call these samples at this regular grid of points, pixels. n Pixels are a sampling of the function that describes the image. n We store these pixels into memory as an array of colors. n How densely should we sample? n What would govern this?

8 Samples n Continuous - function with values at any input. Most things in the world. Ex. sine and cosine n Discrete - function with values only at specific inputs. Computers are discrete. n What is a 1D example? a 2D example? n To convert from a continuous function to a discrete one, we discretize or sample n To convert form a continuous variable to a discrete one, we quantize n When we render an image (which is a continuous function, why?), we sample and quantize

9 Let’s get grounded with an example

10 Similar examples? n High frequency information, low sampling. –Examples? n Train comes every 2 hours. You go every 2:15. How long do you wait? n Audio. 44/48 Khz signal. 11 Khz Sample –What is the result? –Images n 8 MP vs 4 MP vs 640 x 480

11 A quick footnote into frequency analysis n A way to understand the sampling question is to convert the function into a different “space” or domain. n We use the Fourier Transform to convert the function (in our case the image) into the frequency domain.

12 What does sampling mean? n What happens if we don’t sample enough?

13 Aliasing n If we sample at too low a rate, the high frequencies in the image appear as lower frequencies. n How do we fix it? n Increase sampling n Remove high frequencies

14 Aliasing Manifestations n Pixels approximating a signal n Pixels aren’t small enough and MISS information

15 Aliasing n Aliasing manifests itself as “jaggies” in graphics. Thus we don’t have enough pixels to accurately represent the underlying function. Check out what happens when we increase our sampling.

16 Aliasing n Aliasing also manifests itself in repeating patterns n Car wheels n Big picture: –Continuous signal –Discrete sampling (pixels, frames, etc.) –Aliasing represents misrepresentation (hence the name) involved n How do we fix it?

17 Fixing Aliasing n Increase Resolution n What’s wrong with this approach? n Filtering is another possibility –We want to remove the high frequency areas –How would we do that? n Let’s re-examine what a pixel is in reality.

18 Pixels are points n But when we display the points, what happens? n Each pixel is actually a “blob” on the CRT. This blob has energy that falls off close to a Gaussian. n Thus the CRT has a built in “blurring” system. Think about how this works with resolution of your monitor.

19 (0,0) (4,2) (4,0) 2 2 1 10 0 34 Let’s recall

20 Point Sampling n Thus for each pixel, we are “sampling” a specific point. In the frequency domain we get: n To convert from frequency to spatial domains, we do an integration. n To get around point sampling we should come up with another sampling technique

21 BiLinear Sampling n What we will do is use a bilinear filter. n This reduces the high frequencies (which cause aliasing) n Interpolate between samples.

22 BiLinear Sampling

23 What are we doing? (0,0) (4,2) (4,0) 2 2 1 10 0 34

24 Blurring n Remember, blurring removes high frequencies, which cause aliasing. n We can do other filtering besides bilinear, and we would like to to avoid artifacts. n http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture 11/Slide27.html n How would we blur using our traditional graphics pipeline?

25 Two ways to Antialias n Increase resolution (increase sampling) –or n Supersampling

26 Increase Rendering Resolution n Render the image at a higher resolution and downsample. n Really, you are letting your eye do some filtering for you.

27 Supersampling n For each pixel, we would like to figure out what “percentage” is covered. (0,0) (4,0) 2 1 10 0 34

28 Supersampling n For each pixel, sample at multiple points. –What is the distribution of these points? n Uniform Grid n Random n Psuedo-random n How many? n How far away from center should I try? –How would I program this?

29 Line Antialiasing

30 Full Screen Antialiasing n Another way to do the supersampling is to do full screen antialiasing n We want to draw the image with several camera jitter positions and average the answers n Can you see why this would give us near similar answers? n That’s what they mean by 2-tap, 4-tap antialiasing n What does this require? –Memory-wise –Computation-wise n How would you implement this?

31 Full Screen Antialiasing Example (Exaggerated)

32 Antialiasing in OpenGL n To do this in OpenGL, use the Accumulation buffer –glAccum(GL_ACCUM, FRAMES_TO_AVERAGE); –glAccum(GL_LOAD, 1); –glAccum(GL_RETURN); n VERY SLOW! What does this mean memory wise? n Other approahces: graphics cards, quincux

33 Aliasing Examples n From: http://www.os2ezin e.com/v1n7/colorwk s.html

34

35 Hardware Antialiasing n Don’t just generate 1 answer to write to a pixel n nVidia Quincunx AA (2000 – GeForce3) n Result

36 Results from http://www.techreport.com/etc/2005q3/sl i-aa/index.x?pg=4

37 Difference

38 OpenGL Antialiasing n Points and Lines –glEnable(GL_POINT_SMOOTH); –glEnable(GL_LINE_SMOOTH); n Triangles –glEnable(GL_POLYGON_SMOOTH); n Provides blend alpha at edges of a triangle


Download ppt "Antialiasing CAP4730: Computational Structures in Computer Graphics."

Similar presentations


Ads by Google