问题描述
我想知道gluPerspective
参数.
在所有示例中,我看到fovy
设置为大约45-60度我试图将其设置为不同的值,对象只是消失了对此有什么解释?
In all examples I see fovy
is set to around 45-60degreesI've tried to set it to different values and the object just disappearswhat'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.
为观察其影响,我建议编写一个简单的应用程序,在该程序中,您可以通过按键逐步增大/减小视场-然后渲染一些球体或其他基本对象&看看更改后会发生什么.
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格斗.同样,将zNear设置得太靠近相机可能会产生相同的效果-实际上,拥有一个合理的zNear值比zFar更重要.如果您想确切知道为什么会发生这种情况,则应阅读一些深入的说明,例如此一个或这一个
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参数-它们是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!