0
\$\begingroup\$

I just recently imported a new asset package, all of the materials use the URP lit shader, no custom shaders. However, now I can't build the game because I keep getting the same errors:

Maximum ps_4_0 sampler register index (16) exceeded
Maximum ps_5_0 sampler register index (16) exceeded

I'm using Unity Version 2021.3.45.

I understand that it means the Sampler states has exceeded 16, but the problem is I can't find the root cause, nor fix it because URP Lit is a package file so I can't change it.

There is the imported asset.

Here is a screenshot of the errors:

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ These errors can sometimes be version specific - please edit to include the build number you're using. \$\endgroup\$ Commented Aug 16 at 22:10

1 Answer 1

0
\$\begingroup\$

This is a known issue in Unity, currently marked as "postponed" in their issue tracker.

You can find tips to work around it at that link and in other threads about the problem, including:

  • Disable LOD Cross-Fade or Light Cookies on your URP pipeline asset.

    • If you don't see this, go to Preferences > Core Render Pipeline, and set "Additional Properties Visibility" to "All Visible"
  • If you're on an earlier version without this setting, you can...

    • Copy the URP package from Library/PackageCache/com.unity.render-pipelines.universal@##.#.# to your Packages folder, so you can edit this local copy without it getting reverted.

    • Then edit the lit shaders to remove #pragma multi_compile directives you don't need, like _LIGHT_COOKIES.

  • Some users have also reported that caching glitches can cause this error to pop up spuriously. Deleting your Library folder and re-opening your project will force Unity to re-import assets / re-compile shaders, and sometimes fixes intermittent errors like this.

I found these just by taking the name of the file the error message complains about and putting it into a web search, so make sure you do this as one of your first troubleshooting steps, to find answers faster.

\$\endgroup\$
2
  • \$\begingroup\$ Well it worked, but I'm now getting the same problem with Shadow.hlsl. \$\endgroup\$ Commented Aug 19 at 11:51
  • \$\begingroup\$ It's not necessarily the light cookies or shadows causing this specifically. It just complains about the last file it was reading before hitting its limit. Following this general pattern of disabling features you don't need should eventually get you under the threshold where all the files compile successfully. \$\endgroup\$ Commented Aug 19 at 12:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.