Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Use of Sampler State Node?

Discussion in 'Shader Graph' started by DuvE, Oct 30, 2021.

  1. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    167
    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.
     
  2. Warwlock

    Warwlock

    Joined:
    Aug 17, 2018
    Posts:
    40
    There is a documentation about Sampler State Node: https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Sampler-State-Node.html

    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:
    Capture.PNG

    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.
     
    Crabikels and stellamocha like this.
  3. BOXOPHOBIC

    BOXOPHOBIC

    Joined:
    Jul 17, 2015
    Posts:
    506
    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:
     
    DEEnvironment likes this.