Shader "Custom/cube2"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cube("CubeMap",Cube)=""{}
_BumpMap("Normalmap",2D) ="bump"{}
_MaskMap("MaskMap",2D)="white"{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
samplerCUBE _Cube;
sampler2D _BumpMap;
sampler2D _MaskMap;
struct Input
{
float2 uv_MainTex;
float3 worldRefl; INTERNAL_DATA //반사벡터 normalmap사용
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 m = tex2D (_MaskMap, IN.uv_MainTex); //마스크맵
//노멀을 먼저 적용하고
fixed4 n =tex2D (_BumpMap,IN.uv_MainTex);
o.Normal =UnpackNormal(n);
//내장함수를 사용해서 적용된 노멀의 리플렉션을 사용함
float3 worldRefl = WorldReflectionVector(IN,o.Normal);
float4 refl =texCUBE(_Cube,worldRefl);
o.Albedo =c.rgb*(1-m.r); //마스크맵 red 반전
o.Emission =refl.rgb*m.r; //마스크맵 red 부분에 적용
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Shader "Custom/cube3"
{
Properties
{
_MainTex("Main",2D)="white"{}
// _BumpMap("Normalmap",2D) ="bump"{}
_Cube("Cube",Cube)=""{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
// sampler2D _BumpMap;
samplerCUBE _Cube;
struct Input
{
float4 color :COLOR;
float2 uv_MainTex;
float3 worldRefl; INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = IN.color.rgb;
float4 c =tex2D(_MainTex,IN.uv_MainTex);
//노멀을 먼저 적용하고
// fixed4 n =tex2D (_BumpMap,IN.uv_MainTex);
// o.Normal =UnpackNormal(n);
//cube refl
float3 worldRefl =WorldReflectionVector(IN,o.Normal);
float4 refl =texCUBE(_Cube,worldRefl);
o.Albedo =c.rgb*(IN.color.g);
o.Emission = refl.rgb*(1-IN.color.g);
o.Alpha =c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'게임개발 > 게임 그래픽 프로그래밍' 카테고리의 다른 글
Hologram Alpha blend (0) | 2024.02.23 |
---|---|
Alphatest_Cutoff (0) | 2024.02.23 |
Diffuse Warping 기법3 (0) | 2024.02.22 |
Cubemap Reflection 반사영역 (0) | 2024.02.22 |
Diffuse Warping 기법2 (0) | 2024.02.22 |