为什么归一化设备坐标系是左手的? [英] Why is the Normalized Device Coordinate system left-handed?

查看:227
本文介绍了为什么归一化设备坐标系是左手的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

起初,我想知道为什么NDC的范围是-1到1,而不是0到1.我想也许将原点放在中心对于某些事情很有用.

At first I wondered why NDC ranges from -1 to 1, rather than from 0 to 1. I figured maybe having the origin at the center is useful for something.

但是为什么要使用左手坐标系?

But why is it using a left-handed coordinate system?

是否可以让距离更远的对象的Z值更高?对我来说,那将是一个足够好的理由.

Could it be just so that the Z-value is higher for objects farther away? That would be a good enough reason for me.

推荐答案

但是为什么要使用左手坐标系?

But why is it using a left-handed coordinate system?

让我们在该问题上添加默认".因为更改它所需要做的就是glDepthRange(1.0f, 0.0f);,所以您现在是惯用右手的人了.是的,那是完全合法的GL语法;从来没有限制z附近的范围小于z附近的范围.

Let's add "by default" to that question. Because all that's needed to change it is glDepthRange(1.0f, 0.0f); and now you're right-handed. And yes, that is perfectly legal GL syntax; there has never been a restriction that the range near z is less than the range far z.

为什么默认情况下它是惯用左手的?也许ARB上有人喜欢这种方式.也许ARB上有人喜欢增加深度范围而不是减小深度范围,并且左下角的定向使其成为必需.也许是因为OpenGL的祖先IRIX GL就是这样做的,而ARB认为没有必要对其进行更改.

Why is it left-handed by default? Maybe someone on the ARB liked it that way. Maybe someone on the ARB liked increasing depth range instead of decreasing, and the lower-left corner orientation made that necessary. Maybe because the progenitor of OpenGL, IRIX GL, did it this way and the ARB didn't see any need to change it.

其原因无关紧要;上手习惯纯粹是一种符号上的便利.在某些地方,右撇子是有道理的.在其他情况下,左撇子是有道理的.而且由于它已经被微不足道地改变了,所以请使用适合您的方法.

The reason for this is immaterial; handedness is purely a notational convenience. In some places, right-handed makes sense. In others, left-handed makes sense. And since it is trivially changed, just use what works for you.

这将与其他所有内容保持一致.

It would then be consistent with everything else.

还有什么保持一致?所有固定功能的东西都被删除了吗?

Consistent with what everything else? All of the fixed-function stuff that's been removed?

视口转换全部由OpenGL内部完成,没人能做到.您甚至都没有提供矩阵.您只需提供一个视口和深度范围.因此,从使用固定功能GL的人的角度来看,所有事情实际上都是正确的.

The viewport transform is all done by OpenGL internally, where nobody can get at it. You don't even provide a matrix; you just provide a viewport and depth range. So from the perspective of someone using fixed-function GL, everything really is right-handed.

唯一需要用手处理的地方是直接处理顶点着色器时,您必须知道剪贴空间的用手处理是什么.在这种情况下,上手性的变化是透视投影否定Z的简单功能.或者,如果您喜欢用左手坐标,则透视投影否定Z.或者再次,反转glDepthRange,现在您就用右手了.

The only time the handedness even comes up is when dealing with vertex shaders directly, where you have to know what the handedness of the clip-space is. And in that case, the change in handedness is a simple function of the perspective projection negating the Z. Or, if you like left-handed coordinates, the perspective projection not negating the Z. Or again, just reverse the glDepthRange and now you're right-handed.

这篇关于为什么归一化设备坐标系是左手的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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