Shader "Custom/14-5"
{
Properties
{
_BumpMap("NormalMap (RGB)", 2D) = "white" {}
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
cull front
// 1 pass
CGPROGRAM
#pragma surface surf NoLight vertex:vert noshadow noambient
#pragma target 3.0
struct Input
{
float2 uv_MainTex;
};
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_INSTANCING_BUFFER_END(Props)
void vert(inout appdata_full v)
{
v.vertex.xyz = v.vertex.xyz + v.normal.xyz*-0.005;
}
void surf(Input IN, inout SurfaceOutput o)
{
/*fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;*/
}
float4 LightingNoLight(SurfaceOutput s, float3 lightDir, float3 viewDir, float atten)
{
return float4(0, 0, 0, 1);
}
ENDCG
cull back
// 2 pass
CGPROGRAM
#pragma surface surf Toon
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
};
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.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
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.7)
{
ndotl = 1;
}
else
{
ndotl = 0.3;
}
float4 final;
final.rgb = s.Albedo * ndotl * _LightColor0.rgb;
final.a = s.Alpha;
return final;
}
ENDCG
}
FallBack "Diffuse"
}
//appdata_base: 포지션, 노멀, 하나의 텍스처 좌표
//appdata_tan : 포지션, 탄젠트, 노멀, 하나의 텍스처 좌표
//appdata_full : 포지션, 탄젠트, 노멀, 네 개의 텍스처 좌표, 컬러
'Shader > Shader - SurfaceShader' 카테고리의 다른 글
15-3-MaskMap (0) | 2020.04.08 |
---|---|
Custom/15-1-Reflection (0) | 2020.04.07 |
13-4 rim (0) | 2020.04.06 |
13-3 Gloss (0) | 2020.04.05 |
13-2 스펙귤러 (0) | 2020.04.05 |