TSCN instances share shader

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By egore

I have a Object.TSCN containing a MeshInstance with a ShaderMaterial attached. The GDScript for the Object.TSCN looks like this:

extends Node

export(float) var a 0.0
export(float) var b = 0.0

func _ready():
	x.set_shader_param('a', a)
	x.set_shader_param('b', b)

The ShaderMaterial looks like this:

shader_type spatial;
render_mode blend_mix;

uniform float a : hint_range(0,1) = 0.5;
uniform float b : hint_range(0,1) = 0.5;

void fragment() {
	ALBEDO = vec3(0, 0, 0);
	ALBEDO += vec3(1.0 * a, 0.0, 0.0);
	ALBEDO += vec3(0.0, 1.0 * b, 0.0);
	ROUGHNESS = 1.0;
	SPECULAR = 0.0;
}

When I now use the editor to add two instances of Object.TSCN to my MainScene.TSCN and set the values of the first instance to a=0, b=1 and of the second to a=1,b=0 both ShaderMaterial will have their a=1 and b=0.

What do I need to do so two instances of the same TSCN can have independent shader parameters?

:bust_in_silhouette: Reply From: AlexTheRegent

Open Material in Editor and set “Resource/Local To Scene” to “On”.
From documentation:
If true, the resource will be made unique in each instance of its local scene. It can thus be modified in a scene instance without impacting other instances of that same scene.