I cant duplicate my shaders

I got a problem trying to use a shader for an hover animation, i tried to duplicate the shader, but the changes are in all the objects:
const FAKE_3D = preload(“res://global/shaders/fake3D.gdshader”)

func _ready()-> void:
array_creatures = # Inicializamos el array de criaturas
player = Player.new()
# Iteramos sobre todos los hijos del contenedor de cartas
for child in get_children():
var card_ui := child as CardUI
var new_shader = FAKE_3D.duplicate(true)
card_ui.parent=self
card_ui.reparent_requested.connect(_on_card_ui_reparent_requested)
#Aplicamos un material a cada carta para probar el hover PASAR AL DECK ESTO ES UNA PRUEBA
card_ui.container.material.shader = new_shader
Maybe if i duplicate the material instead it will fix it? How can i create a new material from code with that shader?

I think the problem here is that you duplicate a .gdshader not a shader material. You should insted, create a shader material ressource, add it your fake3D.gdshader and duplicate the shader material.

1 Like