Godot: MeshLibraries don't preserve editor-created materials

Created on 3 Dec 2018  路  14Comments  路  Source: godotengine/godot

Godot version:

3.0.6 (self-built from commit 8ac39d886307d76c286e804e027fc39f6b5aaac6)
master (commit 8dd00ed1762c4956b3231d709ce0d01ee9b306c8)

OS/device including version:

Arch Linux (4.19.4-arch1-1-ARCH, Mesa 18.2.5-1)

Issue description:

Materials on editor-created meshes are not preserved in a MeshLibrary created via "Convert To -> MeshLibrary". It sounds very similar to what was happening in #1239, but I'm not sure it's the same issue.

Steps to reproduce:

  1. Create scene with a root node and a child MeshInstance where mesh is created via "New PlaneMesh"
  2. Create a SpatialMaterial for mesh, set Albedo to (255,0,0)
  3. Save scene, then "Convert To" -> "MeshLibrary..."
  4. Create GridMap in new scene, using the MeshLibrary created in Step 3 as theme.
  5. Place the plane on grid

Expected: A red plane
Result: A white plane

Minimal reproduction project:
gridmap_material_issue_example.zip

* Additional Information: *
master build printed out the following after executing Step 3:

ERROR: create_from_image: Condition ' p_image.is_null() ' is true.
   At: scene/resources/texture.cpp:191.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: _write_resource: Resource was not pre cached for the resource section, bug?
   At: scene/resources/scene_format_text.cpp:1369.

And the following after Step 4:

ERROR: create_from_image: Condition ' p_image.is_null() ' is true.
   At: scene/resources/texture.cpp:191.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
ERROR: texture_get_data: Condition ' !texture->active ' is true. returned: Ref<Image>()
   At: drivers/gles3/rasterizer_storage_gles3.cpp:1033.
bug editor

Most helpful comment

Love Godot, but this issue, while having workarounds, is still and issue. I don't see why it has been closed either.

All 14 comments

From what I remember from past issues/discussions, this is caused by the MeshLibrary collecting the Mesh resources, which do not contain the overridden Materials.
There are two main ways this might be solved in:

  1. Add material overrides to the MeshLibrary (and respectively, to the GridMap). This might also mean adding them to MultiMeshInstance as well. While this is probably the best solution, it is likely to take some effort to implement.
  2. Duplicate and change the Mesh resource if material overrides are detected, else continue as normal. As this will result in duplication of the Mesh (which is potentially a huge resource), this is probably a bad idea.

Can confirm as well.

Godot 3.1 beta1

Seems the same problem I'm having.

What I did was:

  • Imported a scene from a gltf file.
  • saved an inherited scene and added material
  • created another scene with GridMap node
  • created a MeshLibrary and imported from the inherited scene
  • the materials I created where not imported
  • manually added the materials directly in the MeshLibrary nodes as per image below
    image

  • updated from scene removed again the materials, see below
    image

Can confirm this is still an issue on 3.1 beta2

This is still an issue in 3.1 beta 3. Is anyone working on this? It seems like a pretty important bug for the 3d workflow.

This is still an issue in 3.1 beta 3. Is anyone working on this? It seems like a pretty important bug for the 3d workflow.

For now I found a workaround:

  • if you select your model .dae or .gltf, or any other compatible format, change your preset so that imports as separate objects+materials (not sure if materials is necessary)
    image

  • then in the inherited scene change the material for each mesh (I also saved them as a separate file), do not use override material
    image

If you then import into the GridMap you should have those materials, I think this is the same think @bojidar-bg was mentioning above.

Clarified this in documentation here:
https://github.com/godotengine/godot-docs/commit/f118ce32137ba57174def4e0e8290e11a3e85c9c
Also, errors shown before no longre happen, so closing this.

I don't see why this has been closed. I just started getting into Godot and this is a huge turnoff. I really don't fancy creating ten meshes that are exactly the same just because I want to use the same cube with a different texture in my gridmap.

Love Godot, but this issue, while having workarounds, is still and issue. I don't see why it has been closed either.

@meowxiik Wasn't this solved by https://github.com/godotengine/godot/pull/25522? If so, it may be a matter of documenting it more clearly.

@Calinou Huh I see. It still happens to me but I've been able to figure out a relatively unpainful workaround, so I don't really mind it anymore.

@meowxiik How does the workaround work? Maybe it could be documented :slightly_smiling_face:

@Calinou My approach was similiar to @Toshiwoz, except simpler:

DO NOT ACTUALLY USE THIS, I have just discovered changes made like this do NOT survive project reload. See the bottom for more details.

  • Select the MeshLib in FileSystem:
    image

  • Manually edit the items in the MeshLib
    image

All scenes containing this MeshLib update immidiatelly. So the fact it doesn't save is maybe a bug? Or if that is intended, one of those image would be handy. (My build of Godot is v3.1.1 Mono Stable Official)

I understand concerns about closing this issue. But strictly speaking this one is solved.
The problem is more the improvements needed to the feature in general, and AFAIK it will be worked on, I hoped on 3.2 but may be delayed, depending on volunteers will, and patreons + community votes (perfectly fine for me).
I abandoned completely the use of this feature for now as I found using procedurally generated mesh more fit to my project.

Was this page helpful?
0 / 5 - 0 ratings