相机空间转换Camera space transformations

通过使用通用视图矩阵转换对象顶点来计算相机空间中的顶点。Vertices in the camera space are computed by transforming the object vertices with the world view matrix.

V = V * wvMatrixV = 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⁻¹)TN = N * (wvMatrix⁻¹)T

矩阵反转和矩阵转置在 4 x 4 矩阵上进行。The matrix inversion and matrix transpose operate on a 4x4 matrix. 乘法组合了法线与生成的 4 x 4 矩阵的 3 x 3 部分。The multiply combines the normal with the 3x3 portion of the resulting 4x4 matrix.

如果呈现状态被设置为标准化法线,则在转换为相机空间后,顶点法线矢量会被标准化,如下所示:If the render state is set to normalize normals, vertex normal vectors are normalized after transformation to camera space as follows:

N = norm(N)N = norm(N)

通过使用视图矩阵转换光源位置来计算相机空间中的光线位置。Light position in camera space is computed by transforming the light source position with the view matrix.

Lₚ = Lₚ * vMatrixLₚ = 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 =-范数 (Ldir * wvMatrix)Ldir = -norm(Ldir * wvMatrix)

对于点光和聚光灯,按如下所述计算光线方向:For a point light and a spotlight, the direction to light is computed as follows:

Ldir = norm (V * Lₚ),如果在下表中定义参数。Ldir = norm(V * Lₚ), where the parameters are defined in the following table.

参数Parameter 默认值Default value 在任务栏的搜索框中键入Type 描述Description
LdirLdir 不适用N/A 3D 矢量(x、y 和 z 浮点值)3D vector (x, y, and z floating-point values) 从对象顶点到光线的方向矢量Direction vector from object vertex to the light
VV 不适用N/A 3D 矢量(x、y 和 z 浮点值)3D vector (x, y, and z floating-point values) 相机空间中的顶点位置Vertex position in camera space
wvMatrixwvMatrix 标识Identity 浮点值的 4 x 4 矩阵4x4 matrix of floating-point values 包含通用和视图转换的复合矩阵Composite matrix containing the world and view transforms
NN 不适用N/A 3D 矢量(x、y 和 z 浮点值)3D vector (x, y, and z floating-point values) 顶点法线Vertex normal
LₚLₚ 不适用N/A 3D 矢量(x、y 和 z 浮点值)3D vector (x, y, and z floating-point values) 相机空间中的光线位置Light position in camera space
vMatrixvMatrix 标识Identity 浮点值的 4 x 4 矩阵4x4 matrix of floating-point values 包含视图转换的矩阵Matrix containing the view transform

 

相关主题Related topics

照明的数学Mathematics of lighting