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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug WebGL Build Failure on Compile/Strip Variant Shader Process (Built-in Render Pipeline)

Discussion in 'Shader Graph' started by Chopium, Dec 5, 2022.

  1. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    WebGL builds fail when shader-graphs are compiled and stripped. There are vague C# index-out-of-range errors posted. When I disable shader stripping, it fails during variant compilation w/ the same posted errors.

    So far, my solution has been to copy and paste the compiled shader-graph code into a separate shader file, which also causes build failures when certain shader-graph features aren't exposed.

    I initially saw the bug in Unity 2022 so stuck with 2021 LTS. Now the bug appears in 2021.3.15f1. Compilation happens successfully for 2021.3.14, although some shaders look different in builds vs in the editor, I do not consider that to be a major flaw.

    I understand WebGL is not a common build target. I'm wondering if anyone else has seen this or cares.

    Additional details:
    WebGL 2 Graphics API specified
    No compression

    If any of you have suggestions, I'm all ears. I also want to know if you've seen this before and if a bug report is the right next step.

    For reference, here's the last valid console post, then the error.
    Code (CSharp):
    1.  
    2.  
    3. STRIPPING: Shader Graphs/Gradient-Height (ShadowCaster pass) (Vertex) - Remaining shader variants = 4/4 = 100% - Total = 1963/8442 = 23.25278%
    4.  
    5. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189)
    6.  
    7.  
    8. ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    9. Parameter name: subshaderIndex
    10. UnityEngine.Shader.FindSubshaderTagValue (System.Int32 subshaderIndex, UnityEngine.Rendering.ShaderTagId tagName) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Shaders/Shader.bindings.cs:98)
    11. UnityEditor.Rendering.BuiltIn.ShaderPreprocessor.IsShaderGraphShader (UnityEngine.Shader shader, UnityEditor.Rendering.ShaderSnippetData snippetData) (at Library/PackageCache/com.unity.shadergraph@12.1.8/Editor/Generation/Targets/BuiltIn/Editor/ShaderPreprocessor.cs:114)
    12. UnityEditor.Rendering.BuiltIn.ShaderPreprocessor.StripUnused (UnityEditor.Rendering.BuiltIn.ShaderFeatures features, UnityEngine.Shader shader, UnityEditor.Rendering.ShaderSnippetData snippetData, UnityEditor.Rendering.ShaderCompilerData compilerData) (at Library/PackageCache/com.unity.shadergraph@12.1.8/Editor/Generation/Targets/BuiltIn/Editor/ShaderPreprocessor.cs:284)
    13. UnityEditor.Rendering.BuiltIn.ShaderPreprocessor.OnProcessShader (UnityEngine.Shader shader, UnityEditor.Rendering.ShaderSnippetData snippetData, System.Collections.Generic.IList`1[T] compilerDataList) (at Library/PackageCache/com.unity.shadergraph@12.1.8/Editor/Generation/Targets/BuiltIn/Editor/ShaderPreprocessor.cs:348)
    14. UnityEditor.Build.BuildPipelineInterfaces.OnPreprocessShaders (UnityEngine.Shader shader, UnityEditor.Rendering.ShaderSnippetData snippet, UnityEditor.Rendering.ShaderCompilerData[] data) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:490)
    15. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189)
    16.  
     
    Last edited: Dec 5, 2022
    tmdwn12512 likes this.
  2. unity_65577D3675C718E5F5DA

    unity_65577D3675C718E5F5DA

    Joined:
    Mar 4, 2022
    Posts:
    3
    I have the same issue, but my target build is Android. I am using a custom shader created in Shader Graph (I am still using the built-in pipeline). I have had this issue since I updated Unity to 2021.3.15 (still happening in 2021.3.16). I think I will downgrade now to 2021.3.15... I hope someone can fix this issue...