Unity/Surface Shader
가짜 리플렉션
TA Rio
2020. 11. 10. 23:01
Shader "Custom/fake_reflection"
{
Properties
{
_MainTex("Albedo (RGB)", 2D) = "white" {}
_NormalMap("NormalMap", 2D) = "bump" {}
_reflect("reflect", Range(-1,1)) = 0.9
_CubeMap("CubeMap", cube) = "" {}
}
SubShader
{
Tags{ "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex, _NormalMap;
samplerCUBE _CubeMap;
float _reflect;
struct Input
{
float2 uv_MainTex, uv_NormalMap;
float3 worldRefl;
INTERNAL_DATA
};
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_NormalMap));
o.Albedo = c.rgb;
o.Emission = texCUBE(_CubeMap, WorldReflectionVector(IN, o.Normal))*_reflect;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
큐브맵이 있어야 작동한다.