Real-Time Rendering——4.7 Projections 投影 Orthographic Projection 正交投影

Before one can actually render a scene, all relevant objects in the scene must be projected onto some kind of plane or into some type of simple volume. After that,clipping and rendering are performed (Section 2.3).

在实际渲染场景之前,场景中的所有相关对象都必须投影到某种平面或某种简单的体积中。之后,进行裁剪和渲染(2.3节)。

Perspective projection matrices are exceptions to both of these properties: The bottom row contains vector and point manipulating numbers, and the homogenization process is often needed.

透视投影矩阵是这两个属性的例外:底行包含向量和点操作数,并且通常需要均匀化过程。

That is, w is often not 1, so a division by w is needed to obtain the nonhomogeneous point. Orthographic projection, which is dealt with first in this section, is a simpler kind of projection that is also commonly used. It does not affect the w-component.

也就是说,w通常不是1,因此需要除以w来获得非齐次点。正投影是本节首先讨论的一种简单的投影,也是常用的投影。它不会影响w分量。

4.7.1 Orthographic Projection 正交投影

A characteristic of an orthographic projection is that parallel lines remain parallel after the projection. When orthographic projection is used for viewing a scene, objects maintain the same size regardless of distance to the camera. Matrix Po, shown below,is a simple orthographic projection matrix that leaves the x- and y-components of a point unchanged, while setting the z-component to zero, i.e., it orthographically projects onto the plane z = 0:

正投影的一个特点是平行线在投影后保持平行。当使用正交投影查看场景时,对象保持相同的大小,而与相机的距离无关。如下所示,矩阵P0是一个简单的正交投影矩阵,它保持一个点的x和y分量不变,同时将z分量设置为零,即它正交投影到平面z = 0上:

Po is non-invertible,since its determinant |Po| = 0. In other words, the transform drops from three to two dimensions, and there is no way to retrieve the dropped dimension. 

Po是不可逆的,因为它的行列式|Po| = 0。换句话说,转换从三维下降到二维,并且没有办法恢复下降的维度。

It is usually useful to restrict the z-values (and the x- and y-values) to a certain interval, from, say n (near plane) to f (far plane). This is the purpose of the next transformation.

将z值(以及x值和y值)限制在某个区间通常很有用,比如从n(近平面)到f(远平面)。这是下一次转型的目的。

A more common matrix for performing orthographic projection is expressed by the six-tuple, (l, r, b, t, n, f), denoting the left, right, bottom, top, near, and far planes.This matrix scales and translates the axis-aligned bounding box (AABB; see the definition in Section 22.2) formed by these planes into an axis-aligned cube centered around the origin.

用于执行正投影的更常见的矩阵由六元组表示,(l,r,b,t,n,f),表示左、右、下、上、近和远平面。该矩阵缩放和平移轴对齐的边界框(AABB;参见第22.2节中的定义)由这些平面形成一个以原点为中心的轴对齐立方体。

The minimum corner of the AABB is (l, b, n) and the maximum corner is (r, t, f). It is important to realize that n > f, because we are looking down the negative z-axis at this volume of space.

AABB的最小角为(l,b,n),最大角为(r,t,f)。认识到n > f是很重要的,因为我们看到的是这个空间的负z轴。

In OpenGL the axis-aligned cube has a minimum corner of (−1,−1,−1) and a maximum corner of (1, 1, 1); in DirectX the bounds are (−1,−1, 0) to (1, 1, 1). This cube is called the canonical view volume and the coordinates in this volume are called normalized device coordinates.

在OpenGL中,轴对齐立方体的最小角为(-1,-1,-1),最大角为(1,1,1);在DirectX中,界限为(1,1,0)至(1,1,1)。该立方体被称为规范视图体积,并且该体积中的坐标被称为标准化设备坐标。(也就是说DirectX定义的单位立方体只有OpenGL定义的一半,但其实只是计算上的差异)

After the transformation into the canonical view volume, vertices of the geometry to be rendered are clipped against this cube. The geometry not outside the cube is finally rendered by mapping the remaining unit square to the screen. This orthographic transform is shown here:

在转换到规范视图体之后,要渲染的几何图形的顶点被剪切到这个立方体上。不在立方体之外的几何图形最终通过将剩余的单位正方形映射到屏幕上来呈现。此正交变换如下所示:

In computer graphics, a left-hand coordinate system is most often used afterprojection—i.e., for the viewport, the x-axis goes to the right, y-axis goes up, and the z-axis goes into the viewport.Because the far value is less than the near value for the way we defined our AABB, the orthographic transform will always include a mirroring transform.

在计算机图形学中,左手坐标系通常在投影后使用,即对于视口,x轴向右,y轴向上,z轴进入视口。因为我们定义AABB的方式的远值小于近值,所以正交变换将总是包括镜像变换。

To see this, say the original AABBs is the same size as the goal,the canonical view volume. Then the AABB’s coordinates are (−1,−1, 1) for (l, b, n) and (1, 1,−1) for (r, t, f). Applying that to Equation 4.63 gives us

要看到这一点,假设原始的AABBs与目标(规范视图体积)的大小相同。则(l,b,n)的AABB坐标为(-1,-1,1 ),而(r,t,f)的坐标为(1,1,-1)。将它应用于方程4.63,我们得到

 which is a mirroring matrix. It is this mirroring that converts from the right-handed viewing coordinate system (looking down the negative z-axis) to left-handed normalized device coordinates.

这是一个镜像矩阵。正是这种镜像从右手视图坐标系(向下看负z轴)转换为左手归一化设备坐标。

DirectX maps the z-depths to the range [0, 1] instead of OpenGL’s [−1, 1]. This can be accomplished by applying a simple scaling and translation matrix applied after the orthographic matrix, that is,

DirectX将z深度映射到范围[0,1],而不是OpenGL的[-1,1]。这可以通过在正交矩阵之后应用简单的缩放和平移矩阵来实现,也就是说,

So, the orthographic matrix used in DirectX is 

因此,DirectX中使用的正交矩阵是

which is normally presented in transposed form, as DirectX uses a row-major form for writing matrices. 

它通常以转置的形式出现,因为DirectX使用以行为主的形式来编写矩阵。

95 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

椰子糖莫莫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值