Use of Sampler State Node?

Hi,

What is the main purpose of the Sampler State Node, to reduce the number of samplers and optimize the shader, right? So, I should use it as much as possible with similar mapped textures?

Also, is there a good resource about optimizing the Shader Graph, what nodes are most expensive and etc? I’ve failed to find any good articles about Shader Graph optimization.

I always optimized shaders by eye and FPS, adding shader variants, lowering texture sizes and etc. But lately wanted to try precise optimization, or maybe just to have a tool to uniformly test separate shader in terms of how performant it is. But not something super complex like Nvidia Nsight, something like UE4 shader performance heatmap, but I checked HDRP for something similar and didn’t find it. Or maybe just instruction count of selected part in Shader Graph.

There is a documentation about Sampler State Node: Sampler State Node | Shader Graph | 6.9.2

In shortly, it changes behaviour of texture sampling. If you’ve played around with a texture’s properties before you should have seen “Wrap Mode” and “Filter Mode”. It is the same thing with that node.

An example usage of sampler state node:

Unfortunately, I don’t know any resource about optimizing the Shader Graph. But I think if you are not writing too complex graphs and math calculations, it should be work fine.

2 Likes

Hi there! With regular shaders you can Compile and show code to get an aprox instruction count. With SG is not possible of course, why would it be… So you can copy the code, paste it in a regular shader and check the instrucrion count.

While this instruction count doesn t tell anything about performance or any real cycles count, at least you can compare if any changes you make, increase or decrease the instructions.

Recently I watched this quite informative video on this topic:
https://www.youtube.com/watch?v=y0QASid1v8w

1 Like