Antialiasing Avoid the jagged appearance of drawn primitives
Antialiasing Avoid the jagged appearance of drawn primitives
Antialiasing Solutions Increase the resolution Expensive solution – diminishes jaggies, does not eliminate them
Antialiasing Solutions Treat the line as having thickness Highlight the intersected pixels based on area of overlap
Antialiasing Weighted Area Sampling – amount of intensity depends on area of overlap Pixel representation – overlay pixel with disks of radius 1 allows the pixel to be intensified as the object approaches it, i.e. before object crosses the pixel
Antialiasing Weighted Area Sampling – amount of intensity depends on area of overlap Pixel representation – overlay pixel with disks of radius 1 allows the pixel to be intensified as the object approaches it, i.e. before object crosses the pixel
Antialiasing Weighted Area Sampling – amount of intensity depends on area of overlap Pixel representation – overlay pixel with disks of radius 1 allows the pixel to be intensified as the object approaches it, i.e. before object crosses the pixel
Antialiasing Weighted Area Sampling – amount of intensity depends on area of overlap Pixel representation – overlay pixel with disks of radius 1 allows the pixel to be intensified as the object approaches it, i.e. before object crosses the pixel
Midpoint Algorithm and Antialiasing Calculate the “true distance” from the pixel center to the line Use the “true distance” as a measure of the are of overlap Need to consider the neighbors above and below P N M this pixel would have been selected based on the midpoint P but now we also consider the immediate neighbors vertically P S
Midpoint Algorithm and Antialiasing In the algorithm from Section 3.2 we know F ( M ) from the equation F(x, y) = 2a*x + 2b*y + 2c a = dy, b = -dx = 2*(ax + by + c) Given a line equation F(x, y) = a*x + b*y + c the (signed) distance to the line can be found if we use an equivalent form D(x, y) = a*x + b*y + c a 2 +b 2 a 2 +b 2 a 2 +b 2 This is the line equation scaled by the factor 1 / a 2 +b 2
Midpoint Algorithm and Antialiasing If we decided to move East and we knew the distance D P can we find D P E , D P N , D P S Coordinates: P(xp,yp) P E (xp+1,yp) P N (xp+1,yp+1) P S (xp+1,yp-1) P N M P P E P S
Midpoint Algorithm and Antialiasing If we decided to move East and we knew the distance D P can we find D P E , D P N , D P S Coordinates: P(xp,yp) P E (xp+1,yp) P N (xp+1,yp+1) P S (xp+1,yp-1) D(P E ) = a*(xp+1) + b*yp + c = a*xp + a + b*yp + c = a*xp + b*yp + c + a P N = D(P) + a M P P E P S
Midpoint Algorithm and Antialiasing If we decided to move East and we knew the distance D P can we find D P E , D P N , D P S Coordinates: P(xp,yp) P E (xp+1,yp) P N (xp+1,yp+1) P S (xp+1,yp-1) D(P E ) = a*(xp+1) + b*yp + c = a*xp + a + b*yp + c = a*xp + b*yp + c + a P N = D(P) + a M D(P N ) = a*(xp+1) + b*(yp+1) + c = a*xp + a + b*yp + b + c = a*xp + b*yp + c + a + b P P E = D(P) + a + b = D(P E ) + b P S
Midpoint Algorithm and Antialiasing If we decided to move East and we knew the distance D P can we find D P E , D P N , D P S Coordinates: P(xp,yp) P E (xp+1,yp) P N (xp+1,yp+1) P S (xp+1,yp-1) D(P E ) = a*(xp+1) + b*yp + c = a*xp + a + b*yp + c = a*xp + b*yp + c + a P N = D(P) + a M D(P N ) = a*(xp+1) + b*(yp+1) + c = a*xp + a + b*yp + b + c = a*xp + b*yp + c + a + b P P E = D(P) + a + b = D(P E ) + b D(P S ) = a*(xp+1) + b*(yp-1) + c P S = a*xp + a + b*yp + b + c = a*xp + b*yp + c + a - b = D(P) + a - b = D(P E ) + b
Midpoint Algorithm and Antialiasing If we decided to move East and we knew the distance D P can we find D P E , D P N , D P S P N + b M D(P E ) = D(P) + a P P E - b P S
Midpoint Algorithm and Antialiasing If we decided to move NorthEast and we knew the distance D P can we find D P NE , D P N , D P S Coordinates: P(xp,yp) P NE (xp+1,yp+1) P N (xp+1,yp+2) P S (xp+1,yp) P N P NE M P P S
Midpoint Algorithm and Antialiasing If we decided to move NorthEast and we knew the distance D P can we find D P NE , D P N , D P S Coordinates: P(xp,yp) P NE (xp+1,yp+1) P N (xp+1,yp+2) P S (xp+1,yp) D(P NE ) = a*(xp+1) + b*(yp+1) + c P N = a*xp + a + b*yp + b + c = a*xp + b*yp + c + a + b = D(P) + a + b P NE M P P S
Midpoint Algorithm and Antialiasing If we decided to move NorthEast and we knew the distance D P can we find D P NE , D P N , D P S Coordinates: P(xp,yp) P NE (xp+1,yp+1) P N (xp+1,yp+2) P S (xp+1,yp) D(P NE ) = a*(xp+1) + b*(yp+1) + c P N = a*xp + a + b*yp + b + c = a*xp + b*yp + c + a + b = D(P) + a + b P NE D(P N ) = a*(xp+1) + b*(yp+2) + c = a*xp + a + b*yp + 2b + c = a*xp + b*yp + c + a + 2b M = D(P) + a + 2b = D(P NE ) + b P P S
Midpoint Algorithm and Antialiasing If we decided to move NorthEast and we knew the distance D P can we find D P NE , D P N , D P S Coordinates: P(xp,yp) P NE (xp+1,yp+1) P N (xp+1,yp+2) P S (xp+1,yp) D(P NE ) = a*(xp+1) + b*(yp+1) + c P N = a*xp + a + b*yp + b + c = a*xp + b*yp + c + a + b = D(P) + a + b P NE D(P N ) = a*(xp+1) + b*(yp+2) + c = a*xp + a + b*yp + 2b + c = a*xp + b*yp + c + a + 2b M = D(P) + a + 2b = D(P NE ) + b P P S D(P S ) = a*(xp+1) + b*yp + c = a*xp + a + b*yp + c = a*xp + b*yp + c + a = D(P) + a = D(P NE ) - b
Midpoint Algorithm and Antialiasing If we decided to move NorthEast and we knew the distance D P can we find D P NE , D P N , D P S P N + b P NE D(P NE ) = D(P) + a + b M - b P P S
Midpoint Algorithm and Antialiasing Finally, consider the initial conditions, i.e at first vertex P 0 P N ? D(P 0 ) = ? P 0 ? P S
Midpoint Algorithm and Antialiasing Finally, consider the initial conditions, i.e at first vertex P 0 P N + b D(P 0 ) = 0 P 0 - b P S
Midpoint Algorithm and Antialiasing Minor modification s required to Midpoint Algorithm to use Antialiasing def drawLineAA(x0, y0, x1, y1, c): # # keep original algorithm # compute a', b' for D(x,y) from a,b of F(x,y) compute dist increments for E, NE update dist similar to update of d # # change plotPixel(P, c) # plotPixel(P above , c, dist above ) plotPixel(P, c, dist) plotPixel(P below , c, dist below )
Distance and Intensity How to convert distances to pixel intensity? 1. use a formula that returns a number in [0..1] based on distance value dist = 0 => return 1, dist = dist max => return 0 2. use a table of precomputed values (Gupta-Sproull paper, Table 1)
Distance and Intensity How to convert distances to pixel intensity? 1. use a formula that returns a number in [0..1] based on distance value dist = 0 => return 1, dist = dist max => return 0 2. use a table of precomputed values (Gupta-Sproull paper, Table 1) Under our assumptions what is the useful range for dist
Distance and Intensity How to convert distances to pixel intensity? 1. use a formula that returns a number in [0..1] based on distance value dist = 0 => return 1, dist = dist max => return 0 2. use a table of precomputed values (Gupta-Sproull paper, Table 1) Under our assumptions what is the useful range for dist dist = 0 intensity = 100% dist max = 1.5 dist = 1 intensity = 0%
Horizontal/Vertical Lines
Alpha Blending Instead of overwriting the intensity of the current pixel, blend current and new value color = α * color new + (1-α) * color current α = [0..1]
Recommend
More recommend