> 알파 채널이 있는 텍스쳐 배경 투명하게 하기
Shader "Custom/fire"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue" ="Transparent" } //
CGPROGRAM
#pragma surface surf Standard alpha:fade //
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
>속도, 강도 슬라이더 만들어서 불 제어하기
Shader "Custom/fire"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2 ("Albedo (RGB)", 2D) = "white" {}
_Strangth("Strangth", float) = 0 // 강도 제어 슬라이더
_Speed("Fire Speed", Range(0,2)) =0 // 속도 제어 슬라이더
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue" ="Transparent" } // 알파
CGPROGRAM
#pragma surface surf Standard alpha:fade // 알파
#pragma target 3.0
sampler2D _MainTex;
sampler2D _MainTex2;
float _Strangth;
float _Speed;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
// 노이즈 텍스쳐 애니매이션 적용
fixed4 c2 = tex2D (_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - (_Time.y *_Speed))); // 시간에 보정 속도를 곱함
// 적용 텍스쳐
fixed4 c = tex2D (_MainTex, IN.uv_MainTex +c2.r * _Strangth); // 강도
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'게임 그래픽 프로그래밍' 카테고리의 다른 글
셰이더9: 하프 램버트 라이트 만들기 (0) | 2024.09.04 |
---|---|
셰이더6: 버택스 (1) | 2024.09.04 |
셰이더4: 텍스쳐 애니메이션 (0) | 2024.09.03 |
셰이더3: 색 반전 및 밝기 조정 (0) | 2024.09.03 |
셰이더3:lerp함수로 텍스쳐 섞기 (0) | 2024.09.03 |