Unity URP 光照着色器:一个 material 个不同的 'tinted' 个对象

Unity URP lit shader: One material different 'tinted' objects

我对着色器编程非常陌生,对修改 urp 光照着色器 以支持在运行时使用 MaterialPropertyBlock 在对象中设置属性感兴趣。

objective 是有几个 相同 material 'tinted' 且每个 不同颜色的对象.

谢谢!

我不懂着色器编程,但如果您想要共享一个 material 的多个对象使用不同的颜色着色,这样的脚本可能会起作用:

public class Tint : MonoBehaviour
{
    public Color TintColor;

    [Range(0,1)]
    public float TintIntensity = 0.5f;
        
    private void OnEnable()
    {
        Material material = GetComponent<MeshRenderer>().material;
        material.color = Color.Lerp(material.color,TintColor,TintIntensity);
    }

}