Game Development Reference
In-Depth Information
used to generate the texture coordinates in this case is
2
4 1/s x
3
5
0
0
0
0
−1/s y
0
0
Texture coordinate
generation matrix for a
DOOM-style omni light
,
0
0
1/s z
0
1/2
1/2
1/2
1
where s x , s y , and s z are the dimensions of the box on each axis. This matrix
operates on points in the object space of the light, where the position of the
light is in the center of the box, so for the matrix that operates on world-
space coordinates, we would need to multiply this matrix by a 4 × 4 world-
to-object matrix on the left. Note the right-most column is [0,0,0,1] T ,
since we use an orthographic projection onto the gobo. The translation of
1/2 is to adjust the coordinates from the [−1/2,+1/2] range into the [0,1]
range of the texture. Also, note the flipping of the y-axis, since +y points
up in our 3D conventions, but +v points down in the texture.
Next, let's look at the spot light. It uses a perspective projection, where
the center of projection is at one end of the box. The position of the light
used for calculating the l vector is at this same location, but that isn't
always the case! Note that the same circular gobo is used as for the omni,
but due to the perspective projection, it forms a cone shape. The falloff
map is brightest at the end of the box nearest the center of projection and
falls off linearly along the +z axis, which is the direction of projection of
the gobo in all cases. Notice that the very first pixel of the spot light falloff
map is black, to prevent objects “behind” the light from getting lit; in
fact, all of the gobos and falloff maps have black pixels at their edges, since
these pixels will be used for any geometry outside the box. (The addressing
mode must be set to clamp to avoid the gobo and falloff map tiling across
3D space.) The texture generation matrix for perspective spots is
2
4 s z /s x
3
0
0
0
Texture coordinate
generation matrix for a
DOOM-style spot light
5
0
−s z /s y
0
0
.
1/2
1/2
1/s z
1
0
0
0
0
The “fake spot” on the right is perhaps the most interesting. Here,
projection is orthographic, and it is sideways. The conical nature of the
light as well as its falloff (what we ordinarily think of as the falloff, that is)
are both encoded in the gobo. The falloff map used for this light is the same
as for the omni light: it is brightest in the center of the box, and causes
the light to fade out as we approach the −z and +z faces of the box. The
texture coordinate matrix in this case is actually the same as that for the
omni. The entire change comes from using a different gobo, and orienting
the light properly!
Search WWH ::




Custom Search