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:
- 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..
- Specify shader parameters before each object is rendered, basically a sort of OnPreRender but at object scope rather than camera scope?
Thanks :)