godotengine / godot-proposals

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

Preserve material names when importing a GLTF file with "placeholder" materials #4343

Open timshannon opened 2 years ago

timshannon commented 2 years ago

Describe the project you are working on

A 3D FPS with levels exported from Blender to GLTF

Describe the problem or limitation you are having in your project

When working with materials from GLTF files they are referenced locally either via embedded data or absolute paths referenced from the GLTF working directory. This means if you have a material that is shared between two models in different directories, you either need to live with the fact that the materials are duplicated, or swap them out with the shared material via an import script.

I am opting from the latter option, which means ideally I'd export my GLTF files from blender with "placeholder" textures, as I don't need them. I do however need the material names, which still get exported to the GLTF file, even though the texture data isn't.

However these material names don't make their way into Godot. The material name is just blank.

GLTF File: image Godot: image

So when importing a gltf file or using the new Blender import feature with "placeholders" set for the materials, there is no way to determine what texture goes one what mesh surface. All of that information is lost.

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

Ideally the material names would just be preserved. I'm betting that during the GLTF import process, they look for the indexed material data, and it drops out early because there are no actual textures. It would be helpful not to use that information from the GLTF file.

This might be considered a bug, but it may also be an intentional choice, so I opened a proposal.

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

N/A

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

It can be worked around by exporting the materials even though they aren't needed.

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

This is about a slight change in behavior to the GLTF import feature.

fire commented 2 years ago

Since it is empty, I'd pick the one that's the most useful.

timshannon commented 2 years ago

So, in my work flow, during my scene import script, I try to match the name of the material in the GLTF import to an existing, already created material in my project. Not having the name basically means I need to set all of the materials in a scene, after setting them all in Blender.

This simplifies things even more so for me by taking advantage of the new blender asset library. I have an asset library per-configured with all of the materials from my Godot project, so when working in blender I just drag and drop the material from the asset library onto a mesh, and I know that my import script will swap the GLTF material out for a the proper Godot material.

Currently I have to export with textures and materials I end up ignoring. Not a big deal, but ideally you wouldn't lose this valuable information when purposefully choosing to use placeholders.

In creating the GLTF file Blender obviously chose to allow this option to skip the texture data, but preserve the material name. The GLTF file is still a valid GLTF file.

Calinou commented 2 years ago

We discussed this in a proposal meeting and choose to approve this proposal. It actually seems to be a bug rather than a missing feature :slightly_smiling_face: