Anyway to stop 3D Shaders effecting all objects with same shader and only effect one object.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dodgetgo
:warning: Old Version Published before Godot 3 was released.

I made a Shader for when you hit a 3d object it turn white and return smoothly to its old texture colors.

Here is the Shader Script in the Material Override.

uniform color col;
uniform texture source;
uniform float val;

DIFFUSE = tex(source, UV).rgb + (col.rgb * val);

and in the fixed Process of my objects is this

if(hit):
	_hit();
get_node("Body").get_material_override().set_shader_param("val",hit_timer);

hit_timer is set to 1.

When hit by the Player all objects light up and it only reacts if i hit the last object on the list.

anyway around these issue?

:bust_in_silhouette: Reply From: Akien

As I answered on the Discord chat, the material override resource is by default shared between all instances of the object.

To prevent a change from affecting all objects, that specific instance therefore needs to get a duplicated resource. In the editor it can be achieved via the “Make resource unique” option, and in script:

var mat_override = get_node("Body").get_material_override().duplicate()
mat_override.set_shader_param("val",hit_timer)
get_node("Body").set_material_override(mat_override)