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

UWP build failure - "Shader error: invalid subscript"

Discussion in '2017.1 Beta' started by Hertzole, Jun 5, 2017.

  1. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    Hello

    First of all, I'm not 100% sure if this is the beta acting up or if it's the same in Unity 5.6, but I can't really check with 5.6 because I don't have access to it as of right now so I'll post it here since it's present in the beta.

    So sometimes when I want to try and build a UWP app, I get a shader error "invalid subscript". The worst part is that it appears to be quite random. Sometimes it does this, and sometimes it doesn't. I have no idea how I can reproduce it either. I've just tried to build again without changing anything until it works, which is does eventually. But it's still annoying since the error can last for quite some time. And from what I've gathered, it only happens when I try and build for UWP (.NET 4.6).

    And I'm not sure if I really can post the actual shader that gives the error since it's a bought asset.

    Oh, and this is just one of the many problems I've experienced when trying to build for UWP. Seriously, why is UWP so unstable? Sometimes it works and sometimes it doesn't, and no code changes are required to make it work...
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Is that the whole error message? You don't have to post the shader here - you can send it to us via a bug report privately, and post the case number (not the link!) here.

    Could you tell us about these issues you're facing? I don't think we have any issues like that known at this time - and the only way to make us fix it is to make us aware of them :).
     
  3. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    The full error message is:
    And the bug report case number is 918624.

    And for the other problems, it's mostly problems I've experienced in the past but I don't experience them anymore. And some of the problems I've experienced recently have basically just been hiding the actual error in a large block of text. Like one of the icons being too big and it says that at the very bottom of a big block of text. But it's probably just my fault for not reading all the text. But one point still stands. When I've experienced these problems they have been random. Sometimes it works and sometimes not.
    I was kinda fed up with UWP when I first wrote that post, which led to me including that last part.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hey, I looked at this issue. Looks like you're hitting this (the post describes a workaround):

    https://forum.unity3d.com/threads/s...ed-shader-editor.222049/page-111#post-2875887

    Basically that shader is using boxMin and boxMax fields of this struct (it's under Editor\Data\CGIncludes\UnityLightingCommon.cginc):

    Code (csharp):
    1. struct UnityGIInput
    2. {
    3.     UnityLight light; // pixel light, sent from the engine
    4.  
    5.     float3 worldPos;
    6.     half3 worldViewDir;
    7.     half atten;
    8.     half3 ambient;
    9.  
    10.     // interpolated lightmap UVs are passed as full float precision data to fragment shaders
    11.     // so lightmapUV (which is used as a tmp inside of lightmap fragment shaders) should
    12.     // also be full float precision to avoid data loss before sampling a texture.
    13.     float4 lightmapUV; // .xy = static lightmap UV, .zw = dynamic lightmap UV
    14.  
    15.     #if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
    16.     float4 boxMin[2];
    17.     #endif
    18.     #ifdef UNITY_SPECCUBE_BOX_PROJECTION
    19.     float4 boxMax[2];
    20.     float4 probePosition[2];
    21.     #endif
    22.     // HDR cubemap properties, use to decompress HDR texture
    23.     float4 probeHDR[2];
    24. };
    As you can see, these fields are only there if "UNITY_SPECCUBE_BOX_PROJECTION" is true. That is set in "Edit -> Project Settings -> Graphics -> Tier Settings". By default, it's always on in the standalone player. However, we turn it off on the lowest tier for UWP so the apps could scale down to very weak devices (like phones). All shaders are compiled for every different tier setting. You get this error when the shader is recompiled after Unity determines it needs to do it. If you clear the error, Unity will continue to think that shader has an error, but it will not keep continually printing it to the log.

    Hope this explains what's happening :).