If you remove lines 70-75, the PG should work again. The problem is these internally computed values that pass from vertex shader to fragment shader are tagged with location (<#>) with a number > 15.
It would also work if you comment out addShadowCaster at line 46 and 50. It seems enabling shadow triggers location tag added to the varying. And then the location number is increased in a way that exceeds the underlying system limit.
Update: lines 70-75 need to be deleted to make it work again. If you comment out them, the error still occurs.
Yes, the number of varying is not very high in WebGPU at the time. It has been raised in Chrome Canary (122.0.6182.0), so the PG works in Canary (I don’t know when this will be available in Chrome retail, though).
The initial PG works in canary. But my project still fails for the same error. Also, if I increase the number of varying declaration in the PG to 17, it will still fail in canary.
Does it work if I combine multiple float type varying to a vec4 varying?
It should help packing 4 varyings into a single one, yes.
There are two limits, one for the number of varying, and one for the total number of components (floats) you can pass through varyings, but I think you hit the first limit right now.
The problem is solved after combining 4 float varyings to a single vec4. It even worked in regular chrome. So I didn’t further optimize. I actually did the same before. It didn’t work because I left the 4 float varyings as comments. I guess BJS preprocess still picked the commented varyings?
What is this limitation you mentioned? one for the total number of components (floats), is it the same as varyings but flatten to total number of floats?