-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
glTF2 Importer uses incorrect code to calculate horizontal FOV #4435
Comments
…ective camera in GLTF2 import assimp#4435
Fix: fix incorrect math for calculating the horizontal FOV of a perspective camera in gltf2 import #4435
This code does not respect the aiCamera's interface. It computes the correct horizontal FOV, however, the camera struct // FBX fov is full-view degrees. We want half-view radians.
out_camera->mHorizontalFOV = AI_DEG_TO_RAD(fov_deg) * 0.5f; The code here should therefore change from: aicam->mHorizontalFOV = 2.0f * std::atan(std::tan(cam.cameraProperties.perspective.yfov * 0.5f) * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect)); to aicam->mHorizontalFOV = std::atan(std::tan(cam.cameraProperties.perspective.yfov * 0.5f) * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect)); I will gladly provide a pull request if this is agreed to be correct. Update: I noticed that the semantics of |
The importer code for glTF2.0 assumes multiplying the vertical FOV by the aspect ratio is how horizontal FOV is calculated.
However, this is not correct and the correct way to convert between the two is by this method referenced in this Reddit post.
The text was updated successfully, but these errors were encountered: