Different shader parameters for instances of a material

We have multiple instances of a vehicle prefab in our scene (set up very similarly to the vehicle tutorial), and of course each of these share materials, being based on the same prefab.

As in the vehicle tutorial, the brake light system currently sets and intensity parameter on the shader set on the lights material in the OnUpdate function:

if (controls.ThrottleInput < 0.0f)
{
    brakeLights.SetFloat("_Intensity", Mathf.Abs(1.0f));
}
else
{
    brakeLights.SetFloat("_Intensity", 0.0f);
}

Unfortunately, since the OnUpdate is called per vehicle, and the shader parameters shared across all instances since they use the same meterial, by the time the object is rendered, the parameter is set to the last calculated value. Is there a way to either:

  1. Set shader parameters differently on material per object that uses them (having a different material for this makes no sense, defeats the point of a prefab) or..
  2. Specify shader parameters before each object is rendered, basically a sort of OnPreRender but at object scope rather than camera scope?

Thanks :)

Don't store brakeLights as a reference to a material. Just store a reference to the Renderer, and use Renderer.material.SetFloat on that. That will automatically instance the materials. (The alternative to Renderer.material is Renderer.sharedMaterial, which would yield the same results as storing a reference to a Material, as you did.)