Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Is it worth creating texture atlases for mobile with URP?

Discussion in 'Universal Render Pipeline' started by Meceka, Mar 29, 2020.

  1. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    386
    We have a project that also targets mobile platforms. In the past years, to reduce draw calls we have been working a lot to have dynamic batching to as many objects as possible.

    For this, we have always created texture atlases for almost every object and many objects share the same material. We try to have as little material count as we can. I will give 2 examples;

    1st example: Traffic lights, street light, all traffic signs, bus stop, trash bins all share a single atlased material. All traffic cars share a single atlased material. Vegetation is also atlased.

    2nd example: We have an object with 4 color variations, instead of making 4 materials, we made a single larger texture that includes 4 colors in it.

    These all currently batch with dynamic batching and helps a lot in CPU performance cost.

    But we are going to switch to URP soon, and when doing so, (if I understood correctly) SRP batcher can batch objects that share "same shaders" instead of how dynamic batching does with "same materials".

    So for the 4 color variation example, if I use a texture with single greyscale material but use 4 materials that have different colors (from material property), these would still batch with SRP batcher and I wouldn't lose performance.

    And for the 1st example, then it doesn't make sense to work on atlasing such objects. We can just have unique materials/textures for every object. If they share the same shader they will still batch.

    Am I correct with these assumptions? And does making texture atlases for first case also reduce the GPU's load?

    Does SRP batcher have a vertex limit like dynamic batching (in example 300 vertices limit)

    Thanks,
    Mehmet
     
    PerunCreative likes this.
  2. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    111
    We are also in the process of switching to URP and that's exactly what we are investigating as well. Going through the docs it seems that it is still beneficial to reduce amount of materials, since each material adds memory overhead (both RAM and VRAM). However once everything is set up, there is no longer the need to upload material data from CPU to GPU since they are already uploaded unless there is modification (e.g. color changes etc.)
     
  3. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    386
    I also think having more materials in the way you explain should have more memory overhead. But a better comparison would be like that.

    1) Texture atlas for 4 different objects: 2048x2048 texture and 1 material
    2) 4 unique 1024x1024 textures and materials for 4 objects but has same shader.

    I think both options should be pretty similar in memory overhead. But with dynamic batching 1st one batches better. I'm not sure about SRP batching.

    There are also cases like this;
    There is a big building with lots of detail. For versatility I want to make a 2nd version of this building using another buildings roof texture. And lets say the only way to have it is by adding a second material submesh to the building.

    We hesitate doing this because of draw calls. But perhaps with SRP batching there isn't an additional cost for adding a second material (that's already used for other buildings) to this building
     
    Last edited: Aug 7, 2020
  4. edub101

    edub101

    Joined:
    Jul 16, 2015
    Posts:
    36
    Was there ever a definitive answer to this question? Can we ditch the atlas and focus on keeping shader variants to a minimum, rather than materials?
     
    Ruslank100 likes this.
  5. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    329
    +1 Would like to know this as well.
     
    Ruslank100 likes this.
  6. ridethefader

    ridethefader

    Joined:
    Jun 17, 2019
    Posts:
    44
    +1 here as well.
     
    Last edited: Aug 30, 2020
  7. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,582
    Is there any reason you don't test it yourself? Make a test for each case and look at the Profiler and Frame Debugger to find out how each test performs.
     
unityunity