Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Static Batching not working in URP project and I'm not sure why

Discussion in 'Universal Render Pipeline' started by SilverDaller, May 8, 2021.

  1. SilverDaller

    SilverDaller

    Joined:
    Apr 25, 2021
    Posts:
    5
    Hello! I am a beginner with unity and game dev in general, so alot of this stuff is new to me. I was watching some videos and read some documentations about static batching and how it can help in reducing draw calls by grouping objects that share the same material. I've been building out a level (using tilesets, my level is made up with tons of tiles which I'm still trying to figure out a way around how to build levels with the modularity that tilesets provide but without having to sacrifice all of that performance), and I thought that maybe I can take advantage of batching. So I look at the stats while playing my level, and I'm getting about 350-500 batches on avg with 0 saved by batching. That confused me because alot of the tiles I'm using in the level use the same material. I use several mixed lights in my scene, and i'm using the progressive lightmapper with baked indirect lighting mode because the unity forums recommends that for an indoor setting. So I whip out the frame debugger to see whats going on, and I see that the cause for the batch breaking is due to "SRP: Node use different shader keywords". I look at the materials of each SRP batch draw call, and they use the same keywords and the same material, so i'm quite confused why its not working. Before its suggested I should say that yes static batching is turned on in my settings and that almost all meshes in my scenes besides the doors are marked as static objects. I will share some screenshots below to describe what I'm looking at.

    SIDE NOTE: For other optimizations, I'm using occlusion culling so that Its not always keeping things rendered while I'm not looking at them. I'm also using lightmaps and avoided real time lights (I know that mixed also uses realtime lighting and baked lighting, but I think for my scene thats filled with 99% static objects It should behave as a baked light source? correct me if I am wrong please :) ). Please point me in the right direction of how I can utilize static batching, what I can watch out for, and if you have any tips about reducing the performance impact of using too many tiles in my level please share that with me if you will :D


    EDIT: Upon inspecting the pictures I posted, I looked at the keywords the debugger is showing, and I do see that one call has an _OCCLUSIONMAP_ keyword while the one after doesn't. It seems that the image showing event 121 vs 122 doesn't actually show my problem at all, but what I was trying to illustrate with that is I thought that the wall that pops between event 121 and 122 would joined or be batched with the walls drawn in event 106 thats shown in the "Debug 1" image I uploaded since they do share the same material and keywords. I don't quite understand if its because of the order the batching is happening, or what?? I do not know :/, please clarify to me I super confused.
     

    Attached Files:

    Last edited: May 8, 2021
  2. SilverDaller

    SilverDaller

    Joined:
    Apr 25, 2021
    Posts:
    5
    Here's event 106 that I reference in the EDIT segment. Sorry for the messy post
     

    Attached Files:

  3. Brother_77

    Brother_77

    Joined:
    Feb 8, 2019
    Posts:
    226
    I got similar issue the batches are not saved and the frame debugger is still showing the same amount of draw calls as the static objects that should have been batched


    "SRP: First call from ScriptableRenderLoopJob" the reason?

    Soo frustrating. Something so basic is a rabbit hole that I can't get out of