Uniqe Shader Instance

newMorningKingdoMnewMorningKingdoM Posts: 59Member

Hi there,
i have multiple instanced objects that share the same shader (animated parameters with animationplayer node)
but as you guys can gues, when an events it happens (like get hit) animated shader play for every instance.
i did research for this and find it can be done for albedo colors, but not shaders.

is there a way the fix this? or another way to solve?
thank you for your time.


  • xyzxyz Posts: 204Member

    Try to make shader (or material) resource "local to scene". There's a checkbox under "Resource" section in the Inspector.

  • newMorningKingdoMnewMorningKingdoM Posts: 59Member

    @xyz said:
    Try to make shader (or material) resource "local to scene". There's a checkbox under "Resource" section in the Inspector.

    well i did, it did not work.

  • xyzxyz Posts: 204Member
    edited October 11

    If you're using shader material, try to set both resources (material and shader) local to the scene.

    I'm assuming your "instanced objects" are scenes. Otherwise making things local to the scene won't make a difference.

  • newMorningKingdoMnewMorningKingdoM Posts: 59Member
    edited October 11

    silly me, thanks its solved.
    i did notice after your answer that i did indeed check to box "local to scene" BUT , i did it on the instanced scene's material slot (enemy instance).

    after i reply your answer i thought why not, and reach the resource directly and check to box "local to scene" and it work. thanks.

    from here:

  • cyberealitycybereality Posts: 2,089Moderator

    That's good to know, I didn't realize that. Previously I was clicking on the resources (in the inspector) and clicking "make unique" which also works, but I guess this duplicates things unnecessarily.

  • xyzxyz Posts: 204Member

    Yeah, took me some time to actually grasp the difference. Making resources unique will make actual duplicates of shared resources. "Local to scene" just makes them "unique" in instanced scenes at runtime.

  • Erich_LErich_L Posts: 142Member

    Ohhh!! This helps me so much! I've been running this code on the ready func of each MeshInstance I wanted to make unique:
    var myMaterial = get_surface_material(0).duplicate()
    set_surface_material(0, myMaterial)

    I don't know why though the original resource would ever need to be duplicated, so I assumed this is just making it "local to scene." I wonder if this enlarged my used of "VRAM" if that's what it is.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file