유니티/수업 내용
[shader] 반짝거리기
hyunjin-dev-log
2022. 1. 18. 19:55
Shader "Custom/Blink"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MaskTex ("Mask Texture", 2D) = "white" {}
_RampTex ("Ramp Texture", 2D) = "white" {}
_UValue ("UV U VALUE", Range(0, 1)) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _MaskTex;
sampler2D _RampTex;
float _UValue;
struct Input
{
float2 uv_MainTex;
float2 uv_MaskTex;
float2 uv_RampTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
float4 mask = tex2D (_MaskTex, IN.uv_MaskTex);
float4 ramp = tex2D (_RampTex, float2(_Time.y, 0));
o.Albedo = c.rgb;
o.Emission = mask.g * ramp.r * c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}