Graphics Reference
In-Depth Information
3-space, take the difference, and find an appropriate representation of that dif-
ference. We have
) = (
) (
) =
xyzw xyzw xyz
w
,
,
xyz
w
,
,
(
) (
bbb
aaa
,
,
,
,
,
,
bbbb aaa
a
b
a
(
) (
)
wx
wy wz wx wy wz
ww
,
,
,
ab
ab ab
ba ba ba
.
ab
Now the denominator in the right-hand side is a scalar, so if we only want a
unit direction vector, we can simply normalize the numerator as
.
(
)
v
=
normalize
w xwxwywywzwz
ab ba ab ba ab ba
,
,
If both of the original vectors were already in homogeneous form with w a and
w b both equal to one, this reduces to the standard form for the difference of two
vectors.
Light position is specified in homogeneous coordinates with four values
that actually position the light in projective 4-space. If the w component is not
zero, the light position is an ordinary point in 3D world space whose x -, y -,
and z -values are given when the point is converted to standard homogeneous
form. But if you use a light position whose homogeneous coordinate w is zero,
the light is treated as a directional light, because the position is the “point at
infinity” of projective space. Modeling and viewing transformations affect the
direction of the light, but they do not affect light's position.
Texture coordinates are also stored as real 4-vectors, just like vertices, but
they also include the possibility of a one-dimensional case. Texture coordinate
components have name conventions, just as vertices do; for textures, these are
( s , t , p , q ). (The leter p is used for the third texture coordinate instead of r in
order to avoid confusion with the leter for the color red.) If you specify a 1D
texture with a value of s , the t and p values are set to 0 and the q value is set to 1.
The 2D and 3D texture coordinates are set in the same way.
Color is also stored internally in four dimensions in RGBA form, and if
you only specify a color in RGB form, its alpha component is set to 1. Normal
vectors are always defined to be three-dimensional, as in glNormal3f(x,y,z),
so there are no homogeneous-coordinate issues with normals.
Graphics cards' reliance on 4-vectors lets them adopt a uniform data path
that is four floats wide. This lets cards become, in effect, array processors, and
is part of the reason that graphics cards can speed up the pipeline processes
so effectively.
Search WWH ::




Custom Search