maximum ps_5_0 sampler register index (16) exceeded
I have read that its maybe because of the target platform supports Shader Model 5.0, and the max Texture sampler number is 16, and if there are more Texture Sampler nodes are in the shader graph than 16, then the error will appear.
Is there a way to solve this without remaking the shader graph?
Can I make preprocessor directive-like nodes into the shader graph?
#What is the best way to solve this shader graph issue?
1 messages · Page 1 of 1 (latest)
as I read, maybe the best solution is to create 1 Sampler State Node and connect that to all of the Sample Texture node's Sampler input, and that's all?
Yes, that might work. Though obviously all the texture will have to share the sampler state.
you dont have to connect them all to the same node, you can create separate nodes, the graph is smart enough to figure out which textures share the same sampler settings
and is it normal that the shader graph compiles for 14 hours now (only this one)? I selected the shader graph and I'm compiling only for build platform
and its not freezed out, its still ongoing
@rigid spoke
haha wow, you need to remove some shader keywords
how? if its a shader graph
you added shader keywords yourself, did you not?
well, its a shader graph written by others million years ago
well, maybe you want to take a look at it anyway
so there might be keywords, I have no idea
I mean I'm not pro at shaders, I'm mainly a gameplay programmer
like, specify which shader stage(s) they are needed, and check shader feature vs. multi-compile depending on if you activate them through code or not
so can you help me what to look for?
yeah, you'll need to open it and look for parameters of the type "enum keyword" and/or "keyword"
so should I cancel it?
@marsh pelican okay, so I cancelled the compilation.
How to open it?
where should I find the "keyword" part?
look for the shader graph in your project, I don't know it's name but i expect it's something like TerrainIce ?
you can filter by shader graph with t:ShaderGraph
you need to open it
do you have knowledge about what kinds of features you need from this shader, in your project?
I have zero knowledge about it
absolutely zero
pretty huge shader graph
what a joy to look at 🙈
so as someone with zero shader experience, what should I do with this?
it's not very different from regular programming, except that this is code that is executed for every vertex or pixel
I know that part
I know its probably a vertex and fragment shader
right, so you need to try and look at the keywords and see what code is activated/deactived by them
but my knowledge is almost ends here
and see if you can identify keywords that have very little attached to them
those you can replace by a regular branch instead of a shader keyword branch
and how to open the code?
this is the code
I thought you mean the generated code
well, you can look at that, but that's much harder to read
do you have a lot of materials that use this shader?
and are you working alone on this or are there others that know more about this shader?
no idea. I only know about one thing which is using this shader
well, you need to figure this out, to be able to make changes you need to be able to update the materials that use the parameters
there's one, but he's assigned to other stuff
and you need to find out if there are places in the code where you set shader keywords on materials using this shader
you can see if a keyword can be overridden with a global keyword, if the Is Overridable option is checked
they are inputs, like regular material parameters
you can see the type of input parameter next to the name
well, they're called Properties, officially
well, in the left side I can see lot of input parameters like SnowDirection, SnowIntensity, etc., but these are not appearing on the right side
if you hover over them, it will highlight any nodes in the graph that are linked to the input
the keyword boolean and keyword enums are the ones you are interested in
I also recommend you make a backup of the graph (and the materials, if that's feasible), that way you can relatively easily go back if things go wrong
(and compare)
well, we use version control
yeah, but even then, you will want to be able to compare them
but those are not here in this list
oh never mind
they are here
some of them
its possible some of them may exist only in the custom hlsl nodes
a lot of them are added by unity
I can only see 3 keywords appearing in the left side
and if I hover them, I can see them in the graph
so that means all other keywords are unnecessary?
no, it just means your shader does not use them itself, but they can still be used by the render pipeline and such
shader graph adds them for you
during build, any unused shader variants are usually stripped and not compiled
you can also customize this stripping process if you know certain keywords are unnecessary
these ones, I guess you are using HDRP?
there is some information about shader stripping here
https://docs.unity3d.com/6000.2/Documentation/Manual/shader-variant-stripping.html
it also talks about keywords
yes, HDRP is being used
I fidn it surprisng you have 62 thousand shader variants and only added 3 keywords in the graph yourself
are they enum keywords?
its _OTHERWORLD_MASK_ENABLED which is boolean
_TESSELLATION_ENABLED, also boolean
_MATERIAL_QUALITY (built-in enum)
how many quality settings do you have in your project?
5 pieces
that's not a lot of keywords in the blackboard indeed
okay, I suppose you use them and that you need the material quality
yeah, these 3 keywords are being used in the graph
and about the qualities, yeah, those 5 are used
at least 3 of them for sure
but maybe all 5
in the HDRP asset you should be able to find the quality level in the material section and verify they (material quality settings) are all three in use (low, med, high)
I never used HDRP, but there's a page on reducing variants for HDRP specifically
for this one, and the tesselation enabled one, you may want to check if they are shader features or multi-compile
also check if they enable/disable a lot of code
if its using shader feature, it will only compile the flag with the settings coming from your materials; if all materials use the same setting one, modifying this keyword will not do much for you
if its multi compile you need to see whether the keyword is set through code
otherwise you may be able to replace it by a regular branch
beyond this, i guess you would have to dig into the custom hlsl nodes, which may or may not be easier depending on the code
so basically I should look for if our project is not using some of these
and those could be set to the suggested values here?
okay, thx. I'm not sure if anyone if the project would be able to answer which of these are being used
but I will try
the whole shader is more than a year old
probably 2-3 years old
yeah you may have to dig a bit then, find references and all that
ah though for features that is a bit harder indeed
@marsh pelican so if I look into the generated shader code
can't I just CTRL+F and search for the keywords one by one?
although if I would see a keyword not used in the generated shader anywhere, how could I remove that from the graph itself
for this shader I think you first need to find all the custom HLSL nodes in the graph itself and see what code (and keywords) is added by them
if a keyword is not used in the generated shader, I don't think it would be compiled for the graph either
the problem is keywords that do something, but are not actually used by anything in the game
or dont do something useful
okay, so then why did you say to look for unused keywords?
if we can't do anything with it
I don't think I said to look for unused keywords ? 🤔
okay, maybe I misunderstood you then
I got an info that maybe this shader is not even used anymore... 😄
that should be possible to verify by traversing the references
but that would be great 😄
it's still referenced by something though, otherwise it would not compile of course
yeah
I tracked shaders with Project Settings
and it got found
@marsh pelican can't I just set quality to low and disable all other qualities?
won't that speed up the compilation?
I would, but for now I would just check everything else in the target platform
if other stuff works
I would honestly temporarily disable this whole shader
if I could
if you just want to do it locally, you can always do find all references and change the shaders of the materials that use it
or simply delete it
well, I could do it with this shader, but there's an another one, which is similarly bad
and that's being used by a lot of things
well, I have to go unfortunately, but you have a lto more information now
so I think you can find a temporary solution at least
are those "lot more information" in the same room with me?
well, yeah, but I need to fix it primarily, or at least get it compiled in a bad quality
if it could got compiled in a worse quality, it would be enough for me for now
I think you can remove all the other quality levels then
that didnt help?
nope, still 62K variants
and still it was slow after 17k (the point it got compiled during 14 hours)
the weird is that this shader got compiled well for other platforms
I never had this issue before
with this shader
strange, unfortunately I'm a little out of my depth here (and out of time)
@rigid spoke if I use shadervariants file (generated by tracking used shader variants), then for shader compilation, it would just received from that file?
Not sure. What do the docs say?
Normally unity would strip variants that it decided would never be used. And compile any that might potentially be used. Based on different project settings.
I don't really understand based on this about what should I do
You'll need to be a bit more specific.
it says: "Check what shader variants you have to help you see which shader variants and keyword combinations Materials need at runtime."
well, based on the link it writes
no information is provided
and no info about how to set to include only the necessary ones
its very hard to ask, when I don't understand the whole thing
when I start to compile the other shader called Lit/Actor, it says I have 100K variants... for the TerrainIce it says 62K
are those all variants really needed based on the project?
You don't really have direct control over that. Unity collects the used keywords based on project, rp, renderer, lighting and other settings and compiles all the possible combinations.
Reducing the amount of quality setting tiers, disabling features in the render pipeline settings could help
like this?
There's not correct. It depends. And I've no clue what automatic does, or how it decides if to strip or not. Might need to look at the docs.
I'd start with these things that you can modify right away without introducing any breaking changes into the project
Another thing to consider is if the shader cache is used. Normally, only the first build should be heavy, while consequtive should skip shader compilation, unless there are new variants required.
for other platforms even the first build didn't took for 10+ hours
only 2 hours
Then it uses way less variants. Or you already had some shader cache
and these 2 shaders were not changed in the last 2 years
nope, variant number is the same
I just checked it
the whole shader graph is the exact same, and if I comple those, I also get 100K and 62K variants for them
How did you check that?
I selected the shader graph in the other workspace and I clicked on compile and show code button
That should only compile one variant I think.
I didn't have shader cache 🙂 I cloned the project the same way
just selected a different target platform
that's all
Or rather, it generates the shader code, not compiles the variants
then why it tries to compile all variants?
but anyway... even if I created a build for the other platform for the first time, it took for 2 hours
not 10+ hours
even if we don't consider this "compile and show code" button
When you click "generate and show code"?
yeah
Because it doesn't compile shaders
It generates the shader code from nodes. Doesn't compile it.
then what it does
okay
then how to compile shaders? only with creating build for target platform?
Normally yes, because:
- It uses platform specific compiler.
- It uses platform specific configuration, keywords.
I think shader variant collections can be used to precompile them at will, but I don't know much about them
it just literally says the name of the NDA platform
but okay then
still the first build took 10+ hours instead of 2 for the other platform
Customizing these might actually help quite a lot. If you know what is used or not used in the project.
so that's not normal it differs
"If you know what is used or not used in the project."
yeah, I tried to figure it out in the past few hours, and I didn't receive too much info
What was the other platform? If it was windows, it might have been using shaders compiled in the editor.
nope. 2 different consoles.
NDA
both are NDA, but different NDA
Well, then either they have a vastly different shader variant numbers, or the other platform shader compiler is fast fast, compared to this platform
Some platforms have several compilation passes too.
I saw on the progressbar that it used the exact same amount of variant numbers
"or the other platform shader compiler is fast fast, compared to this platform" maybe that will be the case
Then it's probably fast fast
Could be the compiler settings too. Some could be spawning several compilation processes or threads to make use of all your cores. Other might be configured to be single threaded... Really hard to tell without actually investigating it.🤷♂️
could the enabled graphics debugging have something to do with slower shader compilation?
Yes, quite likely, though can't say how much.
There's also the other side to it where compiler optimizations are enabled