Shader "Ageia/SimpleReflectionProbe" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
[Normal]_Normal("Normal", 2D) = "bump"{}
_NormalPow("NormalPow", Range(0, 3)) = 1
_Metallic("Metallic", Range(0, 1)) = 1
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf CumstomLighing fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _Normal;
struct Input {
float2 uv_MainTex;
half2 uv_Normal;
half3 viewDir;
half3 worldRefl; //WorldReflectionVector ๋ฐ์ดํฐ์ ์ฌ์ฉ๋ฉ๋๋ค.
INTERNAL_DATA
//worldRefl ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๊ธฐ ์ํด ํด๋น ๋ฐ์ดํฐ ๊ตฌ์กฐ๋ฅผ ํ์๋ก ํจ.
};
fixed4 _Color;
half _NormalPow;
half _NormalPow2;
half _Metallic;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutput o) {
half3 NormalTest = UnpackNormal(tex2D(_Normal, IN.uv_Normal));
o.Normal = lerp(o.Normal, NormalTest, _NormalPow);
//simpleReflectionMap
half3 Reflection1 = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, WorldReflectionVector(IN, o.Normal)) * unity_SpecCube0_HDR.r;
//unity_SpecCube0_HDR.r : ๋ฆฌํ๋ ์ ํ๋ธ์ Intensity๊ฐ.
half3 Reflection2 = UNITY_SAMPLE_TEXCUBE_SAMPLER(unity_SpecCube1, unity_SpecCube0, WorldReflectionVector(IN, o.Normal)) * unity_SpecCube0_HDR.r;
//Reflection2๋ ๋ค๋ฅธ ๋ฆฌํ๋ ์ ํ๋ก๋ธ์์ ๋ณด๊ฐ์ ์ฒ๋ฆฌํฉ๋๋ค. ํ์์๋ ๊ฒฝ์ฐ ์ ๊ฑฐ ํ์ญ์์ค.
half3 ReflectionFinal = lerp(Reflection2, Reflection1, unity_SpecCube0_BoxMin.w);
//unity_SpecCube0_BoxMin.w : ๋๊ฐ์ ๋ฆฌํ๋ ์ ํ๋ก๋ธ๋ฅผ ๋ณด๊ฐํฉ๋๋ค.
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = lerp(c.rgb, 0, _Metallic);
//o.Emission = pow(NdotV * 0.5 + 0.5, 20);
o.Emission = lerp(0, ReflectionFinal, _Metallic);
o.Alpha = c.a;
}
half4 LightingCumstomLighing(SurfaceOutput s, half3 lightDir, half atten)
{
half4 c;
c.rgb = s.Albedo;
c.a = s.Alpha;
return c;
}
ENDCG
}
FallBack "Diffuse"
}
๋ชจ๋ฐ์ผ ์ ์ฉ ๋ฆฌํ๋ ์ ํ๋ก๋ธ ๋ธ๋ ๋ฉ ์์ด๋ ๋ง๋ค์ด๋ดค์ต๋๋ค.
์์ด๋ ๋ง์ง์ค ์์๋ ๋ถ์ด๋ฉด ์ด๊ฑธ๋ก ๊ธ์ ์ง๊ฐ ์ฒ๋ฆฌํ๊ฑฐ๋ ํ์๋ฉด ๋ ๋ฏ ํฉ๋๋ค.
์๊ฐค ์ต๊ณ ์์ํ;;
๊ฒ์ฐฝ๊ฐค ์ง์กด์ด์ฌ