유니티/쉐이더
05/03 유니티 쉐이더 불 타는 효과 만들기
박준희
2021. 5. 3. 17:59
728x90


1. 두 텍스쳐를 받는 쉐이더 작성
2. 첫번째 : check, 두번째 : source (data)
3. check의 uv좌표를 source의 값으로 이동 (r)
4. source의 uv의 y좌표를 위로 올라가게 애니메이션 (_Time.y값을 빼줌)
5. check를 fire로 변경
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2 ("Albedo (RGB)", 2D) = "white" {}
_Speed("Speed", Range(-10, 10)) = 0
}
SubShader
{
Tags { "RenderType"= "Transparent" "Queue" = "Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
sampler2D _MainTex2;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
};
float _Speed;
void surf (Input IN, inout SurfaceOutputStandard o)
{
float4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y * _Speed)); //검정
float4 c = tex2D(_MainTex, IN.uv_MainTex + d.r); //check
o.Emission = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
728x90