



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Interactive Computer Graphics; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Unknown 1989;
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




lines and triangles
-^
with floating point vertices
-^
in viewport (screen) coordinates into•^
pixels
-^
with integer coordinates
-^
in viewport (screen) coordinates
pixels centered
at gridvertices, pixels centerednot grid cells
at gridvertices, not grid cells
Need to rasterize linesbetween any two clippedscreen points, from (
x^0
, y
to (
x^1
, y
Only rasterize lines fromthe origin to a point in thefirst octant
-^
Translate start vertex toorigin
-^
Reflect end vertex into firstoctant
( x
, y 0
) 0
( x^1
, y 1
) ( x
-x 1
,^0 y^1
-y^0
)
( x
-x 0
, 1 y-y^0
) 1
How to rasterize a linefrom (0,0) to (4,3)
-^
Pixel (0,0) and (4,3) easy
-^
One pixel for each integerx-coordinate
-^
Pixel’s y-coordinateclosest to line
-^
If line equal distancebetween two pixels, pickon arbitrarily butconsistently
0
1
2
3
4
4 3 2 1 0
Which pixel should beplotted next?– East?– Northeast?
Which pixel should beplotted next?– East?– Northeast?
-^
Line equation
y^
mx
b
m
y^1
y
x^1
x
b^
y
0
mx
0
f (
x ,
y ) =
mx
b
y
f^ < 0
f^
Which pixel should beplotted next?– East?– Northeast?
-^
Line equation
y^
mx
b
m
y^1
y
x^1
x
b^
y^0
mx
0
f (
x ,
y ) =
mx
b
y
f (
f (
x ,
y )
mx
b
y
f (
f (
x +1,
y +½)
m
( x
b
y +½)
mx
m
b
y
mx
b
y + m
f (
m
f (
f (
x +1,
y )
f (
m
f (
f (
x +1,
y +1)
f (
m
f (0,0)
b
f (
m
f (
f (
x +2,
y +½)
m
( x
b
y +½)
f (
m
f (
m
f (
NE
f (
x +2,
y +1½)
m
( x
b
y +1½)
f (
m
f (
m
f (1, ½) =
m
b
(^2) M
E M
NE
Ignore horizontal lines
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
Ignore horizontal lines
-^
Sort edges by smallery coordinate
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
For each scanline…
-^
Add edges wherey = ymin
-^
Sorted by x
-^
Then by dx/dy
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
segments lie on pixels
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
y = 1
-^
Delete y = ymax edges
-^
Update x
-^
Add y = ymin edges
-^
For each pair x
,x 0
, plot 1
from ceil(x
to ceil(x
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
y = 2
-^
Delete y = ymax edges
-^
Update x
-^
Add y = ymin edges
-^
For each pair x
,x 0
, plot 1
from ceil(x
to ceil(x
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
y = 3
-^
Delete y = ymax edges
-^
Update x
-^
Add y = ymin edges
-^
For each pair x
,x 0
, plot 1
from ceil(x
to ceil(x
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
y = 4
-^
Delete y = ymax edges
-^
Update x
-^
Add y = ymin edges
-^
For each pair x
,x 0
, plot 1
from ceil(x
to ceil(x
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
y = 9
-^
Delete y = ymax edges
-^
Update x
-^
Add y = ymin edges
-^
For each pair x
,x 0
, plot 1
from ceil(x
to ceil(x
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0
Flat shading– Per face normals– Color jumps across edge– Human visual perception
accentuates edges
Smooth shading– Per vertex normals– Colors similar across edge– Edges become harder to
discern
Perception
Keep track of R, G, B atedge endpoints
-^
Compute dR/dy, dG/dyand dB/dy per edge
-^
Compute dR/dx, dG/dxand dB/dx at eachscanline
-^
Color each pixelR += dR/dxG += dG/dxB += dB/dx
0
1
2
3
4
5
6
7
8
9
9 8 7 6 5 4 3 2 1 0