Skip to content
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

Improve .blend import performance by importing multiple .blend files at once with a single Blender call #5099

Closed
jgillich opened this issue Aug 7, 2022 · 3 comments · Fixed by godotengine/godot#69319

Comments

@jgillich
Copy link

jgillich commented Aug 7, 2022

Describe the project you are working on

Multiplayer FPS

Describe the problem or limitation you are having in your project

I use asset packs in my project which contain hundreds to thousands of models each in fbx format. I've found that using blender files is the easiest to work with, so I use a python script to convert the fbx format to blender. This script processes all files at once and takes only a few minutes for hundreds of files.

Then I add the resulting blend files to my Godot project. Unfortunately, Godot takes a very long time to import all the blender files, it's approximately 10-20x slower than my fbx->blend script. Reimporting all assets in my project takes approximately 2 hours. One time I accidentally moved one of my asset folders to another directory, which resulted in about an hour of wasted time spent waiting for the importer.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The Godot blender importer calls blender on the command line with a script that converts a single file. This means that for each file, we have to wait for blender to start up and then convert the file to gltf. My assumption is that the vast majority of the time is spent waiting for blender to start up, rather than the conversion of the file. Therefore, significant speed ups could be achieved by modifying the importer in such a way that it processes all blender files at once, with only a single call to the blender program.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The blender importer should be updated so that it accepts multiple files and generates a python script that converts all of them in a single step.

Alternatively, we could launch a single blender instance and handle communication with the importer via rpc.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

It improves a core feature

@Calinou
Copy link
Member

Calinou commented Aug 7, 2022

Godot's import system is designed to have a 1:1 mapping between the source files and imported resources, so I'm not sure how this can work without a lot of special casing for .blend. In other words, you can't have the editor perform the import process for one resource and expect it to create several resources at once.

I've found that using blender files is the easiest to work with, so I use a python script to convert the fbx format to blender. This script processes all files at once and takes only a few minutes for hundreds of files.

Out of curiosity, why not convert FBX to glTF directly in this case?

@jgillich
Copy link
Author

jgillich commented Aug 7, 2022

In that case we could explore the RPC option, where we launch a single blender process and use Python's built-in xmlrpc module to communicate with blender: https://ciesie.com/post/blender_python_rpc/

Out of curiosity, why not convert FBX to glTF directly in this case?

Because I want the ability to edit the models, and that's easiest when they are already in blender format.

@Zireael07
Copy link

Godot's import system is designed to have a 1:1 mapping between the source files and imported resources

How does "batch importing" the OP asks for break the 1:1 mapping? 😕

@Calinou Calinou changed the title Improve blender import performance Improve .blend import performance by importing multiple .blend files at once with a single Blender call Sep 9, 2022
@akien-mga akien-mga added this to the 4.0 milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Implemented
Development

Successfully merging a pull request may close this issue.

4 participants