> 알파 채널이 있는 텍스쳐 배경 투명하게 하기

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"
}

+ Recent posts