gluPerspective 参数 - 它们是什么意思? [英] gluPerspective parameters- what do they mean?

查看:26
本文介绍了gluPerspective 参数 - 它们是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 gluPerspective 参数.

在所有示例中,我看到 fovy 设置为大约 45-60 度我试图将它设置为不同的值,但对象就消失了对它的解释是什么?

In all examples I see fovy is set to around 45-60degrees I've tried to set it to different values and the object just disappears what's the explanation for it?

aspect 值应该始终是比率吗?为什么要改变它?

The aspect value should always be the ratio? why would one change it?

zNear, zFar - 再一次,通常的值大约是 10 和 500+,这反映了什么?

zNear, zFar - once again the usual values are around 10 and 500+ what does it reflect?

推荐答案

4个参数的目的是定义一个视锥,像这样:

The purpose of the 4 parameters is to define a view frustum, like this:

在屏幕上应该看不到截锥体之外的任何东西(为此,参数用于计算一个 4x4 矩阵,然后用于将每个顶点转换为所谓的裁剪空间.在那里,测试是否一个顶点是否在视锥体内是微不足道的)

where nothing outside of the frustum should be is visible on screen ( To accomplish this, the parameters are used to calculate a 4x4 matrix, which is then used to transform each vertex into the so-called clip space. There, testing if a vertex is inside the frustum or not is trivial )

视野参数基本上是通过相机位置的平面与屏幕顶部之间的角度另一架飞机穿过相机位置和屏幕底部.这个角度越大,你能看到的世界就越多——但同时,你能看到的物体也会变得更小.

The field of view parameter is basically the angle in between a plane passing through the camera position as well as the top of your screen & another plane passing through the camera position and the bottom of your screen. The bigger this angle is, the more you can see of the world - but at the same time, the objects you can see will become smaller.

为了观察它的影响,我建议编写一个简单的应用程序,您可以通过按键逐渐增加/减少 fov - 然后渲染一些球体或其他基本对象 &看看当你改变它时会发生什么.

To observe its influence, I'd suggest coding a simple app where you can gradually increase / decrease the fov via keypress - then render some spheres or other basic objects & see what happens as you change it.

纵横比是您的视口的纵横比.(在上图中,视口位于近剪裁平面)能够随意定义它是有意义的,因为您的视口的纵横比可能会有所不同.

The aspect ratio is your viewport's aspect ratio. ( In the graphic above, the viewport is located at the the near clipping plane ) Being able to define it at will makes sense, since your viewport's aspect ratio may vary.

zNear &zFar 值定义了相机位置和相机之间的距离.分别是近剪裁平面和远剪裁平面.任何比 zNear 更靠近相机或比 zFar 更远的东西都将不可见.两个值都必须 > 0,显然 zFar > zNear.理想情况下应该选择 zFar 以便您想要渲染的所有内容都可见,但使其大于必要的浪费深度缓冲精度 &可能会导致闪烁效果,称为 z-fighting.同样,将 zNear 设置得太靠近相机可能会导致相同的效果——事实上,拥有一个合理的 zNear 值比 zFar 更重要.如果你想确切地知道为什么会发生这种情况,你应该阅读一些深入的解释,比如 this一个这个

The zNear & zFar values define the distance between the camera position & the near and far clipping planes, respectively. Nothing that's closer to the camera than zNear or farther away than zFar will be visible. Both values must be > 0, and obviously, zFar > zNear. zFar should ideally be chosen so that everything you want to render is visible, but making it larger than necessary wastes depth buffer prescision & may lead to flickering effects, called z-fighting. Likewise, setting zNear too close to the camera may cause the same effect - in fact, having a reasonable zNear value is more important than zFar. If you want to know exactly why this happens, you should read some in-depth explanations, like this one or this one

这篇关于gluPerspective 参数 - 它们是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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