Camera Space Transformations (Direct3D 9)

Vertices in the camera space are computed by transforming the object vertices with the world view matrix.

V = V * wvMatrix

Vertex normals, in camera space, are computed by transforming the object normals with the inverse transpose of the world view matrix. The world view matrix may or may not be orthogonal.

N = N * (wvMatrix⁻¹)T

The matrix inversion and matrix transpose operate on a 4x4 matrix. The multiply combines the normal with the 3x3 portion of the resulting 4x4 matrix.

If the render state, D3DRENDERSTATE_NORMALIZENORMALS is set to TRUE, vertex normal vectors are normalized after transformation to camera space as follows:

N = norm(N)

Light position in camera space is computed by transforming the light source position with the view matrix.

Lₚ = Lₚ * vMatrix

The direction to the light in camera space for a directional light is computed by multiplying the light source direction by the view matrix, normalizing, and negating the result.

Ldir = -norm(Ldir * wvMatrix)

For the D3DLIGHT_POINT and D3DLIGHT_SPOT the direction to light is computed as follows:

Ldir = norm(V * Lₚ), where the parameters are defined in the following table.

Parameter Default value Type Description
Ldir N/A D3DVECTOR Direction vector from object vertex to the light
V N/A D3DVECTOR Vertex position in camera space
wvMatrix Identity D3DMATRIX Composite matrix containing the world and view transforms
N N/A D3DVECTOR Vertex normal
Lₚ N/A D3DVECTOR Light position in camera space
vMatrix Identity D3DMATRIX Matrix containing the view transform

 

Mathematics of Lighting