Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

SRP Batching Optimization -

Discussion in 'Graphics Experimental Previews' started by ZackNewworldcoders, Jul 7, 2019.

  1. ZackNewworldcoders

    ZackNewworldcoders

    Joined:
    Jul 19, 2016
    Posts:
    20
    Hi everyone!

    Thank you for the help in advance!

    Im working on optimizing my forest, as i use some nice assets that are not optimized for batching, and for the density i would like to create, it is a very good idea to save performance this way.

    I am using Unity 2019.1 on HDRP Preview... i have done alot of research into how the new batching works, and i have tried to play with the MeshRender.SortingLayer (which dosnt seem to have any effect in new unity/hdrp) and i have also Camera.OpaqueSortMode not to do distance sorting...

    All of my Assets and Materials are set to use only HDRP/Lit Shader
    Between all of my Forest Assets, they are using about 9 materials...

    My problem is that i have almost 5000 batch calls that i could be saving from my forest... i am using a group of about 12 - 15 assets for my forest, so i know this should be able to come down.

    Within the Frame Debugger, i get SRP Batch calls, that seem all over the place, with no sorting, thus they are not batching large groups.

    Within the frame Debugger on the SRP Batch Calls, it explains "SRP: Node use different shader keywords"

    Alot of my assets seem to share the same shader keywords, although the order might be off...

    My main Questions are:

    1) How can i Sort or Group or Organize my assets so that the shader keywords are grouped together to lower draw calls/SRP Batch calls?

    2) Are Shader keywords, the activated properties on the materials im rendering? im noticing things like "_NORMALMAP" leading me to believe it is rendering an object with a normal map, then one without. which would result in the 2 SRP Batch calls im seeing. If im understanding this correctly, is it that i must set pretty much the exact same Keyword values (Smoothness,Metalic, DoubleSided,AlphaClipping) and thus it would see them as the same, and batch render them in one call?

    3) The framedebugger does not seem to tell me what game object its rendering, i belive i saw a tutorial that, when clicking on a render call it would highlight the gameobject in the Hierarchy, however its not doing this, mostlikley because they are placed trees on a terrain, and grouped under terraindata, which i could understand why they are not selected (haha)
     
    tylo likes this.
  2. tylo

    tylo

    Joined:
    Dec 7, 2009
    Posts:
    154
    I'd like to bump this for some tips.

    I am working in a project that uses ShaderGraph shaders, and am running into a similar problem.

    In my case, I have the FrameDebugger reporting to me that it's creating a new batch because

    SRP: Node use different shader keywords


    Yet, the frame debugger also reports that each batch is using the same shader, and shows no shader keyword differences.

    Here is a screenshot to illustrate what I am talking about.

    This is using Unity version 2018.4.1f1, the LWRP, and a ShaderGraph generated shader.

    https://imgur.com/v5ofCOC
     
  3. ZackNewworldcoders

    ZackNewworldcoders

    Joined:
    Jul 19, 2016
    Posts:
    20
    hi tylo, i was able to reesolve this problem by using the same meshes,

    I had previously merged a bunch of objects mesh's into one single mesh, thinking this would be a better way to optimize and it was not.

    Node uses diffrent shader keywords can also mean that its drawing the same texture but on a diffrent mesh, so it cant batch it in the same drawcall. reach out to me if u have questions!