Specifying Vertices |
Voodoo Graphics is a rendering engine.
The user configures the texture and pixel pipelines (see Figure 1.2) and then sends streams of vertices representing points, lines, triangles, and convex polygons. (In fact, the hardware renders only triangles; Glide converts points and lines to triangles and triangulates polygons as needed.)Vertices are specified in the GrVertex data structure, shown below and defined in glide.h.
Up to ten parameters can be used to specify a point:Note that the GrVertex structure has a spot for z, but actually uses its reciprocal (ooz, for one over z). Similarly, 1/w is stored in the variable oow. And, s/w and t/w are stored in the structure (as sow and tow) rather than s and t, because the scale d values are the ones actually used by the Voodoo Graphics system. These values need to be computed only once for each vertex, regardless of how many triangles include the vertex.the geometric co-ordinates (x, y, z, w)
where x and y indicate a screen location,
z indicates depth, and
w is the homogeneous co-ordinatethe color components (r, g, b, a) the texture co-ordinates (s, t) The GrVertex structure also includes a small array of GrTmuVertex data structures, one for each TMU present in the system, and each of the array elements contains private oow, sow, and tow variables. Each TMU and the Pixelfx chip each have their own copy of 1/w, s/w, and t/w. Normally, they will all be the same. However, projected textures have a different w value than non-projected textures.
Projected textures iterate q/w where w is the homogeneous distance from the eye and q is the homogeneous distance from the projected source.
typedef struct {
float oow; /* 1/w */ float sow; /* s/w texture co-ordinate */ float tow; /* t/w texture co-ordinate */ } GrTmuVertex; typedef struct {
|
Every vertex must specify values for x and y, but the other parameters are optional and need only be set if the rendering configuration requires them. Table 2.1 lists some typical rendering operations and the vertex parameters they use.Table 2.1 Vertex parameter requirements depend on the rendering function being performed.
The x and y co-ordinates must be specified for every vertex, regardless of the rendering function being performed. The other parameters stored in the GrVertex structure are optional and need to be supplied only if required for the desired computation. The table below details the values required by the rendering functions implemented by Glide and the Voodoo Graphics hardware.
Rendering Function | Required Variables | Expected Values | See Chapter |
all vertices, all rendering functions | x, y | 2048 to +2047 4 | Chapter 4 |
Gouraud shading | r, g, b | 0 to 255.0 | Chapter 5 |
alpha | a | 0 to 255.0 | Chapter 6 |
blending/testing non-projected texture mapping | tmuvtx[0].oow | 1/w where w is in the range [1..65535] | Chapter 9 |
tmuvtx[0].sow | s/w where s is in the range [0..255.0] | ||
tmuvtx[0].tow | t/w where t is in the range [0..255.0] | ||
projected texture mapping | tmuvtx[0].oow | 1/w where 1/w is in the range[4096..61439] | |
tmuvtx[0].sow | s/w where s/w is in the range[32768..32767] | ||
tmuvtx[0].tow | t/w where t/w is in the range[32768..32767] | ||
tmuvtx[1].oow | q/w where q/w is in the range [4096.. 61439] | ||
tmuvtx[1].sow | s/w where s/w is in the range [32768.. 32767] | ||
tmuvtx[1].tow | t/w where t/w is in the range [32768.. 32767] | ||
linear z buffering | ooz | 1/z where 1/z is in the range [0, 65535] | Chapter 7 |
w buffering | oow | 1/w where w is in the range [1..65535] | Chapter 7 |
fog with iterated alpha | a | [0..255.0] | Chapter 8 |
fog with iterated z | ooz | 1/z where 1/z is in the range [0, 65535] | Chapter 8 |
fog with table | oow | 1/w where w is in the range [1..65535] | Chapter 8 |