• 3D
  • Uniqe Shader Instance

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.

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

@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.

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.

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:

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.

@cybereality 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.

5 days later

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.