Changing material properties on one object changes all others

I have a fadeout script to change the material properties when something blocks the screen. I want the objects to fade individually but when a new object fades, all the others also start the fade again or start fully faded out immediately.

The Docs say changing material properties using renderer.material creates a new instance of the material, but the behaviour I see points to them still being the same instance.

The material is a simple unlit ghader graph and here’s the Coroutine I use to fade the object:

IEnumerator TransitionTransparency ()
{
    _renderer.material = _transparentMat;
  
    float transition = 1;
    while (transition > 0) {
        _renderer.material.SetFloat("_Transition", transition);
  
        transition -= Time.deltaTime / _transitionTime;
        yield return null;
    }
  
    Destroy(_renderer.material);
    _renderer.material = _transparentMat;
      
    yield break;
}

So after trying out a few things I found the solution.
Leaving it here for anyone having a similar issue in the future.

The problem is with how shadergraph shaders handles non-exposed properties by default.
If you want to have a non-exposed property that can be changed for every material instance you have to enable “Override property declaration” and set “Shader Declaration” to “per material” in the property settings.

I’d recommend Material Property Blocks. It is a class that you can set to almost every renderer and it will override the renderer’s shader properties.

For Instance, here is a script that I wrote for tweaking the _Fade property using DOTween.

using DG.Tweening;
using UnityEngine;
using UnityEngine.Events;
  
public class Interactable : MonoBehaviour, IRaycastEnter
{
    [SerializeField] protected MeshRenderer mR;
    protected MaterialPropertyBlock mPB;
    protected Vector3 StartScale;
  
    protected float tw = 0;
  
    protected virtual void Awake()
    {
        mPB = new MaterialPropertyBlock();
    }

     // This isn't the whole script but I think that would be enough to show how it works.
    public virtual void OnRaycastEnter()
    {
        if (!interactable) return;
  
        //throw new System.NotImplementedException();
        if (flashTW != null) flashTW.Kill();
        flashTW = DOTween.To(() => tw, x => tw = x, 1, .22f)
                .OnUpdate(() =>
                {
                    mR.transform.localScale = StartScale * (1 + (tw * scaleMultiplier));
                    // This is the Material Property Part, first you get the property block from the renderer.
                    mR.GetPropertyBlock(mPB);

                    //Then you tweak the values in the Material Property Block
                    mPB.SetFloat("_Fade", tw);

                    //Finally you set the property block of the renderer
                    mR.SetPropertyBlock(mPB);
                });
    }
}

For anyone wondering what @consumedman is talking about

As of Unity 2023.2, The "Override property declaration” is located here:

For anyone wondering what I was making, It’s called a Toon / Cel shader which I’ve replicated from here