为什么剪辑应该在 CCS 中完成,而不是 NDCS [英] Why clipping should be done in CCS, not NDCS

查看:36
本文介绍了为什么剪辑应该在 CCS 中完成,而不是 NDCS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么剪辑应该在 CCS 中完成,而不是 NDCS.我认为在NDCS中剪辑更容易,但是很多书都说剪辑应该在CCS中完成.他们举了一个例子,一条线从后面和前面放在眼睛上.

Why clipping should be done in CCS, not NDCS. I think it is easier to clip in NDCS, but many book said the clipping should be done in CCS. They give an example that a line is laid over eye from behind and front.

我不明白为什么会出现问题.

I could not understand why it can be a problem.

推荐答案

归一化设备坐标 (NDCS) 和剪辑空间 (CCS) 之间的唯一区别是,CCS 在透视分割之前,NDCS 在透视分割之后.在 NDCS 中剪裁效果不佳的原因是透视分割将观察者后面的点移动到前面(因为 w 包含 -z),因此观察者后面的三角形不会在前平面上被正确剪掉.

The only difference between Normalized Device Coordinates (NDCS) and Clip Space (CCS) is, that CCS is before the perspective divide and NDCS is afterwards. The reason why clipping doesn't work well in NDCS is that the perspective divide moves points behind the viewer to the front (since w contains -z), so triangles behind the viewer would not be clipped away correctly at the front plane.

问:NDCS 中的查看器在哪里.在 VCS 中,观察者的位置是原点 [0,0,0,1].但是,如果我用透视矩阵计算原点,结果很奇怪.齐次坐标不是1而是0.如何在NDCS中定义观察者的位置?

在 NDCS 和 CCS 中,没有有限的观看点(我不确定观看者与剪辑有什么关系).必须将两个系统都视为将视锥体扭曲为立方体(近平面和远平面具有相同大小).在 NDCS 中,可见区域沿每个轴位于 [-1, 1] 中,而在 CCS 中,它位于 [-w, w] 中.现在考虑观察者:在视图空间中,观察者(投影中心)是从近平面的一个角到远平面的相应角的所有光线相交的点.当我们现在将平截头体扭曲成立方体时,所有这些光线都是平行的,不再有交点.这意味着投影中心无限远,这在投影空间中由齐次坐标为 0 的向量描述.

In NDCS and CCS there is no finite viewing point (and I'm not sure what the viewer has to do with clipping). One has to think about both systems as the view-frustum being warped to a cube (near and far plane having the same size). In NDCS, the visible area is in [-1, 1] along each axis, whereas in CCS it is in [-w, w]. Now think about the viewer: In view space, the viewer (the projection center) was that point where all rays going from a corner of the near plane to the respective corner in the far plane intersected. When we now warp the frustum to a cube, all these rays are parallel and there is no intersection point anymore. This means the projection center is infinitely far away, which is described in projective space by vectors that have a homogeneous coordinate of 0.

Q:但是z> 0 的点在转换后总是大于1,在NDCS中也被砍掉了.我错了吗?如果我错了,你能给我举个例子吗?

你基本上是对的.但是裁剪不会发生在单个点上,裁剪发生在这些点之间的边缘上.

You are basically right. But clipping doesn't happen at single points, clipping happens on edges spanned between these points.

假设我们有一条从截锥体 (A) 内的点到观察者后面的点 (B) 的线.在这种情况下,剪裁应该发生在近平面,线应该从 A 到 B'(线与近平面的交点).

Let's assume we have a line going from a point inside the frustum (A) to a point behind the viewer (B). In this case clipping should happen at the near plane and the line should go from A to B' (the intersection of the line with the near plane).

如果我们首先执行透视分割,那么(如您所见)A 仍留在视锥体内,但 B 被映射到远平面后面的一个点.当我们现在剪断这些点之间的线时,我们得到一条从 A 到远平面上的点 B' 的线.显然,当线条最初穿过观众时,我们不想让线条远离观众.

If we would first perform the perspective divide, then (as you noted) A still stays inside the frustum but B gets mapped to a point behind the far plane. When we now clip the line between those points, we get a line going from A to a point B' which is on the far plane. Obviously we don't want to get a line away from the viewer when the line was initially going through the viewer.

这篇关于为什么剪辑应该在 CCS 中完成,而不是 NDCS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