Shader "Custom/14-5-1"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
cull back
// 2 pass
CGPROGRAM
#pragma surface surf Toon
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_INSTANCING_BUFFER_END(Props)
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
float4 LightingToon(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
{
float ndotl = dot(s.Normal, -viewDir);
if (ndotl > 0.5)
{
ndotl = 1;
}
else if (ndotl < 0.2)
{
ndotl = 0;
}
else
{
ndotl = 0.3;
}
return ndotl;
}
ENDCG
}
FallBack "Diffuse"
}
//appdata_base: 포지션, 노멀, 하나의 텍스처 좌표
//appdata_tan : 포지션, 탄젠트, 노멀, 하나의 텍스처 좌표
//appdata_full : 포지션, 탄젠트, 노멀, 네 개의 텍스처 좌표, 컬러