Shader

2020. 6. 29. 18:21카테고리 없음

1. 리소스파일인 textures를 임포트

2. 쉐이더 파일 생성

3. 메테리얼 파일 생성

4. 쉐이더를 메테리얼에 어사인

5. 3d 오브젝트 Quad생성하고 메테리얼을 어사인

6. 쉐이더 스크립트 작성

 

1) 

Shader "Custom/Shader_0"
{
    Properties
    {
        _MainTex("Albedo (RGB)", 2D) = "white" {}
        _MainTex2("Albedo (RGB)", 2D) = "white" {}		// 추가
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent"}		// 변경
        CGPROGRAM
        #pragma surface surf Standard alpha:fade		// 변경
        sampler2D _MainTex;
        sampler2D _MainTex2;		// 추가

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;		// 추가
        };
        fixed4 _Color;
        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            float4 d = tex2D(_MainTex2, float2(IN.uv_MainTex.x, IN.uv_MainTex.y - _Time.y));		// 추가
            float4 c = tex2D (_MainTex, IN.uv_MainTex);		// 변경
            o.Emission = c.rgb * d.rgb;		//추가
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 

 

2) 

Shader "Custom/Shader_1"
{
    Properties
    {
        _MainTex("Albedo (RGB)", 2D) = "white" {}
        _MainTex2("Albedo (RGB)", 2D) = "black" {}		// 추가

    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent"}		// 변경
        CGPROGRAM
        #pragma surface surf Standard alpha:fade		// 변경
        sampler2D _MainTex;
        sampler2D _MainTex2;		// 추가

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;		// 추가
        };
        fixed4 _Color;
        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            float4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y));	// 추가
            float4 c = tex2D (_MainTex, IN.uv_MainTex + d.r);	// 변경
            o.Emission = c.rgb;		// 추가
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

7. 메테리얼 텍스쳐1번에 fireTest와 2번에 noise2를 어사인한다.

8. fireTest 알베도에서 Tiling의 y값을 0.9정도로 바꾼다.