Shader "Custom/tex2"
{
    Properties
    {
        _MainTex("Albedo(RGB)", 2D) = "grey" {}
        _MainTex2("Albedo(RGB)", 2D) = "grey" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Standard

        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 c2 = tex2D (_MainTex2, IN.uv_MainTex2);

            o.Albedo = lerp(c, c2, 1-c.a ); // 1- 알파 텍스쳐의 0와 1값이 바뀌어 반전됨
        
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 

 

Shader "Custom/tex2"
{
    Properties
    {
        _MainTex("Albedo(RGB)", 2D) = "grey" {}
        _MainTex2("Albedo(RGB)", 2D) = "grey" {}
        _lerp("lerp",Range(0,1)) = 0 // lerp 슬라이더 인터페이스 생성
        _Bright("Bright&Dark",Range(-1,1)) = 0 // 밝기 조정 슬라이더 인터페이스 생성
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Standard

        sampler2D _MainTex;
        sampler2D _MainTex2;

        float _lerp; // 변수 선언
        float _Bright; // 변수 선언


        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
           fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
           fixed4 c2 = tex2D (_MainTex2, IN.uv_MainTex2);
                      
           float3 lerpColor = lerp(c, c2, 1-_lerp);

           // 섞은 텍스쳐의 rgb 값에 밝기 조정
           float3 grayColor = (lerpColor.r + lerpColor.g +lerpColor.b) + _Bright; // 회색 부분 음영조절

           o.Albedo = lerp(grayColor, c2, 1-c.a);

           o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 

+ Recent posts