Search Unity

Terrain Vegetation doesnt get batched / Baking Terrain Vegetation to Meshes?

Discussion in 'World Building' started by Kareeem, Apr 17, 2019.

  1. Kareeem

    Kareeem

    Joined:
    Mar 1, 2013
    Posts:
    37
    Hey there,

    I am quite surprised to find out that the vegetation we painted on the unity terrain will not get batched. The prefabs used on the terrain are of course marked as static. The terrain itself is also flagged static...

    I cant really believe that this is not possible ( or am i missing something? )!

    If that is really the case I would be interested in a method to bake the vegetation to meshes and batch or even combine them via Meshbaker.

    Does somebody have a hint how to approach this?

    Thanks a lot in advance!
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Did you check "Use Instancing" on your vegetation material?
     
  3. Kareeem

    Kareeem

    Joined:
    Mar 1, 2013
    Posts:
    37
    You mean GPU Instancing in the Advanced Options of the prefabs material?
    ... but then it wold not be batching anymore rather than GPU Instancing, right?

    upload_2019-4-19_17-37-14.png
     
  4. Kareeem

    Kareeem

    Joined:
    Mar 1, 2013
    Posts:
    37
    Ive checked GPU Instance in my materials and its true. There are a lot more "saved by batching". It doesnt help the framerate though. I also tried GPU Instance Asset and that did some good. I have an other scene though where even with the GPU Instance Asset the framerate stays the same. So I would like to try to get these assets batched rather then using gpu instancing. Andy ideas?

    upload_2019-4-19_17-57-0.png
     
  5. Kareeem

    Kareeem

    Joined:
    Mar 1, 2013
    Posts:
    37
    anybody?
     
  6. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Batching would not help in your case. Your performance loss is coming from trying to render ~83 million triangles to screen per frame. Reduce the poly count of your objects.
    As for Instancing, Unity doesn't seem to implement it properly for situations like this, which is why assets like GPU Instancer exist. It's a shame because Unity just updated their terrain engine, but placing foliage on said terrain is hopelessly broken. Instead of making useful features for game developers, their priority has been on making tech demos like ECS. I recommend checking out Unreal Engine. Their Foliage tool is top notch.
     
  7. ThreattecJake

    ThreattecJake

    Joined:
    Apr 2, 2021
    Posts:
    1
    Did you end up finding a solution to this problem Kareem? I am running into the same problem right now... no matter if I enable batching or GPU instancing on my trees, Saved by batching always stays at 0...
     
  8. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I think the best solution for terrain trees would be to use some sort of billboarding/imposters system as billboarding greatly reduces polycounts. By default Unity has billboard renderer which automatically picks trees if you set them correctly (currently only Build-in render pipeline is supported, no URP or HDRP supported for this, see more details here).

    You can also take a look at my repos and compare different examples of billboarding:
    https://github.com/chanfort/Tree-billboards-stress-test
    https://github.com/chanfort/Imposters-stress-tests
    https://github.com/chanfort/Custom-billboard-renderer