Are shader variants good for quality options?

I’ve introduced few boolean shader features in attempt to create diffrernt quality settings of the shader. My hope is that by turning them off, shader would not compute anything before this switch. Is this a fair assumption or not really?

I see no big performance difference on mobile using those variants , there are huge GPU side spikes every 5 seconds as long as the object with this shader is active. Shader itself does not seem to have anything related to this timing, might be GPU throttling maybe. In a very basic form it is basically a sine wave with some sampled noise.

Any ideas?

Shader graph branches are dynamic, which means both options are calculated and it will pick the right one afterwards.
This can gain performance on older devices if the calculations are simple.

I think you can use static branching or if statements done in hlsl custom nodes, but I have not benchmarked this.

If a feature is very heavy I suggest making 1 shader graph with it and 1 without it, and switching out the shader per platform.

I think ShaderFeature variables are meant to end up instatic branching. Unity - Manual: How Unity compiles branching shaders What I’m not sure is whether shader compiler is able to remove unused nodes in such case to save performance.

100% if it uses the keyword mechanism (from the node I can infer that this is what is being used) it creates shader_feature pragma directives and therefore completely separate shader variants, one of which does the additional calculations and one that does not even have the code to do it.
You should be able to rely on this path being not present in the final shader code (I guess you could look at the generated shader files to make sure it really works.

Likely your spikes come from something different and not this particular branch of your shader and you might only be doing rather light gpu work in your branches hence you don’t see a noticeable change.