0507 쉐이더 Cube Map+메터리얼에 배경 반사하기
2021. 5. 7. 18:27ㆍunity/쉐이더
Shader "Custom/CubeMap"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cube("Cube Map", Cube) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
samplerCUBE _Cube;
struct Input
{
float2 uv_MainTex;
float3 worldRefl;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
float4 ref = texCUBE(_Cube, IN.worldRefl);
o.Albedo = 0;
o.Emission = ref.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
위와 아래는 똑같은 결과
Shader "Custom/CubeMap"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_BumpMap("Normal", 2D) = "bump" {}
_Cube("Cube Map", Cube) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
samplerCUBE _Cube;
struct Input
{
float2 uv_MainTex;
float3 worldRefl;
float2 uv_BumpMap;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
float4 ref = texCUBE(_Cube, WorldReflectionVector(IN,o.Normal));
o.Albedo = 0;
o.Emission = ref.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Shader "Custom/CubeMap"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_BumpMap("Normal", 2D) = "bump" {}
_Cube("Cube Map", Cube) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
samplerCUBE _Cube;
struct Input
{
float2 uv_MainTex;
float3 worldRefl;
float2 uv_BumpMap;
float3 worldNormal;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
float4 ref = texCUBE(_Cube, WorldReflectionVector(IN,o.Normal));
o.Emission = ref.rgb*0.5;
o.Albedo = c.rgb*0.5;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'unity > 쉐이더' 카테고리의 다른 글
0510 Alpha Blending (0) | 2021.05.10 |
---|---|
0507 쉐이더 Diffuse Wraping (0) | 2021.05.07 |
0507 쉐이더 툰 그래픽 만들기 (0) | 2021.05.07 |
0506 쉐이더 블린퐁 (0) | 2021.05.06 |
0506 쉐이더 Rim Light + Hologram (0) | 2021.05.06 |