C#/문제해결

0504_ 그래픽스, 한 오브젝트에서 따로 러프니스 값 주기

minquu 2021. 5. 4. 16:02
반응형

0. 한 오브젝트에서 color.rgb 채널을 사용해서 r , g , b 따로 러프니스 값을 주려고한다.

 

 

 

일단 r 채널에 스무스 값을 다르게 주면, 나머지 쓰레기 봉투의 값에는 러프니스를 주기 어렵다.

 

 

            o.Smoothness = (IN.color.r * 0.6) * _GlossAmountA ;

 

 

 

폴리브러쉬에서 r 는 더려운 부분, b 는 전체를 칠해주고 ,

 

 

 

            o.Smoothness = (IN.color.r * 0.6) * _GlossAmountA + (IN.color.b * 0.6) * _GlossAmountB;

 

따로 준다 .

 

 

Shader "Custom/Trash"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _MainTex2 ("Albedo (RGB)", 2D) = "white" {}
        _Normal ("Normal (RGB)", 2D) = "white" {}
        _gloss ("gloss", 2D) = "white" {}
        _GlossAmountA ("_GlossAmountA", Range(0,1)) = 0.5
        _GlossAmountB ("_GlossAmountB", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _MainTex2;
        sampler2D _Normal;
        sampler2D _gloss;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;
            float2 uv_gloss;
            float2 uv_Normal;
            float4 color:COLOR;
        };

        half _Metallic;
        float _GlossAmountA;
        float _GlossAmountB;
        fixed4 _Color;

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            fixed4 d = tex2D (_MainTex2, IN.uv_MainTex2);
            fixed4 gloss = tex2D (_gloss, IN.uv_gloss);
            fixed3 n = UnpackNormal(tex2D (_Normal, IN.uv_Normal));
            o.Normal = n;
            o.Albedo = lerp(c.rgb, d.rgb, IN.color.r);
            //o.Albedo = IN.color.rgb;

            o.Metallic = _Metallic;
            o.Smoothness = (IN.color.r * 0.6) * _GlossAmountA + (IN.color.b * 0.6) * _GlossAmountB;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

 

 

 

전체코드 

 

 

반응형