게임개발/게임 그래픽 프로그래밍
Diffuse Warping 기법
pudding81
2024. 2. 22. 11:15
Shader "Custom/Warp"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_RampTex ("Ramp", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf _Warp //커스텀라이트
#pragma target 3.0
sampler2D _MainTex;
sampler2D _RampTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
//커스텀라이트
float4 Lighting_Warp(SurfaceOutput s,float3 lightDir,float atten)
{
//Lambert
float ndotl =dot(s.Normal,lightDir);
// Warping 기법
float2 uv = float2(ndotl,0.5);
float4 ramp = tex2D(_RampTex,uv);
return ramp;
}
ENDCG
}
FallBack "Diffuse"
}