如何解决透视投影失真? [英] How to fix perspective projection distortion?

查看:63
本文介绍了如何解决透视投影失真?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是图形编程的新手.我从来没有意愿坐下来研读任何漫长的OpenGL教程,但是当Apple发布Metal时,我感到非常兴奋,从那以后我走了很长一段路.我了解所有矩阵数学背后的原因(尽管当然不是它们的推导方式),但我在投影时遇到了困难.使用正交投影矩阵时,没有深度,因此在这种情况下您最好放弃3D图形.但是,虽然起初我的透视投影效果不错,但是当我将立方体从投影中心移开时,我注意到了一些东西:

I'm new to graphics programming. I never had the willpower to sit down and grind through any long OpenGL tutorial, but I got really excited when Apple released Metal and I've come a long ways since. I understand the reasoning behind all the matrix mathematics (although not how they were derived, of course) but I'm having difficulty with my projection. With an orthographic projection matrix, there is no depth so you might as well give up on 3D graphics in that case. However, while my perspective projection seemed to work great at first, I noticed something when I translated my cube away from the center of the projection:

现在我可能完全错了,但是那种扭曲感觉并不现实.也许在纹理化和更复杂之后,这是有道理的,但是我不确定.在项目中,我有一个投影矩阵,一个世界视图矩阵和该多维数据集的模型视图矩阵.矩阵按以下顺序相乘: prMatrix *(wvMatrix * mvMatrix)*< vertex> .不管物体在视锥中处于什么位置,都有什么方法可以保持它们的比例?

Now I may be completely wrong, but that distortion does not feel realistic. Maybe after texturing and more complexity it will make sense, but I don't know for sure. In the project, I have a single projection matrix, a world-view matrix, and the cube's model-view matrix. The matrices are multiplied in this order: prMatrix * (wvMatrix * mvMatrix) * <vertex>. Is there some way to maintain objects' proportions no matter where they are within a perspective frustum?

推荐答案

正如reto koradi所述,视野参数非常重要.

As reto koradi mentions, the field of view parameter is very important.

如果您将窗口视为对所看世界的物理窗口,并且将眼睛视为观察点,则可以看到金字塔.对于小窗口,如果离监视器足够远,则金字塔会非常尖锐:因此视野很小.我想说的是,当您实际上以20至30度的角度观看时,您可能会画出90度或更大的视场(因为窗口不是全屏的而是很小的).

If you think of your window as a physical window to the world you're looking at, and your eye as the observation point, you can visualise a pyramid. For a small window, and if you're far enough from the monitor, the pyramid will be very pointy: the field of view is therefore small. I would say you probably drew with a field of view of 90 degrees or more when you really were viewing it at something like 20-30 degrees (since your window is not full screen but rather small).

这会导致严重的失真,如果您实际上是从近处看窗户的话,必须看起来正确.

That incurs a significant distortion, which is required to look correct if you're really looking at your window from up close.

这篇关于如何解决透视投影失真?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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