Shader "Custom/15-2-NormalMap"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_BumpMap("NormalMap (RGB)", 2D) = "white" {}
_Cube("Cubemap", CUBE) = "" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert noambient
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float3 worldRefl;
// 노멀맵에 반사처리르 할때
INTERNAL_DATA
};
sampler2D _MainTex;
sampler2D _BumpMap;
samplerCUBE _Cube;
void surf(Input IN, inout SurfaceOutput o)
{
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
// 노멀맵에 반사처리르 할때
float4 re = texCUBE(_Cube, WorldReflectionVector(IN, o.Normal));
// float4 re = texCUBE(_Cube, IN.worldRefl);
o.Albedo = c.rgb;
o.Emission = re.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}