赞
踩
效果演示:
当前效果需要自己手动写一个shader,效果与unity版本无关,模型没有特别要求
在unity创建一个SurfaceShader类型的shader,命名为CotrolGradient_3Color,双击进入vs进行编辑,shader内容如下:
Shader "Custom/CotrolGradient_3Color"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_ColorTop("Top Color", Color) = (1, 1, 1, 1)
_ColorMid("Mid Color", Color) = (1, 1, 1, 1)
_ColorBot("Bot Color", Color) = (1, 1, 1, 1)
_Middle("Middle", Range(0.001, 0.999)) = 1
_test("Test", Range(0.001, 0.999)) = 1
}
SubShader
{
Tags {"Queue" = "Background" "IgnoreProjector" = "True"}
LOD 100
ZWrite On
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
fixed4 _ColorTop;
fixed4 _ColorMid;
fixed4 _ColorBot;
float _Middle;
float _test;
struct v2f
{
float4 pos : SV_POSITION;
float4 texcoord : TEXCOORD0;
};
v2f vert(appdata_full v)
{
v2f o;
if (v.vertex.y > _test)
{
v.vertex.y = _test;
}
o.pos = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 c = lerp(_ColorBot, _ColorMid, i.texcoord.y / _Middle) * step(i.texcoord.y, _Middle);
c += lerp(_ColorMid, _ColorTop, (i.texcoord.y - _Middle) / (1 - _Middle)) * step(_Middle, i.texcoord.y);
c.a = 1;
return c;
}
ENDCG
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。