Mik*_*012 4 opengl camera fieldofview perspective
使用openGL透视图时,我不太确定如何从fovy计算fovx.我在不同的地方阅读不同的东西,并且通过使用我找到的任何一种方法都没有得到正确的行为.那么有人可以告诉我,鉴于相机的性能和宽高比,如何计算相机的fovx?如果需要任何其他数据,那就让我知道我需要什么.非常感谢你提前!
正确:
fieldOfViewX = 2 * atan(tan(fieldOfViewY * 0.5) * aspect)
Run Code Online (Sandbox Code Playgroud)
错了,特别是对于大方面,请参阅下面的@ gman的评论:
Aspect ratio === width/height
fovy ~= "height"
==> fovx = fovy * aspect
Run Code Online (Sandbox Code Playgroud)
测试:
Fovy = 60 degs
Aspect = 4:3 ~= 1.33
Fovx = 60*1.33 = 80
80/60 = 4:3 (fovs match, yay)
Run Code Online (Sandbox Code Playgroud)
对于"合理的"fovs /方面,简单的方法是"合理地"接近事实,但如果你有极端的方面,你会得到fovx> 180度,这是你不想要的.