Search Unity

Custom shader worked in 2019 but not in 2020.1.17f

Discussion in 'Shaders' started by Kobaltic1, Jul 13, 2021.

  1. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    I don't know much about shaders but I wrote a custom one. I got it to work in Unity 2019 but it doesn't work in Unity 2020.1.17.

    This is what it looks like now
    upload_2021-7-13_10-38-34.png

    This is what it is supposed to look like
    upload_2021-7-13_10-39-27.png

    This is the code for the shader
    Code (CSharp):
    1. Shader "Custom/DoubleSidedDecal"
    2. {
    3.  
    4.     Properties{
    5.         _Color("Main Color", Color) = (1,1,1,1)
    6.         _MainTex("Base (RGB)", 2D) = "white" {}
    7.      
    8.         _DecalColor("Decal Color", Color) = (1,1,1,1)
    9.         _DecalTex("Decal (RGBA)", 2D) = "black" {}
    10.         _Illum("Illumin (A)", 2D) = "white" {}
    11.         _Emission("Emission (Lightmapper)", Float) = 1.0
    12.     }
    13.  
    14.         SubShader{
    15.             Tags {"RenderType" = "Transparent" "Queue" = "Transparent"}//Tags { "RenderType" = "Opaque" }
    16.             LOD 100
    17.         Cull Off
    18.              ZWrite Off
    19.                  Blend SrcAlpha OneMinusSrcAlpha
    20.  
    21.         CGPROGRAM
    22.         #pragma surface surf Lambert alpha
    23.  
    24.         sampler2D _MainTex;
    25.         sampler2D _DecalTex;
    26.         sampler2D _Illum;
    27.         fixed4 _Color;
    28.         fixed4 _DecalColor;
    29.         fixed _Emission;
    30.  
    31.         struct Input {
    32.             float2 uv_MainTex;
    33.             float2 uv_DecalTex;
    34.             float2 uv_Illum;
    35.         };
    36.  
    37.         void surf(Input IN, inout SurfaceOutput o) {
    38.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
    39.             half4 decal = tex2D(_DecalTex, IN.uv_DecalTex);
    40.             decal *= _DecalColor;
    41.             c *= _Color;
    42.             c.rgb = lerp(c.rgb, decal.rgb, decal.a);
    43.  
    44.             o.Albedo = c.rgb;
    45.             o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
    46. #if defined (UNITY_PASS_META)
    47.             o.Emission *= _Emission.rrr;
    48. #endif
    49.             o.Alpha = c.a;
    50.         }
    51.         ENDCG
    52.     }
    53.  
    54.         Fallback "Legacy Shaders/Diffuse"
    55. }
    56.