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

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

问题描述

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



我无法理解为什么它可能会成为问题。

解决方案

标准化设备坐标(NDCS)和剪辑空间(CCS)之间的唯一区别在于,CCS位于视角划分之前且NDCS在之后。裁剪在NDCS中效果不好的原因是,观看者背后的角度分割将点移动到前方(因为w包含-z),所以在观看者后面的三角形不会在前平面正确剪裁。

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



在NDCS和CCS中没有有限的观察点(和我不确定观看者与剪辑有什么关系)。人们必须考虑这两个系统,因为视角被扭曲成一个立方体(具有相同尺寸的近平面和远平面)。在NDCS中,可见区域沿着每个轴在[-1,1]中,而在CCS中,它在[-w,w]中。现在考虑一下观察者:在观察空间中,观察者(投影中心)是所有从近平面的角落到远平面的相应角落的光线相交的点。当我们现在将平截头体扭曲成立方体时,所有这些光线都是平行的,并且不再有交点。这意味着投影中心距离无限远,这在投影空间中由齐次坐标为0的向量描述。Q:然而,点其中z> 0在转换后总是大于1,并且在NDCS中也被切断。我错了吗?如果我错了,你能给我一个例子吗?



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



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

如果我们愿意首先执行透视分割,然后(如您所注意到的)A仍然留在平截头体内,但B被映射到远平面后面的点。当我们现在剪切这些点之间的连线时,我们得到一条从A到达远处平面上的B'点的线。显然,当线条最初穿过查看器时,我们不希望从观看者看到一条线。


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.

解决方案

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.

Q: Where is the viewer in NDCS. In VCS, the viewer's location is origin point [0,0,0,1]. However, if I calculate the origin point with perspective matrix, the result is weird. The homogeneous coordinate is not 1 but 0. How can we define the viewer's position in NDCS?

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: However, the point where z> 0 is always larger than 1 after conversion, and is also cut in NDCS. Am I wrong? If I'm wrong, can you give me one example?

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

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).

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天全站免登陆