
Shader "Custom/05/Fire"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo (RGB)", 2D) = "white" {}
}
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;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 d = tex2D (_MainTex2, float2(IN.uv_MainTex.x, IN.uv_MainTex.y - _Time.y));
o.Emission = c.rgb * d.rgb;
o.Alpha = c.a * d.a;
}
ENDCG
}
FallBack "Diffuse"
}
전체 코드
#pragma surface surf Standard alpha:fade : 매우 무거운 alpha 연산
o.Emission = c.rgb * d.rgb;
o.Alpha = c.a * d.a;
두 장의 이미지를 곱하여 불 이미지를 출력할 수 있다.
'Unity > Unity_Shader' 카테고리의 다른 글
| 13. Time (0) | 2023.05.04 |
|---|---|
| 12. UV값 변환 (0) | 2023.05.04 |
| 11. UV (0) | 2023.05.04 |
| 10. Lerp 함수 응용 (0) | 2023.04.27 |
| 09. 이미지를 흑백으로 바꾸는 방법 (0) | 2023.04.27 |