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.49k stars 317 forks source link

fps_base is not respected in exported animations #2024

Closed Shinmera closed 9 months ago

Shinmera commented 1 year ago

Describe the bug Hi, I have a model file that was created, rigged, and animated in Blender. In Blender itself the animations play back fine, and the animations are configured for 60fps. However, the exported gltf or glb include the animation keyframe timestamps slowed down by a factor of 10, meaning animations play back 10x slower than they should.

I can verify that the timestamps emitted into the gltf/glb are slowed by this factor, so it's not anything on the gltf/glb decoder. I've also verified that they are indeed slow in the 3rd-party f3d viewer.

I've tried to look for anyone else with this issue but can't find anything. I've looked through all export settings, but can't find anything relevant. Animation sampling is on and the sampling rate set to 1. (Incidentally, if I turn animation sampling off, it errors out)

Is there some Blender setting that could be causing this that I'm missing? As mentioned, the animations play back in the expected time scale in Blender itself, so I'm not sure where else to look.

.blend file/ .gltf The model files are unfortunately for a private commercial, so I cannot share them publicly with you.

Version

julienduroure commented 1 year ago

Hello,

glTF stores animation data in seconds. Conversion is done using this value : bpy.context.scene.render.fps

Sorry, but without any test file, I can't investigate it. Maybe you can try to replicate the bug in another file, or removing sensible data

Shinmera commented 1 year ago

Oh, it seems that bpy.context.scene.render.fps was set to 6 instead of 60 when viewed through the console. In the UI Scene > Format > Frame Rate was set to 60 though. How odd, is there somewhere else that property is accessible in the UI?

julienduroure commented 1 year ago

Quite interesting!

You should be able to find it here: image

Do you have multiple scenes in your .blend file ?

Shinmera commented 1 year ago

Yeah that's the UI I was looking at, but it displayed as 60fps before. After changing bpy.context.scene.render.fps through the console, it displayed as 600fps, so I switched it to 60 in the UI again and now both the UI and the property seem in agreement.

There's only one scene in the blend file.

julienduroure commented 1 year ago

Quite strange. This is maybe a bug in Blender itself, not in this addon. If you are able to delete all content and share your file, I can have a look (or open a ticket on Blender side)

Shinmera commented 1 year ago

weiss.zip

Here's the minimised file, and a screenshot to prove I'm not going crazy:

2023 10 13 15:10:18

julienduroure commented 1 year ago

I can reproduce. Your bpy.context.scene.render.fps_base is 0.1, explaining the factor I am now able to reproduce this behaviour, changing these data from console. Not reproducing it when trying to tweak UI.

Anyway, I will have to fix this addon code, by taking the fps_base into account too

Shinmera commented 1 year ago

Ok, good to know. I wonder how that factor got changed, though, given that the UI field only seems visible when the frame rate is set to Custom? Well, a mystery for another time :)

Shinmera commented 9 months ago

Thanks for your work!