Window -> Rendering -> Lighting
Shader "Custom/cube"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cube("CubeMap",Cube)=""{}
_BumpMap("Normalmap",2D) ="bump"{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
samplerCUBE _Cube;
sampler2D _BumpMap;
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 n =tex2D (_BumpMap,IN.uv_MainTex);
o.Normal =UnpackNormal(n);
//내장함수를 사용해서 적용된 노멀의 리플렉션을 사용함
float4 re =texCUBE(_Cube,WorldReflectionVector(IN,o.Normal));
o.Albedo = c.rgb*0.3; //=0; 어두워야 반사가 더 잘 보임
o.Emission =re.rgb*0.7;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'게임개발 > 게임 그래픽 프로그래밍' 카테고리의 다른 글
Cubemap Reflection 2 (0) | 2024.02.23 |
---|---|
Diffuse Warping 기법3 (0) | 2024.02.22 |
Diffuse Warping 기법2 (0) | 2024.02.22 |
Diffuse Warping 기법 (0) | 2024.02.22 |
끊어지는 음영 만들기 (0) | 2024.02.21 |