Lecture15 anti aliasing

8,532 views

Published on

helpful for assignment

Published in: Technology, Art & Photos
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,532
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
Downloads
523
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Lecture15 anti aliasing

  1. 1. CS 455 – Computer Graphics Antialiasing
  2. 2. Aliasing <ul><li>Aliasing: a high-frequency signal masquerading as a low frequency </li></ul><ul><ul><li>Caused by insufficient sampling (sampling interval too large) </li></ul></ul>Sampling Interval Actual (high-frequency) signal Sampled (aliased) signal
  3. 3. <ul><li>Strobe light on dripping water: Temporal aliasing </li></ul><ul><li>Spokes on a rotating wheel: Temporal aliasing </li></ul><ul><li>Moir é patterns: Spatial aliasing </li></ul>Examples of Aliasing
  4. 4. Aliasing and Line Drawing <ul><li>We draw lines by sampling at intervals of one pixel and drawing the closest pixels </li></ul>Sampling Interval Sampling Interval <ul><li>Results in stair-stepping (i.e., the dreaded “jaggies”) </li></ul>
  5. 5. Antialiasing Lines <ul><li>Idea: </li></ul><ul><ul><li>Make line “fatter” </li></ul></ul><ul><ul><li>Fade line out (removes high frequencies) </li></ul></ul><ul><ul><li>Now sample the line </li></ul></ul>
  6. 6. Antialiasing Lines <ul><li>Solution 1 – Unweighted Area Sampling: </li></ul><ul><ul><li>Treat line as a single-pixel wide rectangle </li></ul></ul><ul><ul><li>Color pixels according to the percentage of each pixel that is “covered” by the rectangle </li></ul></ul>
  7. 7. Solution 1: Unweighted Area Sampling <ul><li>Pixel area is unit square </li></ul><ul><li>Constant weighting function </li></ul><ul><li>Pixel color is determined by computing the amount of the pixel covered by the line, then shading accordingly </li></ul><ul><li>Easy to compute, gives reasonable results </li></ul>Line One Pixel
  8. 8. Solution 2: Weighted Area Sampling <ul><li>Treat pixel area as a circle with a radius of one pixel </li></ul><ul><li>Use a radially symmetric weighting function (e.g., cone) : </li></ul><ul><ul><li>Areas closer to the pixel center are weighted more heavily </li></ul></ul><ul><li>Better results than unweighted, slightly higher cost </li></ul>Line One Pixel
  9. 9. Solution 3: Gupta-Sproull algorithm <ul><li>Calculate pixel intensity by computing distance from pixel center to line using the midpoint line algorithm </li></ul>x p NE m E x p+1 Line to draw v y p y p+1  D
  10. 10. Gupta-Sproull algorithm (cont) <ul><li>D is the perpendicular distance from E to the line </li></ul><ul><li>How do we compute it? </li></ul>a How does triangle abc compare to triangle ade? D c = e, and a = a, so b must equal d b c d e dx dy v r r
  11. 11. Gupta-Sproull algorithm (cont) <ul><li>D is the perpendicular distance from E to the line </li></ul><ul><li>How do we compute it? </li></ul>a So: D b c d e dx dy v r r And: Then:
  12. 12. Gupta-Sproull algorithm (cont) <ul><li>Recall from the midpoint algorithm: </li></ul><ul><li>So </li></ul><ul><li>For pixel E: </li></ul><ul><li>So: </li></ul>x p NE m E x p+1 Line to draw v y p y p +1  D
  13. 13. Gupta-Sproull algorithm (cont) <ul><li>From previous slide: </li></ul><ul><li>So </li></ul><ul><li>From the midpoint computation, </li></ul><ul><li>So: </li></ul>x p NE m E x p+1 Line to draw v y p y p+1  D
  14. 14. Gupta-Sproull algorithm (cont) <ul><li>From the midpoint algorithm, we had the decision variable (remember?) </li></ul><ul><li>Going back to our previous equation: </li></ul>x p NE m E x p+1 Line to draw v y p y p +1  D
  15. 15. Gupta-Sproull algorithm (cont) <ul><li>So, </li></ul><ul><li>And the denominator is constant </li></ul><ul><li>Since we are blurring the line, we also need to compute the distances to points y p – 1 and y p + 1 </li></ul>
  16. 16. Gupta-Sproull algorithm (cont) <ul><li>If the NE pixel had been chosen: </li></ul>
  17. 17. Gupta-Sproull algorithm (cont) <ul><li>Compute midpoint line algorithm, with the following alterations: </li></ul><ul><li>At each iteration of the algorithm: </li></ul><ul><ul><li>If the E pixel is chosen, set numerator = d + dx </li></ul></ul><ul><ul><li>If the NE pixel is chosen, set numerator = d – dx </li></ul></ul><ul><ul><li>Update d as in the regular algorithm </li></ul></ul><ul><ul><li>Compute D = numerator/denominator </li></ul></ul><ul><ul><li>Color the current pixel according to D </li></ul></ul><ul><ul><li>Compute D upper = (2dx-2vdx)/denominator </li></ul></ul><ul><ul><li>Compute D lower = (2dx+2vdx)/denominator </li></ul></ul><ul><ul><li>Color upper and lower accordingly </li></ul></ul>
  18. 18. Solution 4: Super-sampling <ul><li>Divide pixel up into “sub-pixels”: 2  2, 3  3, 4  4, etc. </li></ul><ul><li>Sub-pixel is colored if inside line </li></ul><ul><li>Pixel color is the average of its sub-pixel colors </li></ul><ul><li>Easy to implement (in software and hardware) </li></ul>No antialiasing Antialiasing (2  2 super-sampling)
  19. 19. Solution 5: Sum of Foreground and Background <ul><li>Compute percent of pixel covered by line, p </li></ul><ul><li>Line color is c l </li></ul><ul><li>Background color is c b </li></ul><ul><li>Pixel color is the sum of this percent multiplied by the line color, plus the percent of the pixel not covered by the line multiplied by the background color, i.e., </li></ul><ul><li>color = p * c l + (1-p) * c b </li></ul>
  20. 20. Polygon Antialiasing <ul><li>To antialias a line, we treat it as a polygon (a rectangle) </li></ul><ul><li>Antialiasing a polygon (or any shape primitive) is similar </li></ul><ul><li>Some concerns: </li></ul><ul><ul><li>Corners: Complicate the coverage </li></ul></ul><ul><ul><li>computation </li></ul></ul><ul><ul><li>Micro-polygons: smaller than a pixel </li></ul></ul><ul><ul><li>Super-sampling: There may still be </li></ul></ul><ul><ul><li>polygons that “slip between the cracks” </li></ul></ul>

×