1.shader代码
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Custom/OpaVertColor2"
{
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 vcol : COLOR;
};
v2f vert (appdata v)
{
v2f o;
if(length(v.vertex.xyz - float3(0.5,0.5,-0.5)) < 0.01){
o.vcol = fixed4((fixed)abs(sin(_Time * 5)),0,0,1);
}else{
o.vcol = fixed4(0,0,1,1);
}
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return i.vcol;
}
ENDCG
}
}
}
2.说明
3.效果: