Help with WebGL and Shader Compatibility Issues (Gamma vs. Linear Color Space)

Hello,

I’m encountering issues with shaders when building my Unity project for WebGL, specifically related to the color space setting.

Issue:

  1. When I switch the color space to Gamma, I can build for WebGL, but I get the error:
    RenderingCommandBuffer: invalid pass index X in DrawMesh.
  2. When switching to Linear, I can’t build for WebGL at all, as I get build errors related to shader compatibility.
  3. I have both WebGL1 and WebGL2 enabled in the Player Settings. Removing WebGL1 causes the same shader error.

What I’ve Tried:

  • Switching color spaces between Gamma and Linear doesn’t resolve the issue.
  • Enabling and disabling WebGL1/WebGL2 didn’t help.

My Setup:

  • I’m using imported materials and shaders (not manually created), and I’m not sure how to modify them for color space compatibility in WebGL.

Help Needed:

  • Any tips on resolving the invalid pass index error when using Gamma color space.
  • How to make sure imported shaders work properly with WebGL and different color spaces.

Thanks for any help!

This is a runtime error? Check any usages of DrawMesh(Instanced etc). Even if its in 3rd party code. This may indicate that there’s a shader in use which isn’t compatible with the Web platform.

And this seems to point to what I said above. Could you post these errors?

Do consider updating to Unity 2022.3 LTS or 6 nevertheless, because the Web platform has made great strides since. Also, WebGL v1 has been removed entirely. It probably won’t fix your issue here but you’re likely to see improved performance. You can test the upgrade in a copy of the project.

Thank you! I ended up removing WebGL 1 from the player settings and it fixed the issue :slight_smile: