KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.5k stars 319 forks source link

Camera Fov Y exported wrong. #2315

Closed voidstorm closed 1 month ago

voidstorm commented 3 months ago

Describe the bug Camera y-fov export is wrong. Instead of exporting it in radians it seems its exported as degrees/100. E.g a fov of 39.9 is exported as 0.3999 instead of 0.69. The erratic behavior is also apparent when re-importing the previously imported gltf file. If you re-import, the fovy that was exported as 39.9 becomes now 22.9 instead. Changing lens units from/to fov or mm also does not change behavior.

To Reproduce Steps to reproduce the behavior: Create a camera, export gltf including cameras. Check json -> value will be wrong. To further confirm, re-import gltf, now the imported camera will also have a wrong fov.

Expected behavior E.g 39.9 should export as 6.999 radians

Version

julienduroure commented 3 months ago

Hello,

Exporting / Importing camera yfov is not as simple as field of view conversion, as it require also aspect ratio (so render size) and sensor fit

We can find the conversion used here:

https://github.com/KhronosGroup/glTF-Blender-IO/blob/93db35363d12975da974e1d12f0343932a85dcaf/addons/io_scene_gltf2/blender/com/gltf2_blender_conversion.py#L201

At import, we currently don't fully manage aspect ratio / render size : https://github.com/KhronosGroup/glTF-Blender-IO/blob/93db35363d12975da974e1d12f0343932a85dcaf/addons/io_scene_gltf2/blender/imp/gltf2_blender_camera.py#L64

julienduroure commented 1 month ago

Hello, More than a month without any answer, closing this ticket Feel free to comment again if you want to continue the discussion