Accessing current Material Emissive Scale?

Hello,

We’ve been working on a project that uses the standard Unity materials, and we’re having an issue with getting the current emissive scale (brightness). There are quite a few answers out there concerning accessing them already, but they don’t seem to answer our question.

Basically, we have some point lights and light bulb models underneath them, and we want to be able to control the color and brightness of both the light (easy to do) and the model (requires editing the material’s “_EmissionColor” property). We haven’t had any issues setting “_EmissionColor”, but we can’t get the value from “_EmissionScaleUI” since it is UI only.

Other solutions said to simply multiply whatever color we’re passing in by some float to scale the emissiveness, but how can we get the current emissive scale? If our lights are at a brightness of “0.5”, how do we access “_EmissionScaleUI” to get that value?

Thanks

I don’t know of any way to access that specific material property, but if you haven’t noticed, the brightness is just the highest value between the r, g, and b of your material’s emission color.

So, for example, if your material has a Color of (0.9f, 0.6f, 0.1f), the brightness (or emissive scale as it’s referred to behind the scenes) would be 0.9. You can see the brightness change in realtime in the editor if you change the emission color.

To get the current emissive scale of a standard material, just make a function similar to this and multiply the new color you’re assigning to “_EmissionColor” by the result:

In C#:

//Function to find the emissive scale of a material's color (the highest value out of r,g,b)
private float FindScale(Color color)
{
      return color.r < color.g ? (color.g < color.b ? color.b : color.g) : (color.r < color.b ? color.b : color.r);
}