godotengine / godot-blender-exporter

Addon for Blender to directly export to a Godot Scene
GNU General Public License v2.0
1.16k stars 132 forks source link

Camera mismatch #109

Open samvila opened 6 years ago

samvila commented 6 years ago

On Blender 2.79a 64 bit Windows version the camera doesn't get exported correctly to Godot. Even changing the camera units in Blender from millimeters to field of view doesn't fix the problem, sometimes it gets exported correctly but many others don't.

For example a 35mm camera in Blender gets exported as 49.1 field of view in Godot, but a 49.1 field of view in blender also gets exported as 49.1 in Godot. In order to get the same results as in Blender viewport I need to manually tweak the setting in Godot to 35 instead of 49.1, then is perfect.

This should be automatically without expecting the user to know why this doesn't match or how to fix it.

Jason0214 commented 6 years ago

so are you suggesting Godot field of view angle with 35 degrees looks same with Blender's field of view angle with 49.1 degrees? (I can not tell much difference by just looking at the viewport, but it do seems the object size is larger in Blender with same FOV) I think the exporting of the FOV value has no problem, might be the issue that same FOV looks different in Godot and Blender. I would go and consult some godot developers.

sdfgeoff commented 6 years ago

There is one current limitation in the export, and that is that blender's FOV setting sets the maximum FOV, whereas godot's sets the minimum. If you have a square screen, they will be the same, but if your image is wider than tall, godot will zoom out, and blender will zoom in.

Unfortunately I couldn't think of how to "solve" this.

In godot's viewport, the camera is previewed as a square, so they appear the same size when viewed from the top: camera But in-game, they are likely different.

Calinou commented 4 years ago

@sdfgeoff By default, Blender uses Vert- FOV scaling, whereas Godot uses Hor+ FOV scaling when the camera's aspect is set to Keep Height (which is the default). See this page for more information on FOV scaling modes.

Unfortunately, Blender 2.80 didn't change this and still defaults to Vert- scaling, which isn't suited to modern games running in landscape mode. I'm not sure if Blender allows changing the FOV scaling mode, but even if it does, I'd advise against following the Blender setting as to not end up with more Vert- games in the wild :slightly_smiling_face:

As for the FOV conversion, we can convert the Blender camera FOV to something that matches a 16:9 aspect ratio. This is the default aspect ratio of Blender's rendering output, so it will likely match most people's expectations well. You can find vertical/horizontal FOV conversion algorithms here.