Search Unity

Fragment Shader Compile Issues

Discussion in 'Shaders' started by aflesher, Mar 21, 2018.

  1. aflesher

    aflesher

    Joined:
    Dec 12, 2013
    Posts:
    28
    One of my shaders won't compile on my Macbook (works fine on my PC though).

    I get the following compile error:

    GLSL compilation failed:
    ERROR: 0:33: '.' : syntax error: syntax error


    The shader renders some water with some wave effects
    Code (Boo):
    1. Shader "Environment/Water"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Color", Color) = (1,1,1,1)
    6.         _FilmColor ("Film Color", Color) = (1,1,1,1)
    7.         _FilmSize ("Film Size", Float) = 0
    8.         _EdgeColor ("Edge Color", Color) = (1,1,1,1)
    9.         _EdgeSize ("Edge Size", Float) = 0
    10.     }
    11.     SubShader
    12.     {
    13.         Tags
    14.         {
    15.             "PreviewType" = "Plane"
    16.             "Queue" = "Transparent"
    17.             "RenderType" = "Transparent"
    18.         }
    19.  
    20.         Pass
    21.         {
    22.             Cull Off
    23.             ZWrite Off
    24.             Blend SrcAlpha OneMinusSrcAlpha
    25.  
    26.             CGPROGRAM
    27.             #pragma vertex vert
    28.             #pragma fragment frag
    29.            
    30.             #include "UnityCG.cginc"
    31.             #include "Assets/Shaders/Includes/CommonFunctions.cginc"
    32.  
    33.             struct appdata
    34.             {
    35.                 float4 vertex : POSITION;
    36.                 float2 uv : TEXCOORD0;
    37.             };
    38.  
    39.             struct v2f
    40.             {
    41.                 float2 uv : TEXCOORD0;
    42.                 float4 vertex : SV_POSITION;
    43.             };
    44.  
    45.             v2f vert (appdata v)
    46.             {
    47.                 v2f o;
    48.                 o.vertex = UnityObjectToClipPos(v.vertex);
    49.                 o.uv = v.uv;
    50.                 return o;
    51.             }
    52.  
    53.             float _WaterColumns[10];
    54.             int _Columns;
    55.             fixed4 _Color;
    56.             fixed4 _FilmColor;
    57.             float _FilmSize;
    58.             fixed4 _EdgeColor;
    59.             float _EdgeSize;
    60.  
    61.             fixed4 frag (v2f i) : SV_Target
    62.             {
    63.                 float suv = float2(i.uv.x * _Columns, i.uv.y);
    64.                 float fuv = frac(suv);
    65.                 float iuv = floor(suv);
    66.  
    67.                 fixed4 col = _Color;
    68.  
    69.                 float prev = _WaterColumns[max(iuv.x - 1, 0)];
    70.                 float cur = _WaterColumns[iuv.x];
    71.                 float next = _WaterColumns[min(iuv.x + 1, _Columns - 1)];
    72.                 float edge = lerp(lerp(prev, cur, 0.5f), lerp(next, cur, 0.5f), fuv.x);
    73.  
    74.                 // add film
    75.                 col = lerp(col, _FilmColor, smoothstep(edge - _FilmSize, edge, i.uv.y));
    76.  
    77.                 // add line to the edge of the water
    78.                 col = lerp(col, _EdgeColor, smoothstep(edge - _EdgeSize - .0005f, edge - _EdgeSize, i.uv.y));
    79.  
    80.                 // soften the edge of the water by smoothsteping the alpha
    81.                 col.a = lerp(0, col.a, 1 - smoothstep(edge, edge + 0.005f, i.uv.y));
    82.  
    83.                 return col;
    84.             }
    85.             ENDCG
    86.         }
    87.     }
    88. }
    89.  
    Does anyone know what the problem is or have any information on how I can debug this error?