Search Unity

Bug Terrain vegetation texture memory issue

Discussion in 'Editor & General Support' started by RubberBandGames, Aug 9, 2022.

  1. RubberBandGames

    RubberBandGames

    Joined:
    Jul 20, 2020
    Posts:
    170
    Hello,

    In our project we have a bunch of terrain which have to be loaded due to multiplayer reasons. These terrains all have the same-ish vegetation textures i.e grass/flowers/sea weed etc. However even though these are basically the same for each terrain, Unity makes a new texture atlas for each terrain (Which results in 15+ textures which are exactly the same resulting in memory being used up for the same thing, we've had to reduce our grass texture size from 256x256 to 16x16 so that our title fits in the memory budget.

    Can someone give us a solution to this as we want to increase the quality of our grass.

    Here is what it looks like in the memory profiler (Circled red is the duplicated textures) I can confirm this is also the case in a build and is not Editor only.

    Unity version: 2020.3.34f1



    Different texture2d but same image (Why?) Why can't they just use 1 texture atlas for all the grass?

     
  2. RubberBandGames

    RubberBandGames

    Joined:
    Jul 20, 2020
    Posts:
    170
    Hello,

    Does anyone have any ideas?
     
  3. RubberBandGames

    RubberBandGames

    Joined:
    Jul 20, 2020
    Posts:
    170
  4. vvvvalentin

    vvvvalentin

    Unity Technologies

    Joined:
    Nov 11, 2015
    Posts:
    4
    Unfortunately, there doesn't seem to be a way to force terrains to use the same vegetation atlas. Starting from 2021 there's an option to use GPU instanced details to share the textures. Have you considered upgrading?
    Another option would be decreasing the number of terrain instances, but I assume this is what you tried first.

    You can also try grabbing the data that the terrain uses to generate the instances and convert that at build time into a point cloud to do manual GPU instancing. Maybe something like this is going to help:
    https://assetstore.unity.com/packages/tools/utilities/gpu-instancer-117566

    Another option might be converting grass into "trees" — that won't need instancing. These should be handled by batching, so there is going to be extra CPU cost and needs testing.
     
    RubberBandGames likes this.
  5. RubberBandGames

    RubberBandGames

    Joined:
    Jul 20, 2020
    Posts:
    170
    Okay thank you.