본문 바로가기

유니티/수업 내용

[Shader] Texture_Fire

Shader "Custom/Fire"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Texture2 ("texture2", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue"="Transparent"}

        CGPROGRAM
        #pragma surface surf Standard alpha:fade

        sampler2D _MainTex;
        sampler2D _Texture2;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_Texture2;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float4 d = tex2D (_Texture2, float2(IN.uv_Texture2.r, IN.uv_Texture2.g - _Time.y));
            o.Emission = c.rgb + d.rgb;
            o.Alpha = c.a * d.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 


Shader "Custom/Fire"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Texture2 ("texture2", 2D) = "white" {}
        _NoiseIntensity ("Noise Intensity", Range(0, 2)) = 0
        _Test ("test", Range(-1, 1)) = 0
    }
    SubShader
    {
        //Tags { "RenderType"="opaque" }
        //Tags { "RenderType"="opaque" "Queue"="Transparent"}
        Tags { "RenderType"="Transparent" "Queue"="Transparent"}

        CGPROGRAM
        #pragma surface surf Standard alpha:fade

        sampler2D _MainTex;
        sampler2D _Texture2;
        float _NoiseIntensity;
        float _Test;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_Texture2;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            float4 d = tex2D(_Texture2, float2(IN.uv_Texture2.r, IN.uv_Texture2.g - _Time.y));    

            float2 e = float2(IN.uv_MainTex.r + (d.r * _NoiseIntensity) + _Test, (IN.uv_MainTex.g + _Test) + (d.r * _NoiseIntensity));
            fixed4 c = tex2D (_MainTex, e);
            
            o.Emission = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

'유니티 > 수업 내용' 카테고리의 다른 글

[Shader] Metallic, Smoothness, UnpackNormal  (0) 2022.01.18
[Shader] Texture polybrush  (0) 2022.01.18
Shader Warning  (0) 2022.01.18
ML Agent - DinoRun  (0) 2022.01.18
게임인공지능 MLAgent RollerBall 복습  (0) 2022.01.18