Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Materials Not Honoring Local to Scene #71406

Closed
SoapSpangledGames opened this issue Jan 14, 2023 · 3 comments · Fixed by #71578
Closed

Materials Not Honoring Local to Scene #71406

SoapSpangledGames opened this issue Jan 14, 2023 · 3 comments · Fixed by #71578

Comments

@SoapSpangledGames
Copy link

Godot version

4.0 Beta 10

System information

Kubuntu 18.04, Forward+, NVIDIA GeForce GTX 1660

Issue description

I have a model created via Blender, exported from Blender as a GLTF file, and imported into Godot as a local copy.

There is a set of materials in the mesh, with each material intended to display a different texture, and each material in the set is flagged as "Local to Scene".

I create multiple instances of this mesh, and set each material set to a different set of textures. Setting the individual textures within the mesh works fine, but each instance of the mesh displays the same set of textures. This shouldn't happen with each material set as "Local to Scene". Each instance should display a different set of textures.

Steps to reproduce

I've added an MRP to demonstrate the issue. Each flattened cube has two materials, which each material flagged as "Local to Scene". Each instance of the cube shows the exact same textures, though all instances are given unique textures. What is displayed is the set of textures assigned to the last cube instance.

Minimal reproduction project

materials.zip

@RedMser
Copy link
Contributor

RedMser commented Jan 17, 2023

Same cause as #71243, since a mesh's surface information is stored in an array of dictionaries _surfaces[*].material.

As a workaround, you can use:

func setText(nIndex : int,image):
	var mat : StandardMaterial3D = m_mesh.get_active_material(nIndex).duplicate()
	m_mesh.set_surface_override_material(nIndex, mat)
	mat.albedo_texture = ImageTexture.create_from_image(image)

@Calinou
Copy link
Member

Calinou commented Jan 17, 2023

Duplicate of #71243 (same cause).

@SoapSpangledGames
Copy link
Author

Thank you. That works beautifully!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants