Search Unity

Question Disable SRP Batcher for one ShaderGraph shader (doc solution not working?)

Discussion in 'Universal Render Pipeline' started by edsonnnn, Nov 25, 2022.

  1. edsonnnn

    edsonnnn

    Joined:
    Jun 1, 2021
    Posts:
    14
    Hello!
    I created a new 3D (URP) Project (2021.3.7f1 LTS).
    Then created a new basic ShaderGraph-Shader:
    upload_2022-11-25_17-55-55.png

    The documentation says (https://docs.unity3d.com/Manual/SRPBatcher.html) for 2021.3:
    upload_2022-11-25_17-56-7.png

    So I click "View Genererated Shader" and copy paste the code into a new .shader file.
    Then I add one new material property declaration into the shader’s Properties:
    upload_2022-11-25_18-8-55.png

    The shader is still being SRP batched:
    upload_2022-11-25_18-11-27.png


    I am thankful for any response!
     
  2. kruskal21

    kruskal21

    Joined:
    May 17, 2022
    Posts:
    68
    I believe in addition to the property, you also need to declare the variable in the HLSL code. Find a place anywhere within the generated HLSL code (between CGPROGRAM and ENDCG, or between HLSLPROGRAM and ENDHLSL), and insert the following line:
    Code (CSharp):
    1. float _ExampleName;
    Give this a try and see if it works!
     
  3. edsonnnn

    edsonnnn

    Joined:
    Jun 1, 2021
    Posts:
    14
    Thank you! Tried it and unfortunately didn't work
    The oher solution in the docs (making renderer incompatible) works, so I'll be using that for now which might be better to work with anyway