public void UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(Material material, float intensity)
{
const string kEmissiveColorLDR = "_EmissiveColorLDR";
const string kEmissiveColor = "_EmissiveColor";
const string kEmissiveIntensity = "_EmissiveIntensity";
Debug.Log("11");
if (material.HasProperty(kEmissiveColorLDR) && material.HasProperty(kEmissiveIntensity) && material.HasProperty(kEmissiveColor))
{
//重要:kEmissiveColorLDR的颜色选择器是LDR并且是在sRGB颜色空间中,但是Unity不会在颜色中执行任何颜色空间转换
//只有在将颜色数据发送到着色器时才进行选择…因此,当我们在c#中进行自己的计算时,我们必须自己完成转换
Color emissiveColorLDR = material.GetColor(kEmissiveColorLDR);
Color emissiveColorLDRLinear = new Color(Mathf.GammaToLinearSpace(emissiveColorLDR.r), Mathf.GammaToLinearSpace(emissiveColorLDR.g), Mathf.GammaToLinearSpace(emissiveColorLDR.b));
material.SetColor(kEmissiveColor, emissiveColorLDRLinear * intensity);
material.SetFloat(kEmissiveIntensity, intensity);
}
}
借鉴大神帖子https://blog.csdn.net/qq_38062606/article/details/129105389
最后加了material.SetFloat(kEmissiveIntensity, intensity);才有效果
改变材质其他值可以点击材质右上角SelectShader查看其他关键字