A Gouraud Shaded Triangle
TVP4020
Programmers Reference Manual
278
D4
Calculating Color values for Interpolation
To draw from left to right and top to bottom, the color gradients (or
deltas) required are:
dRdy
R
R
Y
Y
13
3
1
3
1
=
−
−
dGdy
13
=
G
3
−
G
1
Y
3
−
Y
1
dBdy
13
=
B
3
−
B
1
Y
3
−
Y
1
And from the plane equation:
dRdx
=
{(R
1
−
R
3
)
×
(Y
2
−
Y
3
)
a
}
−
{(R
2
−
R
3
)
×
(Y
1
−
Y
3
)
a
}
dGdx
=
{(G
1
−
G
3
)
×
(Y
2
−
Y
3
)
a
}
−
{(G
2
−
G
3
)
×
(Y
1
−
Y
3
)
a
}
dBdx
=
{(B
1
−
B
3
)
×
(Y
2
−
Y
3
)
a
}
−
{(B
2
−
B
3
)
×
(Y
1
−
Y
3
)
a
}
where:
a
=
ABS({( X
1
−
X
3
)
×
(Y
2
−
Y
3
)}
−
{( X
2
−
X
3
)
×
(Y
1
−
Y
3
)})
These values allow the color of each fragment in the triangle to be
determined by linear interpolation. For example, the red component
color value of a fragment at X
n
,Y
m
could be calculated by:
•
adding dRdy
13
, for each scanline between Y
1
and Y
n
, to R
1
.
•
then adding dRdx for each fragment along scanline Y
n
from the left
edge to X
n
.
The example chosen has the 'knee' i.e. vertex 2, on the right hand side,
and drawing is from left to right. If the knee were on the left side (or
drawing was from right to left), then the Y deltas for both the subordinate
sides would be needed to interpolate the start values for each color
component (and the depth value) on each scanline. For this reason
P
ERMEDIA
always draws triangles starting from the dominant edge and
towards the subordinate edges. For the example triangle, this means left
to right.
D5
Register Set-up for Color Interpolation
For the example triangle the P
ERMEDIA
registers must be set as follows.
Details of register formats are given later.
Содержание TVP4020 PERMEDIA 2
Страница 1: ...Texas Instruments TVP4020 PERMEDIA 2 Programmer s Reference Manual Issue 4 ...
Страница 47: ...Memory I O and Organization TVP4020 Programmers Reference Manual 38 Texture address TextureBaseAddress T W S ...
Страница 284: ...TVP4020 Programmers Reference Manual A Gouraud Shaded Triangle 275 ...
Страница 292: ...TVP4020 Programmers Reference Manual Register Tables 283 ...
Страница 314: ...TVP4020 Programmers Reference Manual Index 305 ...
Страница 315: ...Index TVP4020 Programmers Reference Manual 306 Index ...
Страница 323: ...Index TVP4020 Programmers Reference Manual 314 ...