Shader "ShaderLearn/my_test_03" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_MainColor("MainColor", color) = (1,1,1,1)
_SecondColor("SecondColor", color) = (1,1,1,1)
_Center("Center", range(-0.51, 0.51)) = 0
_R("R", range(0, 1)) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows vertex:vert
#pragma target 3.0
sampler2D _MainTex;
fixed4 _MainColor;
fixed4 _SecondColor;
float _Center;
float _R;
struct Input {
float2 uv_MainTex;
float x;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
UNITY_INSTANCING_CBUFFER_START(Props)
UNITY_INSTANCING_CBUFFER_END
void vert(inout appdata_full v, out Input o)
{
o.uv_MainTex = v.texcoord.xy;
o.x = v.vertex.x;
}
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
float d = IN.x - _Center;
float s = abs(d);//正
d = d / s;//1或者-1
float f = s / _R;
f = saturate(f);
d *= f;
d = d / 2 + 0.5;//变成0到1
o.Albedo *= lerp(_MainColor, _SecondColor, d);
}
ENDCG
}
FallBack "Diffuse"
}