Hi, will the unity team ever fix this issue that stops me from building? This error shouldnt happen in the Lit shader ever. I’ve noticed that it may happen in shadergraphs that use many textures after a lot of google searches. But the Lit shader doesnt use that many textures. I’ve had a bug report on this for more than 6 months. When will it get fixed? I somehow managed to build until now by reimporting the URP assets every time i tried to build but that doesnt work anymore. I just tested in 2021.2.3,4,5,6,7,8,9,10 and 14, and in 2022.1.0b11. I am stuck because of this and it doesnt seem like it will be fixed soon. I’ve been promised in my bug report that it will get fixed after the christmas vacantions, but it’s 12 march and this stuff is still going on. It’s somewhat outrageous if you ask me.
Nobody seems to care about this problem. It may not happen for everybody because usually people dont have big projects but im definitely not the only person with a big project here. I think the cause is many lit materials and not everybody has this many lit shader materials in the project.
Well my assumption seems correct. So i added 3 more maps in my game and all of those environment assets had urp/lit shader. Before adding those maps i could bypass the error by reimporting the urp asset and forward renderer before building. After adding those maps i couldnt. I made all those materials simple lit and now i can build again.
There are weird issues going on with the lit shader since urp 12. Hope they will be fixed soon. Simple lit doesnt look the way i want, i need the lit shader.
Hi there, I must’ve missed this reply, this is a game-breaking bug but it wont be fixed anytime soon? I just upgraded to 2021.3 and i cannot build again. Wow.
Just popping this in here as well in case anyone else needs this info (swontonb and I had a little chat via dms)
how do you even modify the lit shader? It comes back to default code after compiling, since its in packages folder.
You just copy the URP package from Library/PackageCache/com.unity.render-pipelines.universal@12.1.6 to the Packages folder (so you end up with Packages/com.unity.render-pipelines.universal@12.1.6) and that makes unity use the local folder instead of re-downloading it
As for what features to remove… if you dont use light cookies for example you should be able to just edit the Lit shader and comment out all the “#pragma multi_compile _ _LIGHT_COOKIES”
If you don’t use Decals you can comment out the “#pragma multi_compile _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3” etc
(there’s gonna be multiple of that in the shader)
For me taking out light cookies solved the sampler issues, but your project may have different needs
If you use the shadergraph you’ll also have to modify the keywords shadergraph adds (which was easier than expected, code is quite tidy), you want to look at the URP/Editor/ShaderGraph/Targets/UniversalTarget.cs there
For light cookies, thats on line 1783 in 12.1.6, you can now look at the uses via your IDE of choice or, if you’re just using lit targets the exact spot where its referenced is in UniversalLitSubTarget.cs line 814 onwards - just remove it from there and shader graph shaders wont reference it either anymore
For example:
Dang man you saved my life! Allthough i was using light cookies i choose the ability to build. All i did was saying #define light cookies instead of #pragma multi_compile, as you mentioned in the 2nd post, in the urp lit shader code and the variants went from 1500M to 250M. Unity URP team messed up the light cookies, that was the cause of the sampler limit. I did that because i read your other post here:
Btw if you want to use decals it’s safe to do it, light cookies seem to be the main problem. I use decals for bullet marks and blood splatters.
Regarding huge build times… i kinda got used to it, the first build takes ages, the second is faster. Without cookies its a lot of times faster (from 1500M variants to 250M).
Thanks a lot man! If it wasnt for you to have this issue and be able to report it I’d be stuck forever. My project is 90 gb, kinda hard to send a bug report with it.
OMG! Thank you so much! After I commented out the cookies, the installation package was reduced from 1GB to 700MB, the build time was reduced from 5 hours to 2 hours, and the RAM usage was also reduced…
Don’t worry, this is still the case even in latest beta… to which i decided to switch just to see if i will be able to build… but guess what… i can’t… latest 2022.x fails to build with some errors that can not be even traced… and latest 2023.beta just gives me the same error as original post… so guess how much you can rely on URP
Getting this on 2022.3.0. I use light cookies, but disabling the feature in the URP pipeline asset files didn’t prevent the error anyway. Suddenly unable to build my project… what gives!?
Update: After digging through my recent commit history, it seems that this error is being caused by enabling LOD Cross Fade on my URP pipeline asset. The build actually still goes ahead but this error is logged in the background:
same fix as above, take the URP package from library>package cache, paste it in packages folder, right near the manifest. This way you can edit the lit shader and comment light cookies. That’s the only way to get rid of maximum sampler error
For me 2022.3 brought whole new bunch of errors, like 10-15 errors in all URP shaders. The merging shaders into one was a big fail and i basically cannot send a bug report. It only happens when the project is big and has a lot of materials I believe, just like the maximum sampler error. It cant be reproduced in a small project, you must have thousands of materials.