Shader "Lambert"
{
Properties
{
_BaseColor("BaseColor",Color) = (1.0,1.0,1.0,1.0)
}
SubShader
{
Tags { "LightMode"="ForwardBase" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float3 normal:NORMAL;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 pos : SV_POSITION;
float3 normal_WS:TEXCOORD1;
};
float4 _BaseColor;
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv =v.texcoord;
o.normal_WS=UnityObjectToWorldNormal(v.normal);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
half3 normal = normalize(i.normal_WS);
half3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
half3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
half3 diffuse =_LightColor0.rgb*saturate(dot(normal,lightDir))*_BaseColor;
return float4(diffuse,1);
}
ENDCG
}
}
}
|