godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.08k stars 69 forks source link

Create an official Blender add-on for Godot asset pipeline #6883

Open RedMser opened 1 year ago

RedMser commented 1 year ago

Describe the project you are working on

Any 3D project using Blender for asset creation

Describe the problem or limitation you are having in your project

Supersedes #2422

Note that "add-on" refers to Blender's add-on system, and not Godot's EditorPlugins.

As already mentioned in that issue, many features of Blender do not get imported into Godot. Some examples are physics settings, camera/light settings, shader node setup, or splines. This is due to the glTF exporter not supporting such features, and .blend files are imported through the glTF pipeline.

Furthermore, certain options are Godot-specific and are not even part of Blender's UI, such as LOD settings or enabling collisions. These must currently be configured using the Advanced Importer or via import hints in object names.

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

The goal is to

This is done by creating an add-on for Blender that can be enabled by the user when desired. The add-on would be responsible to extend the glTF exporter, as well as showing additional UI elements.

The add-on will need to be installed by Blender users by hand (with Godot notifying the user when this add-on is not found). This process will be simplified once Blender ships its built-in extension repository, working similar to Godot's AssetLib. When the .blend file importer runs, it will hint Blender to enable that specific add-on (if installed), to ensure that this metadata gets imported. Possibly show a warning if metadata is found in the .blend file, but the add-on is not installed.

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

Create a new git repository which is a Blender add-on.

The glTF exporter can be extended by exposing a glTF2ExportUserExtension. GLTF import hooks can be added that can run code to add metadata. Either extras or extensions can be used to store this metadata in the glTF. Here's a short overview between the differences. IMO, an extension would make the most sense, if this becomes the official Blender integration path for Godot.

Any features that are already standardized through other extensions, such as OMI_physics_body etc., should be reused instead of redundantly recreating them in the Godot-specific glTF extension.

The user interface can be extended by adding new properties to the corresponding properties pages (e.g. Object, Light, ... properties). For file-wide settings, a new panel can be added to the Scene or Output properties page. Where possible, re-use Blender's existing settings instead (such as eevee's shadow settings for lights).

Compatibility must be ensured, so that different combinations of Godot versions and add-on versions can properly import asset metadata.

Not sure how to handle unsupported object types, like Curves. I will create a prototype to see if the currently existing hooks are enough to make this possible, or if we need to implement such a hook in the glTF add-on.

I believe that if you opt into using the add-on, the Advanced Import dialog is no longer necessary for supported options. The ideal solution would be to grey out all settings in this dialog that are managed by the add-on, with a hint text informing the user to use Blender to modify these settings instead. Alternatively, we would need an option for Blender to load the .import files to synchronize Godot changes back into Blender. This can probably not be done automatically, but is instead done via a button. Import hints like -col etc. should be ignored as well.

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?

Debatable, so please discuss!

IMO, by making this official, it greatly reduces the friction of the import pipeline for 3D assets. Making this official will guarantee support and compatibility with new features that both softwares have in common. The .blend file importer must also be modified if this were to be implemented as a Godot add-on.

aaronfranke commented 1 year ago

As a concept I wholeheartedly agree, but let's take our time with this, implementing it over many years. We'll likely want to have Godot-specific extensions for information highly specific to Godot, in fact we have already reserved the GODOT_ vendor prefix. However, if we can have more information in a format that's portable between engines then that's ideal, and have a minimal amount of information in a Godot-specific format.

Some examples are physics settings, camera/light settings ... or enabling collisions

Cameras are part of the base glTF spec. Lights are covered by KHR_lights_punctual.

