Unable to reuse existing materials
OS: Arch Linix
Godot version: 3.2.1
Blender version: 2.82
Plugin version: 61dfeb1b35e45c77a3b80b3ee1c362b7af597681
Issue description:
Looking for existing materials with the same name is broken. For example, I have a Materials folder with Wood.tres and Stone.tres inside. If I export a model whose materials have the same names, existing materials (from the Materials folder) will not be applied even if Material Search Paths is Project Directory.
Minimal reproduction project: Model for testing: Bonfire.blend Example project: Export.zip
Steps to reproduce:
Open Bonfire model from above in Blender and export it as .escn to the root of the project above with Material Search Paths set to Project directory (default).
Actual behavior:
Existing materials not assigned. I also tried Generate external materials but it will just create new materials in export folder.
Expected behavior:
Wood.tres and Stone.tres be used from the Material folder.
@Shatur95 the exporter only looks for materials with a .tres extension.
Note that .material files are binary and .tres files are text, so you can't just change the extension on your .material files. You need to create a new material with the .tres extension and copy the params.
I suppose it wouldn't hurt to search for $material.res and $material.material too. Thoughts?
I suppose it wouldn't hurt to search for $material.res and $material.material too. Thoughts?
It would be nice. Maybe such thing even should be implemented on Godot side to use GLTF 2.0 with the same behavior.
Ah, the exporter actually opens the material file to figure out what type it is. It seems the type is necessary in the .escn file, to generate lines like:
[ext_resource id=1 path="new_spatialmaterial.tres" type="SpatialMaterial"]
[ext_resource id=2 path="new_shadermaterial.tres" type="ShaderMaterial"]
I'm not actually sure why type is necessary (the scene loads fine if I remove it). Still, it seems preferable to support text-based resources (is there a compelling reason for binary-serialized materials)?
The problem comes from the fact that Godot's importer recreates the materials externally if that's what it's asked to do, regardless of your Blender export settings. One way to avoid this is to change your scene's import setting materials/storage to Built-In within Godot.
As noted by @rcorre though, it seems like this feature only works with .tres materials as of now.