• Godot Help3D
  • Mesh loses material overrides everytime it is updated externally or re-imported

Scenario

  • Mesh is originally imported with some base materials. For example, this is a sample mesh from Kenney's car pack:

  • Create a New Inherited Scene and override some of these surfaces with custom Materials. The materials are saved resources.



Problem

  • Godot resets my material overrides when the mesh vertices are updated externally, for example, on Blender, but even worse, and this is the red flag: when the mesh is re-imported, for example, after cloning the saved project from the repository all overrides are lost - even although the material overrides were MADE IN GODOT AND WERE COMMITTED to the repository (i.e. the scenes and resource files were saved).

  • If I override the Material directly instead of the surfaces, the same issue happens

Solution

How to solve this? Or how to avoid this, considering it's perfectly mandatory to be able to update meshes while keeping overrides.

This is not the 1st time, in truth, I've been facing this since I've started using Godot since 3.1 and made some Ludum Dare games with it, but I considered the situation "ok and acceptable" and I would always re-insert my materials.

Now I'm starting to place dozens of meshes and this is getting out of control, because it makes impossible to keep the integrity and consistency of the project.

  • So in Blender, make sure all materials have unique names. Then export for glTF with separate mesh + material + texture. In Godot, this will create YourMaterial.tres on the initial import (for each material). On the import tab for the model, make sure keep materials is on (I believe this is the default). Then when you load the same model again or reimport, it should keep your changes to the saved *.tres files for each material. I'm pretty sure this works, but it's also a horrible workflow. I would suggest maybe making a bug report or feature proposal to make this workflow a little more obvious (even if it's just an update to the documentation).

Materials are not reimported when you reimport a model (only the model is). So you can click on a material slot (on the surface of the mesh) then save it, and edit it. It will remain when you reimport.

    cybereality But this is the issue that I describe in my topic. I'm actually losing my custom materials that are defined in Godot. Upon mesh re-import Godot overrides everything.

    I import the mesh, add a custom material to it, save, commit, etc. If the mesh is re-imported, everything is reset.

    There are different types of material slots, you are talking about overrides, @cybereality seems to be talking about the mesh material itself that the override overrides, I assume.

    Yes, I think the GeometryInstance Material Override is not overwritten. It's kind of confusing.

      cybereality but then how it works in a mesh with multiple materials?

      1. If I override it in Mesh -> Surface X, my changes are lost upon a re-import.
      2. If I override it in MeshInstance -> Material X, changes are also lost
      3. Then, in the GeometryInstance.MaterialOverride I have access to only one material, then the whole mesh has to keep this single material.

      So in Blender, make sure all materials have unique names. Then export for glTF with separate mesh + material + texture. In Godot, this will create YourMaterial.tres on the initial import (for each material). On the import tab for the model, make sure keep materials is on (I believe this is the default). Then when you load the same model again or reimport, it should keep your changes to the saved *.tres files for each material. I'm pretty sure this works, but it's also a horrible workflow. I would suggest maybe making a bug report or feature proposal to make this workflow a little more obvious (even if it's just an update to the documentation).

        cybereality Thanks a lot. Definitely a horrible and confusing workflow - this kind of thing should work out of the box without the user thinking.

        I will gather a bit more information, and then I may even submit a PR fix to the docs myself (I have the "Unity to Godot" guide pending to submit a PR to the docs too).

        cybereality It solved the override re-import issue, but the materials are conflicting all over, always defaulting, ignoring my overrides.

        Oh well, I'll close this one.