Search Unity

Individual prefabs vs prefabs of prefabs for performance?

Discussion in 'General Discussion' started by Widanon, Apr 12, 2021.

  1. Widanon

    Widanon

    Joined:
    Jan 31, 2021
    Posts:
    36
    Hi - I want to scatter trees around to make a dense forest, but obviously it increases my poly count a lot. I was wondering if there is any performance benefit from first making prefabs of tree groups, and then scattering these groups around, vs just scattering the trees around individually. Eg. 10 x group of 10 instances vs 100 individual instances

    I guess the CPU/GPU has to draw the same number of faces whichever way, but I wondered if grouping them would make it work less 'hard' somehow.

    Or is there any other way to create a realistically dense forest, without maxing out my poly count? Thanks.
     
  2. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Use vegetation studio. It has instancing support
     
  3. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    I had good success almost recreating the density of a southern Appalachian sub tropical rainforest using the Unity Tree Creator and creating clusters of trees. SpeedTree was a big slowdown gorgeous as it was. If you buy terrain kits they usually have proprietary workflows.
     
    Ryiah likes this.
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,634
    As far as I know, prefabs are just an editor convenience feature, and won't have any affect on performance vs individual objects.
     
    FernandoMK and angrypenguin like this.
  5. stain2319

    stain2319

    Joined:
    Mar 2, 2020
    Posts:
    417
    You might look into a Mesh combiner asset which can reduce your draw calls substantially.
     
  6. Widanon

    Widanon

    Joined:
    Jan 31, 2021
    Posts:
    36
    Thanks for confirming kdgalla- I've been using a prefab painter which just creates all the instances under one container object, and I wondered if this would be less efficient that cloning predefined groups, but I guess not - end of the day it's the same number of faces...
     
  7. Widanon

    Widanon

    Joined:
    Jan 31, 2021
    Posts:
    36
    Thanks Stain - I will investigate.
     
  8. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    GPU Instancing is the approach used to render many copies of the same mesh in an optimal way.
    This is how tools like Vegetation Studio Pro are able to achieve performant results with lots of trees and grass.