Runtime Texture disappear when re-scaling another object?

Godot Version

4.4

Question

Strange thing happened. I have a dancer model instanced on the scene and made her local, then I overrided her materials. I ran the game and everything looks good.

When I re-scaling another object in that scene ( a sofa , painting, etc..totally unrelated to the dancer) my dancer texture still shows in editor BUT disappears at runtime.

  • I tried remade her local and overrided the texture again.
  • I tried delete and re-instance the dancer model.
  • I tried delete .godot folder.

None works. It will no longer show at run time no matter what.

Why would re-scaling an object in the scene affects texture override of another object? How to get texture to show again?

PS: Objects that I re-scaled have no collisionshape, only the mesh.

My dancer setup:

IN EDITOR


AT RUN TIME

INSTANCED AND MADE LOCAL

OVERRIDED MATERIAL

Well, it shouldn’t. Check the Debugger dock for some error and also check the mesh in the scene’s Remote tab and try and see if the material is the correct one.

I don’t think it has anything relates to texture.

From the remote tab it is empty.

I have no idea why. I ran the game a bunch of times before with no problem then I re-scale another object and the next game run the texture is gone.


If I changed the mesh name to something else then the texture is working again at run time.

So what I get from this is:

  • I have a local instanced scene with material override on it
  • Something happened
  • It no longer associates material override with that mesh name.
  • It will then use the mesh’s original material at run time.

My work around:

  • Keep changing the name of the mesh everytime it happens (LOL)
    OR
    Don’t use material override, just use the mesh’s original material.

EDIT** Actually I need the use material override for this since I want each duplicated scene to have its own material.

So I am still looking for a solution..

Where are you assigning the material? to the model’s own scene or to the mesh in another scene? If the color of the node is white it means that the node is local to that scene and any changes to the original scene won’t be applied.

Post more information because there’s not enough to know for sure where the problem is.

  • I imported dancer.glb from Blender using placeholder texture so the original mesh color is white, then I made inherited scene.

  • I imported 4 textures with same uv to the dancer.glb (each with different colors).

  • I then manually placed dancer.tscn into the Level.tscn, then I made her local

  • I clicked on her mesh and made sub-resource unique(from the Inspector’s little tools icon)

  • Then I manually overrided the material from Inspector menu

  • Copied and pasted dancer_01.tscn, ..02.tscn, ..03.tscn, made each sub-resource unique, then overrided material for each of them.

  • The whole Level.tscn is instanced by add_child() once the game starts.

So basically I assigned material to my ‘local’ duplicated dancer.tscn while I am in the Level.tscn.

Why are you making so many things unique? Why are you making it local? You don’t need to do that. Don’t make the scene local or the meshes unique as the data will be saved inside the scene itself making it grow in size and probably cause issues. You will also lose any modifications you do to the model afterwards as they won’t be propagated.

Just make an inherited scene from the glb file and use that inherited scene to make any modifications you need. If you need to modify something in any instance of that scene then: ideally, the inherited scene should have a small script taking care of that or, alternatively, enable Editable Children and make the changes there.

1 Like

I see. My dancer.glb has 4 animations for each of them so I just instanced one and duplicated it. I learn that to change material or animation of duplicated scene you’d need to make it local but I guess this is not an effective/efficient way of doing it (and possibly buggy).

** Actually now I’m a bit confused

I should now make 4 inherited dancer scenes and apply changes there instead(?) I would still need to make the mesh unique in order to change material, right?

Or I should make only one inherited scene and somehow script it to have different material with each instanced.

I guess basically my question is How should I instance 4 different dancers from the same dancer.glb with 4 animations, 4 external textures, and 4 external hair meshes?

UPDATE :
Well, I just have to follow your instructions and this is what I did:

  • make one inherited scene
  • attach script:
@tool
extends Node3D

@export var body_material : Texture
@onready var mesh = $A_BODY_FOOT_RIG/Skeleton3D/DANCEGIRL


func _ready() -> void:
	var material_one = mesh.get_surface_override_material(0)
	material_one.albedo_texture = body_material
	mesh.set_surface_override_material(0, material_one)
  • Instance it, edible children, then make each instance mesh unique
  • Change each instance’s export texture.
  • Change animation / Add bone attach hair mesh to each instance.

So far no issue, Thanks again

Where did you learn that? That’s wrong. There’s no need to make local the mesh itself. MeshInstance3D already has a way to override the Mesh materials with MeshInstance3D.set_surface_override_material() or under the Surface Material Override group in the inspector.

Unless you are modifying the Mesh resource itself (like adding/removing/modifying its vertices or something like that in code) you do not need to make the it unique.

Where did you learn that?

Just internet questions I came across - if you want different material for duplicated scene then make it local.

you do not need to make the it unique.

Then how do you apply different material to each instance? With that code If I don’t make the mesh unique then only one material will be applied to all instances.

You duplicate the Material itself (or make it local) not the Mesh resource or use per-instance uniforms if you are using a custom shader.

Do you mean @export material on each instance? They are already local to scene.



Also this weird thing:

This shows the properties of texture after I load the @export material. It stays like this after I run the game, click other object in the scentree ..etc.

BUT it changes to this after I click another tab and back.

Don’t know why it happens like that. Quite confusing and not sure if it matters.

That’s a texture, not the Material. Local to scene in this case does not make any sense and won’t work anyway.

So you meant this one: mesh’s surface material override? Sorry there are just so many local to scene option I’m not sure which one.

*** I guess it is 'cause it works

Yes, that’s the one. :+1:

1 Like

Thanks for the help!