简体   繁体   English

派生透视投影平面

[英]Deriving the Perspective Projection plane

Given a perspective projection matrix and Center of Projection how can one derive the projection plane?给定一个透视投影矩阵和投影中心,如何推导出投影平面? For example, let us assume that the perspective projection matrix is a 4x4 homogenous matrix:例如,让我们假设透视投影矩阵是一个 4x4 齐次矩阵:

1 0 0 0
0 1 0 0
0 0 1 0
0 2 0 0

and the center of projection [0, 0, 0].和投影中心 [0, 0, 0]。 From this data, it is clear how each point is projected into the projection plane.从这些数据中,可以清楚地看出每个点是如何投影到投影平面上的。 But how can one use this data to find the exact equation / representation of the projection plane?但是如何使用这些数据来找到投影平面的精确方程/表示呢?

Unlike a "center of projection" (which is the effective location of the camera in the 3D scene), there is no need for a concrete "projection plane" in the sense of a notional plane that the image is projected upon.与“投影中心”(即相机在 3D 场景中的有效位置)不同,在图像被投影到的概念平面的意义上,不需要具体的“投影平面”。

Instead, the projection matrix determines a transformation into "clip space" which determines the viewport bounds and the depth mapping, from which the x and y coordinates are further scaled and offset to get the target pixel location.相反,投影矩阵确定了到“剪辑空间”的转换,它确定了视口边界和深度映射,从中进一步缩放和偏移xy坐标以获得目标像素位置。 However, none of this translates to an actual plane in the scene which somehow corresponds to a physical camera's focal plane.然而,这些都没有转化为场景中的实际平面,该平面以某种方式对应于物理相机的焦平面。

There are relevant planes you can derive from a camera matrix:您可以从相机矩阵中导出相关平面:

  • the w=0 plane, which is the fourth row of the projection matrix. w=0平面,即投影矩阵的第四行。 This plane passes through the center of projection, and separates points in front of the camera from those in back;该平面通过投影中心,并将相机前面的点与后面的点分开; none of the points on the w=0 plane can ever be visible. w=0平面上的任何点都不可见。 In your example, this plane is 0 2 0 0 , which is the XZ coordinate plane.在您的示例中,该平面是0 2 0 0 ,即 XZ 坐标平面。

  • the z=0 plane, which is the third row of the projection matrix. z=0平面,即投影矩阵的第三行。 In conjunction with the w=0 plane, it determines the depth mapping function and the near/far clipping planes.结合w=0平面,它确定深度映射函数和近/远剪裁平面。 In your example, this plane is 0 0 1 0 , which is the XY coordinate plane.在您的示例中,该平面是0 0 1 0 ,即 XY 坐标平面。

The remaining rows of the camera matrix also represent planes: the first and second rows are the x=0 and y=0 planes, respectively.相机矩阵的其余行也表示平面:第一行和第二行分别是x=0y=0平面。 In some sense, they are not as fundamentally concrete as the w=0 plane;从某种意义上说,它们根本不像w=0平面那样具体; conventionally, they separate the clip space (and the view frustum) into quadrants.传统上,他们将剪辑空间(和视锥体)分成象限。 They determine the horizontal and vertical boundary planes of the viewing frustum, by taking the sum and difference with the w=0 plane coordinates.它们通过对w=0平面坐标求和和差来确定视锥体的水平和垂直边界平面。

The "center of projection" is the point at the intersection of the x=0 , y=0 , and w=0 planes (that is, the first, second, and fourth rows of the projection matrix). “投影中心”是x=0y=0w=0平面(即投影矩阵的第一、第二和第四行)相交处的点。 I should note that this indicates your example is an unconventional configuration: the "center of projection" is not well-defined, and all your points will be mapped with clip-space coordinates such that y/w = 1/2 , which will typically be a horizontal line one quarter way down the screen.我应该注意,这表明您的示例是一个非常规配置:“投影中心”没有明确定义,并且您的所有点都将使用裁剪空间坐标进行映射,使得y/w = 1/2 ,这通常会是屏幕下方四分之一处的水平线。 Also note that, normally, the z=0 plane should be parallel to the w=0 plane, intersecting only at infinity (instead of along the X-axis, as in your example).另请注意,通常情况下, z=0平面应与w=0平面平行,仅在无穷远处相交(而不是沿 X 轴,如您的示例中所示)。

The near and far clip planes are derived from the z=0 and w=0 planes based on the clip space conventions of your graphics system:近剪裁平面和远剪裁平面根据图形系统的剪裁空间约定从z=0w=0平面派生而来:

  • OpenGL's depth clipping is z/w = [near=-1, far=+1] OpenGL 的深度裁剪是z/w = [near=-1, far=+1]
    • its near clip plane is the sum of the above w=0 and z=0 planes ( 0 2 1 0 in your example)它的近剪裁平面是上述w=0z=0平面的总和(在您的示例中为0 2 1 0
    • its far clip plane is their difference ( 0 2 -1 0 in the example)它的远剪裁平面是它们的区别(示例中为0 2 -1 0
  • DirectX's depth clipping is z/w = [near=0, far=-1] DirectX 的深度裁剪为z/w = [near=0, far=-1]
    • its near clip plane is the z=0 plane ( 0 0 1 0 in your example)它的近剪裁平面是z=0平面(在您的示例中为0 0 1 0
    • and its far clip plane is the sum of the two (identical to the OpenGL near clip plane, 0 2 1 0 in your example)它的远裁剪平面是两者的总和(与 OpenGL 近裁剪平面相同,在您的示例中为0 2 1 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM