Shader Graph自定义渐变色节点Gradiant

Shader Graph自定义渐变色节点Gradiant

Unity自带Shader中的Gradiant不能暴露在外部

image-20240918140246465

使用定义CustomFunction来制作暴露给外部的Gradiant

image-20240918140416457

ShaderGraph节点图

image-20240918140511913

CustomFunction代码

   if(inputValue<location1)
        {
            outFloat = color1;
        }
        else if(inputValue<location2)
        {
            float pos = (inputValue-location1)/(location2-location1);
            outFloat = lerp(color1, color2, pos);
        }
        else if(inputValue<location3)
        {
            float pos = (inputValue-location2)/(location3-location2);
            outFloat = lerp(color2, color3, pos);
        }
posted @ 2024-09-18 14:09  世纪末の魔术师  阅读(19)  评论(0编辑  收藏  举报