Shader errors in WebGL build + long build times

Hey Unity Team,

For our next project we want to make use of the WebGL improvements made in 2021.2. I decided to convert a prototype from 2020.3 to 2021.2b15 using a few asset store packages we are planning to use. Converting the project broke most of the URP materials it was using (weird shading issues). I then recreated the prototype piece by piece in 2021.2, which then worked fine in editor. When I build for WebGL however, I get a couple of the following error:
“GLSL link error: FRAGMENT shader texture image units count exceeds MAX_TEXTURE_IMAGE_UNITS(16)
Note: Creation of internal variant of shader ‘Universal Render Pipeline/Terrain/Lit’ failed.”
And all the materials look weird again (the same way they did when I converted from 2020.3).
What’s also strange is that building takes over 30 minutes now (both clean as well as incremental), compared to 5 minutes tops in 2020.3. According to the progress UI it is spending most of that time stripping shader variants. I also tried to build for Windows. The build also takes over 30 minutes, but in that build there are no errors or shading issues.
I added the WebGL build in the link below so you can see what happens in build. I’m not allowed to post the project itself, but I added a video of what it looks like in editor/should look like.

( I checked other posts on the forum and one post suggested disabling ‘Optimize Mesh Data’ and ‘Vertex Compression’ in player settings. ‘Optimize Mesh Data’ was already disabled and disabling ‘Vertex Compression’ didn’t seem to have much of an influence either.)

Link to build + video of what it should look like:
https://drive.google.com/drive/folders/1Y7bXEon0DmRKcKuzhvU1d_APoD8dfulh?usp=sharing

Thanks,
Jolan Huyvaert (die Keure)

Hi Jolan,

Thanks for reaching out. Would you be able to submit a bug report for this issue with the project attached so we can have a look? The build itself is probably not enough to debug this.

Thanks for the quick response.
I submitted a bug report with the project attached.

1 Like

Thanks! What’s the Issue ID?

The issue id is 1372189. I must add that I changed the color space setting from linear to gamma to test something right before submitting the bug report, but forgot to put it back.

1 Like

Thanks! Could you please reply to the confirmation email that you received after submitting the report with this information? That way it will show up in the report.

Thanks! I replied to the confirmation email with the additional info

1 Like

Was this ever solved? I’m having the same issue.

1 Like

The same to me. So, was this ever solved?

I was running into the same issue, using Unity 6000.027f1. After looking in the frame debugger, I discovered that the terrain shader was indeed using 17 texture units:


In my project, _MainLightShadowmapTexture was unnecessary, as I don’t have any dynamic shadows. I managed to get rid of it by disabling Lighting > Main Light > Cast Shadows in the URP asset, which brought the texture unit count back to 16.

This does sound like a bug to me, though. Shouldn’t the terrain rendering system take the texture unit capabilities of the GPU into account? Was the original bug report ever resolved?

What if we need shadows?