Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DaddyMonster |
The situation:
I’ve got a 3d model with many meshes which I originally imported with glTF (with materials) and set as a scene. I decided to change one of the many MeshInstances so, to avoid starting from scratch, I made a new model for the mesh in question, exported from blender as a obj and added that as a mesh (ArrayMesh) to the relevant MeshInstance. The new mesh has three surface materials. I made new materials in Material Maker, added them manually and converted them to ShaderMaterial.
The issue:
Even though the mesh’s surface materials are ShaderMaterial in the editor (and in Remote during runtime) and are rendered as the desired ShaderMaterial in the game, when addressed in code it returns as a SpatialMaterial.
That is to say: print(obj.mesh.surface_get_material(0))
returns [SpatialMaterial:2061]
Obviously, obj.mesh.surface_get_material(0).set_shader_param("foo", true)
throws an error, no function set_shader_param
on SpatialMaterial.
I’m certain I’m addressing the right object.
Remedies tried:
Reimporting the mesh / making a new MeshInstance node / making the shader material unique and saving it. It always remains a Spatial when addressed in code but appears as Shader in editor.
Is either the .mtl
or .glTF
file somehow acting in the background here but only in code?
Anyone know what’s going on?