Search Unity

help with color in shader

Discussion in 'General Graphics' started by Volkerku, May 22, 2020.

  1. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    114
    Hi
    Sorry I'm a newbie with shaders. I got this shader (forgot where from) and I try to change the rim color to black. If I do thiswith the shader controls, the figure becomes 100% transparent. I want to keep the rim visible, as in the img attached, but in black. Any ideas?

    shader.JPG
    Code (CSharp):
    1. Shader "Custom/Model_TransparentInvert" {
    2.      Properties
    3.      {
    4.        _InnerColor ("Inner Color", Color) = (0.0, 0.0, 0.0, 1.0)
    5.        _RimColor ("Rim Color", Color) = (1.0,1.0,1.0,1.0)
    6.        _RimPower ("Rim Power", Range(0.5,8.0)) = 2.47
    7.      }
    8.      SubShader
    9.      {
    10.        Tags { "Queue" = "Transparent" }
    11.      
    12.        Cull Back
    13.        Blend One One
    14.      
    15.        CGPROGRAM
    16.        #pragma surface surf Lambert
    17.      
    18.        struct Input
    19.        {
    20.            float3 viewDir;
    21.        };
    22.      
    23.        float4 _InnerColor;
    24.        float4 _RimColor;
    25.        float _RimPower;
    26.      
    27.        void surf (Input IN, inout SurfaceOutput o)
    28.        {
    29.            o.Albedo = _InnerColor.rgb;
    30.            half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
    31.            o.Emission = _RimColor.rgb * pow (rim, _RimPower);
    32.        }
    33.        ENDCG
    34.      }
    35.      Fallback "Diffuse"
    36.    }
    37.