Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2022.2 beta is now available for testing. To find out what's new, have a look at our 2022.2 feature highlights.
    Dismiss Notice
  3. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  5. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice
Dismiss Notice
Submit bug reports tagged with #Beta2022Win_Unity when you encounter unknown issues while testing the 2022.2 betas for a chance to win a year of Unity Pro. For more information, have a look at our Beta Sweepstakes Announcement.

UWP build failure - "Shader error: invalid subscript"

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

  1. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    393
    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:
    9,711
    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. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    393
    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:
    9,711
    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 :).
     
unityunity