Graphics Reference
In-Depth Information
The light projection matrix would be constructed just like any other
projection matrix, using the light's parameters for field of view ( FOV ),
aspect ratio ( aspect ), and near ( zNear ) and far plane ( zFar ) distances.
FOV
cot
2
0
0
0
aaspect
FOV
0
cot
0
0
2
zFar
+
zNear
2
×
zFar
+
zNear
0
0
zNear
zFar
zNear
zFar
0
0
1
0
The light view matrix is constructed by using the three primary axis
directions that define the light's view axes and the light's position. We
refer to the axes as the right, up, and look vectors.
right x
.
up x
.
look x
.
0
right y
.
up y
.
look y
.
0
right z
.
up z
.
look z
.
0
dot right
(
,
lightPos dot up lightPos dot look
)
(
,
)
(
,
lightPos
) 1
After transforming the object's position by the view and projection
matrices, we must then turn the coordinates into projective texture
coordinates. This is accomplished by using a 3 × 3 bias matrix on the
( x , y , z ) components of the position in projective light space. The bias
matrix does a linear transformation to go from the [−1, 1] range to the
[0, 1] range. Having the coordinates in the [0, 1] range is necessary for
the values to be used as texture coordinates.
0.5 0.0 0.0
0.0 0.5 0.0
0.5 0.5 1.0
Typically, the matrix to transform the position into a projective texture
coordinate would be computed on the CPU by concatenating the
projection, view, and bias matrices together (using a 4 × 4 version of the bias
matrix). The result would then be loaded into a single uniform matrix that
could transform the position in the vertex shader. However, in the example,
we perform this computation in the vertex shader for illustrative purposes.
 
 
Search WWH ::




Custom Search