Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[Regression] Shader no longer compiles on selected APIs, gives cryptic errors.

Discussion in '5.5 Beta' started by ArtyBoomshaka, Sep 9, 2016.

  1. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Hello,

    I just uploaded a bug report with a shader that no longer compiles at least on GLES3 and OpenGLCore.

    When attempting to compile it for these APIs, I get the following error :
    Shader compiler: internal error compiling shader snippet type=[0|1] platform=<API_ID>: Protocol error - failed to read correct magic number

    My other shaders have no issue, so I guess it has something to do with the specific depth stuff done in it.
    The case number is 830427 and the shaders code is the following :
    Code (CSharp):
    1. Shader "Hidden/PKFx Depth Copy"
    2. {
    3.     Properties
    4.     {
    5.         _Flip("Set to 1 when in forward rendering.", Range(0, 1)) = 0.0
    6.     }
    7.     SubShader
    8.     {
    9.         // No culling or depth
    10.         ZTest Always
    11.         ZWrite On
    12.  
    13.         // Writes to a single-component texture (TextureFormat.Depth)
    14.         Pass
    15.         {
    16.             CGPROGRAM
    17.             #pragma vertex vert
    18.             #pragma fragment frag
    19.  
    20.             #include "UnityCG.cginc"
    21.  
    22.             struct appdata
    23.             {
    24.                 float4 vertex : POSITION;
    25.                 float2 uv : TEXCOORD0;
    26.             };
    27.  
    28.             struct v2f
    29.             {
    30.                 fixed2 uv : TEXCOORD0;
    31.                 float4 vertex : SV_POSITION;
    32.             };
    33.  
    34.             float _Flip;
    35.  
    36.             v2f vert(appdata v)
    37.             {
    38.                 v2f o;
    39.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    40.                 o.uv = v.uv * (1 - _Flip) + _Flip * float2(v.uv.x, 1 - v.uv.y);
    41.                 return o;
    42.             }
    43.  
    44.             sampler2D _CameraDepthTexture;
    45.  
    46. #if !defined(SHADER_API_D3D9) && !defined(SHADER_API_D3D11_9X)
    47.             fixed frag(v2f i) : SV_Depth
    48.             {
    49.                 fixed4 col = tex2D(_CameraDepthTexture, i.uv);
    50.                 return col.r;
    51.             }
    52. #else
    53.             void frag(v2f i, out float4 dummycol:COLOR, out float depth : DEPTH)
    54.             {
    55.                 fixed4 col = tex2D(_CameraDepthTexture, i.uv);
    56.                 dummycol = col;
    57.  
    58.                 depth = col.r;
    59.             }
    60. #endif
    61.             ENDCG
    62.         }
    63.     }
    64. }
    65.