[Help] Shader error after update to unity 2017

Here is the error i get:
3157993--240245--upload_2017-7-25_11-21-25.png

And here the area of the code:

I have a few shaders with similar error does anyone know what is wrong ? It was working in unity 5.5.

Thanks for your help!

Hi Elzean,

you’re missing a “;” after UNITY_APPLY_DITHER_CROSSFADE(IN)

hey thanks for your help! I made the change but then more errors shows up and they don’t make much sens to me :confused:

3158219--240265--upload_2017-7-25_16-35-5.png

This is the shader:

Shader "Bark" {
Properties {
   
    _Color ("Color Variation", Color) = (0.9,0.5,0.0,0.1)
    [Space(5)]
    _MainTex ("Base (RGB) Smoothness (A)", 2D) = "white" {}
    [NoScaleOffset] _BumpSpecAOMap ("Normalmap (GA) Specular (R) AO (B)", 2D) = "bump" {}

    [Space(5)]
    [Toggle(_METALLICGLOSSMAP)] _LODTerrain ("Use Wind for LODGroups on Terrain", Float) = 0.0
    [Space(10)]

    [Header(Options for lowest LOD)]
    [Space(3)]
    [Toggle] _FadeOutWind("Fade out Wind", Float) = 0.0
}


SubShader {
    Tags { "RenderType"="CTI-TreeBark" }
    LOD 200
    CGPROGRAM
        #pragma surface surf StandardSpecular vertex:CTI_TreeVertBark nolightmap keepalpha
        #pragma target 3.0
        #pragma multi_compile __ LOD_FADE_CROSSFADE
        #pragma multi_compile __ _METALLICGLOSSMAP

        #define IS_BARK
        #define IS_LODTREE

        #include "UnityBuiltin3xTreeLibrary.cginc"

        #include "Includes/CTI_Builtin4xTreeLibraryTumbling.cginc"

        sampler2D _MainTex;
        sampler2D _BumpSpecAOMap;

       

        void surf (Input IN, inout SurfaceOutputStandardSpecular o) {

            UNITY_APPLY_DITHER_CROSSFADE(IN);
           
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);

            //    Add Color Variation
            o.Albedo = lerp(c.rgb, (c.rgb + _Color.rgb) * 0.5, IN.color.r * _Color.a);
            o.Smoothness = c.a * _Color.r;
               
            fixed4 bumpSpecAO = tex2D (_BumpSpecAOMap, IN.uv_MainTex);
            o.Occlusion = bumpSpecAO.b * IN.color.a;
            o.Alpha = c.a;


            o.Specular = bumpSpecAO.r;
            o.Normal = UnpackNormalDXT5nm(bumpSpecAO);
        }
    ENDCG

    // Pass to render object as a shadow caster
    Pass{
        Name "ShadowCaster"
        Tags{ "LightMode" = "ShadowCaster" }

        CGPROGRAM
        #pragma vertex vert_surf
        #pragma fragment frag_surf
        #pragma target 3.0
        #pragma multi_compile_shadowcaster
        #pragma multi_compile __ LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE
        #pragma multi_compile __ _METALLICGLOSSMAP
        #include "HLSLSupport.cginc"
        #include "UnityCG.cginc"
        #include "Lighting.cginc"

        #define UNITY_PASS_SHADOWCASTER
        #include "UnityBuiltin3xTreeLibrary.cginc"
        #define IS_BARK
        #define DEPTH_NORMAL
        #define IS_LODTREE
        #include "Includes/CTI_Builtin4xTreeLibraryTumbling.cginc"

      

        struct v2f_surf {
            V2F_SHADOW_CASTER;

            UNITY_DITHER_CROSSFADE_COORDS_IDX(2)
        };

        v2f_surf vert_surf(appdata_full v) {
            v2f_surf o;
            CTI_TreeVertLeaf(v);
            TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
            UNITY_TRANSFER_DITHER_CROSSFADE_HPOS(o, o.pos)
            return o;
        }

        float4 frag_surf(v2f_surf IN) : SV_Target {
            UNITY_APPLY_DITHER_CROSSFADE(IN)
            SHADOW_CASTER_FRAGMENT(IN)
        }
        ENDCG
    }

///
}
}

you’re welcome!
you still have another one, on line 100

and it seems it should be UNITY_APPLY_DITHER_CROSSFADE(IN.), and this is a float2…

I couldnt fixe it, but commenting the line “UNITY_APPLY_DITHER_CROSSFADE(IN);” fixed it and all the other shaders that had errors. But that probably broke something with the LOD no ?
Do you have an idea what this line should be ?
I check other example online but they all look like that with just “IN” as parameter :confused:

Well there is other errors that appears in the shader inspector when i’m in the scene, i will ask more to the asset creator hopefully he can fixe it :frowning:

There is a ton of inconsistency with how semicolons were used with macros in Unity shaders. By macro I mean any line that looked like:

UNITY_SOMETHING_IN_ALL_CAPS(variablesInParentheses);

As far as I can tell it’s completely random as to if a macro should end with a semicolon or not, though generally a macro with no variables should not end with a semicolon. It looks like there was a pass for 2017 to make this more consistent (though still not perfect) and that particular macro was one that was changed from not needing a semicolon to needing one.