Physics is covered by OMI_collider, OMI_physics_body, OMI_physics_joint, soon OMI_physics_material, and eventually some OMI extensions for vehicles and wheels (I see you're aware of OMI_physics_body already).

Note that we could still make a GODOT_ extension that sits on top of OMI_physics_body if we wanted to have more Godot-specific data like damping, sleeping, contact monitor, etc, and other apps would still be able to load the OMI_physics_body data even if they don't support the GODOT_ extension. However, we should only do this if we think it's necessary and helpful and will stand the test of time. Just the OMI specs should be good enough.

shader node setup, or splines ... such as LOD settings ... or via import hints in object names.

These might be good candidates for a specific GODOT_ extension, but I'm not an expert in these so I can't say for sure. If there is a way to specify shader nodes, splines, LOD, animation looping, navigation meshes, etc in a generic way we should do that.

I believe that if you opt into using the add-on, the Advanced Import dialog is no longer necessary ...

It will still be available of course, but the goal here is to allow as many things as possible to work without it, since we should be able to transfer any data we want from Blender via GLTF and there will be no need to tweak things in the advanced import dialog.

The ideal solution would be to grey out all settings in this dialog that are managed by the add-on, with a hint text informing the user to use Blender to modify these settings instead.

I disagree with this part, there is no need to prevent overriding what's in the file if you want to do so. The data in the file is optional, you should not be forced to use it. Keep in mind that you might now have Blender installed and want to tweak a model later, or maybe someone else made the model and just sent you the GLTF file.

Alternatively, we would need an option for Blender to load the .import files to synchronize Godot changes back into Blender. This can probably not be done automatically, but is instead done via a button.

That sounds like a separate thing though, making Blender read Godot's import config files isn't required to make Blender add more data to the GLTF file and have Godot read it.

Import hints like -col etc. should be ignored as well.

Disagree, it's harmless to keep it, I don't see any strong reason to disable that feature.

Is there a reason why this should be core ... Debatable, so please discuss!

Indeed, that's the big question. It totally does not need to be in the engine, the only reason we would do that is to encourage it as the official way since users would not have to hunt down an extension. However, considering that users would already have to hunt down a Blender extension maybe it's not a big deal. Though it may be the case that the user providing the GLTF files from Blender is a different user from the one importing into Godot.

If we do have GODOT_ prefix extensions, those should be maintained inside the Godot organization, either in the engine or a separate repo we put up officially on the Asset Library, not on someone else's GitHub account.

RedMser commented 1 year ago

@aaronfranke Thanks for the detailed feedback!

let's take our time with this, implementing it over many years

We can start with extensions that already exist and are standardized (such as colliders like you mentioned), but lack support from Blender's exporter. TBF, I don't know what Blender's own stance is on which extensions the glTF exporter ships with (only KHR_*?). Might be worth discussing this as well, so that we don't work on something that Blender will later support out of the box.

Note that we could still make a GODOT_ extension that sits on top of OMI_physics_body if we wanted to have more Godot-specific data like damping, sleeping, contact monitor, etc

According to the spec, it seems like it is possible to extend an extension. So we could indeed piggyback specialized fields onto a general purpose extension.

there is no need to prevent overriding what's in the file if you want to do so

Right, if we can keep track of changes in the dialog as overrides, instead of always preferring the glTF metadata over what the user modified in Godot, it can work. I only had the .blend workflow in mind, but indeed exporting .gltf's is just as valid of a use case!

making Blender read Godot's import config files isn't required to make Blender add more data to the GLTF file and have Godot read it.

True, but it would be nice to have the option of keeping both UIs in sync. Not necessary for an MVP.

Disagree, it's harmless to keep [-col etc.], I don't see any strong reason to disable that feature.

How would conflicting values get handled? Or would the import hint always take priority over corresponding glTF metadata?


Regarding core or not: It might be convenient to have all general purpose extensions like physics be part of core, since those may be found in all kinds of glTF assets, and we already support some extensions out of the box (again, should we only stick to KHR_* extensions here?). But the Godot-specific stuff, including Blender add-on and the extension specifications, might be better off on the AssetLib. The source files should be on the Godot GitHub organization for sure.

fire commented 1 year ago

I support the creation of a godot engine organization repository for an update Godot Engine export / import addon. We described using gltf extensions. We can also design the feature in the proposal repo.

Note: I registered the GODOT_ extension for cases like this.

The gltf io blender addon will not add other extensions unless they're an official khronos gltf extensions.

This is on @reduz 's wish list but I wanted critical mass of contributors <3 and now we have it.

https://github.com/KhronosGroup/glTF/pull/2147#issuecomment-1548851270 can be used for replicating godot engine's animation player