TVP4020
Programmers Reference Manual
A Gouraud Shaded Triangle
279
// Load the color start and delta values to draw
// a triangle
RStart (R1)
GStart (G1)
BStart (B1)
dRdyDom (dRdy13)
// To walk up the dominant edge
dGdyDom (dGdy13)
dBdyDom (dBdy13)
dRdx (dRdx)
// To walk along the scanline
dGdx (dGdx)
dBdx (dBdx)
D6
Calculating Depth Gradient Values
To draw from left to right and top to bottom, the depth gradients (or
deltas) required for interpolation are:
dZdy
13
=
Z
3
−
Z
1
Y
3
−
Y
1
And from the plane equation:
dZdx
=
{(Z
1
−
Z
3
)
×
(Y
2
−
Y
3
)
a
}
−
{(Z
2
−
Z
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
)})
The divisor, shown here as a, is the same as for color gradient values.
The two deltas, dZdy
13
and dZdx allow the Z value of each fragment in
the triangle to be determined by linear interpolation as was described for
the color interpolation above.
D7
Register Set-up for Depth Testing
Internally P
ERMEDIA
uses fixed point arithmetic. The formats for each
register are described later. Each depth value must be converted into a
2's complement fixed point number and then loaded into the appropriate
pair of registers. The 'Upper' or 'U' registers store the integer portion,
whilst the 'Lower' or 'L' registers store the fractional bits, left justified and
zero filled.
For the example triangle, P
ERMEDIA
would need its registers set-up as
follows:
Summary of Contents for TVP4020 PERMEDIA 2
Page 1: ...Texas Instruments TVP4020 PERMEDIA 2 Programmer s Reference Manual Issue 4 ...
Page 284: ...TVP4020 Programmers Reference Manual A Gouraud Shaded Triangle 275 ...
Page 292: ...TVP4020 Programmers Reference Manual Register Tables 283 ...
Page 314: ...TVP4020 Programmers Reference Manual Index 305 ...
Page 315: ...Index TVP4020 Programmers Reference Manual 306 Index ...
Page 323: ...Index TVP4020 Programmers Reference Manual 314 ...