Animating the albedo of 1 material w/o affecting those of other materials

Hi,

Using Unity 5.2.2.
I have an object with two materials on it (and some objects with even more materials on them).
Both use a standard shader.
I started animating the albedo of the object’s first material, in its main maps.
But it affects the albedo of the other material too!

Is there a way to animate the albedoes separately? Preferably without scripting?
Or do I need to use a special shader, say a custom one that’s like the standard one, but tweaked with one little option that allows for animating albedoes independently?

The problem is quite annoying. CTRL+Z doesn’t even recover the original albedo values once I started recording value changes in the anim file.

Help!

Some ideas.
=> First you should do animation on “material instance”, NOT “material”. What you modify on “material instance” will NOT be saved after your next time play. And will NOT other material instances.
=> More specifically say, use " renderer.material.Set*** " instead of " renderer.sharedMaterial.Set*** " in your script.

Does that mean if I have a bunch of objects that are a single prefab and share the same material that I could make a script for the prefab that at the start of the level replaces the material with a material instance and tweak the albedo color to something unique to this objects instance? E.g. I want to place a bunch of shipping containers and I want them to randomize their color themselves at runtime.

Right, just need a single line of script " renderer.material.SetColor (“_Color”, randomColor) " will be enough.

1 Like

Awesome, thanks a lot! I’ll try that.

Works like a charm :). This prevents batching though, right? I’m thinking I’ll just put it on the prefabs that are used most often and if I feel a need to optimize drawcalls later that would be an easy thing to revert.