Substance Instancing

I have a number of objects that are going to be instantiated at runtime.

All of them share a single material, a substance, and they have a script that should allow them to react to a mouse click by changing a parameter and getting the clicked object to glow.

What I do is, inside my update, after I perform my tests, I execute the following code:

Renderer rend = GetComponent();
ProceduralMaterial mat = (ProceduralMaterial)rend.material;
mat.SetProceduralFloat(“Glow”, 1f);
mat.RebuildTexturesImmediately();

BUT

When I do this, ALL of the instantiated objects begin to glow!

on the image below, only the A object has the script. sitll, both of them toggle when I click.

Please notice that simply creating a copy of the substance in design time is not an option, since I’m going to have an arbitrary number of objects spawn on each scene.

What am I doing wong?

You are probebly better of render both texture variants out and blend / switch between them using a shader on a per material base (instances).
If you are calling RebuildTexturesImmediately you are updating the texture and the texture is used in all the places the old texture was referenced.

Thanks for your answer.

Do I have any alternative to RebuildTextures (be it immediately or the async version)?

I’ll try to use the something else, rebuild my shaders in another environment, using only the maps from substance… but it kinda sucks. :slight_smile: