Notice
Recent Posts
Recent Comments
Link
스토리지
[5.3] 불 이펙트 만들기 본문
1. 알파 값 없애기
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Emission = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
- Tags 변경 ( RenderType : Transparent, Queue : Transparent )
- pragma 속성 변경 ( alpha:fade 적용 )
2. 두번째 이미지 넣은 뒤 위로 흘러가게 하기 및 속도조절
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Tex2("Albedo (RGB)", 2D) = "white" {}
_Speed ("Speed", Range(0,2)) = 1
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
sampler2D _Tex2;
float _Speed;
struct Input
{
float2 uv_MainTex;
float2 uv_Tex2;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_Tex2, float2(IN.uv_Tex2.x, IN.uv_Tex2.y - _Time.y * _Speed));
o.Emission = d.rgb;
o.Alpha = d.a;
}
ENDCG
}
FallBack "Diffuse"
}
- UV Animation 삽입
- Animation의 Speed 적용
3. 두 이미지를 합치기 (색을 모두 곱해서 출력)
Shader "Custom/Test"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Tex2("Albedo (RGB)", 2D) = "white" {}
_Speed ("Speed", Range(0,2)) = 1
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
sampler2D _Tex2;
float _Speed;
struct Input
{
float2 uv_MainTex;
float2 uv_Tex2;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
fixed4 d = tex2D(_Tex2, float2(IN.uv_Tex2.x, IN.uv_Tex2.y - _Time.y * _Speed));
o.Emission = c.rgb * d.rgb;
o.Alpha = d.a * c.a;
}
ENDCG
}
FallBack "Diffuse"
}
- 두 이미지의 RGB값과 Alpha값을 곱해서 출력
4. 이미지를 왜곡시키기
Shader "Custom/Fire"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2 ("Albedo (RGB)", 2D) = "white" {}
_Speed ("Speed", Range(0,3)) = 1
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
sampler2D _MainTex2;
float _Speed;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
//데이터 텍스쳐에 애니메이션 삽입
float4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y));
//IN.uv_MainTex.x + 0, IN.uv_MainTex.y + 0 (검은색일 경우)
//UV좌표를 이동시키기 위함 (왜곡효과를 위해서)
float4 c = tex2D(_MainTex, IN.uv_MainTex + d.r);
o.Emission = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
- 메인 텍스쳐를 소스 텍스쳐의 r값에 따라 uv좌표를 이동시켜줌 => 왜곡효과
- 소스 텍스쳐에 UV Animation 효과를 부여
완성품
끝에 짤리는 부분은 텍스트의 Wrap Mode를 Repeat에서 Clamp로 변경해주었다.
'Unity > Shader' 카테고리의 다른 글
[5.4] 색깔 영역에 각각 다른 텍스쳐 삽입 (0) | 2021.05.04 |
---|---|
[5.4] Shader 복습 1 (0) | 2021.05.04 |
[5.3] UV _Time (0) | 2021.05.03 |
[5.3] UV (0) | 2021.05.03 |
[5.3] Shader 연습 1 (0) | 2021.05.03 |
Comments