55 lines
1,020 B
Text
55 lines
1,020 B
Text
Shader "Custom/VertexLit"
|
|
{
|
|
Properties
|
|
{
|
|
_Dark ("Dark", Color) = (0, 0, 0, 1)
|
|
_Mid ("Mid", Color) = (1, 1, 1, 1)
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "RenderType"="Opaque" }
|
|
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
fixed4 color : COLOR;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
float3 normal : TEXCOORD;
|
|
fixed4 color : COLOR;
|
|
};
|
|
|
|
fixed4 _Dark;
|
|
fixed4 _Mid;
|
|
|
|
v2f vert (appdata v)
|
|
{
|
|
v2f o;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.normal = UnityObjectToWorldNormal(v.normal);
|
|
float t = clamp(dot(normalize(float3(0.3, 0.6, -0.2)), o.normal), 0, 1);
|
|
o.color = lerp(_Dark, _Mid, t);
|
|
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag (v2f i) : SV_Target
|
|
{
|
|
return i.color;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|