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. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

Questions about SpeedTree

Discussion in 'Unity 5 Pre-order Beta' started by netvortex_dc, Feb 3, 2015.

  1. netvortex_dc

    netvortex_dc

    Joined:
    Jan 13, 2014
    Posts:
    126
    Hello everyone,
    i have some questions regarding the SpeedTree implementation. Current issues aside, there are a few things not very clear to me and i was hoping to find some answers here.

    1. When you generate different meshes/variations of a single tree it's using the same textures as the previous one in the modeller. Does this impact performance when, instead of using the same model, i use different variations of the model ? I noticed that the modeller creates new textures and materials for that new variant even if identical, so i was wondering if i can actually gain some performance when just using variants of the same tree.

    2. How do you officially recommend to implement SpeedTree Grass/Bushes. Should it be added as GameObject, like regular Trees or is there a different method ? Does it have a performance impact when placing it as GameObjects ?

    3. When adding trees as TerrainTrees is there any limit ? What's a good maximum ?

    Thanks!
     
  2. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    Hi,

    1.Personally I haven't used Modeler. But when trees are imported in Unity as prefabs, they are treated as different objects. And they will have different materials and textures (unless you share textures by importing them in a same folder), thus memory footprint is increased, and renderloop has to apply material states for each different type of trees.

    2. Placing tons of trees as separate GameObjects is not a good idea. Terrain does lots of optimizations in this situation so do use terrain for forest.

    3. Though being undocumented, in the terrain code I found sometimes we use 16bit integer as a tree index. So to be safe I'd say the limit would be 65k.

    Cheers,
     
  3. netvortex_dc

    netvortex_dc

    Joined:
    Jan 13, 2014
    Posts:
    126
    Hi!
    thanks for the detailed answers! Will help me a lot making the correct decisions for the terrain.
     
  4. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    2. So it would be nice if we have usable alternative for using speedtree grass/bushes. Now it's simply not usable with terrains without custom solution.

    3. I hope that limit of 65k trees applies to one terrain. So if we use more terrains we can bypass this limit..

    Thanks
    Peter
     
  5. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    2. Currently terrain is the only way. If your custom solution is about finer control of trees (like positions, rotations, scalings, etc.) you can use scripts to inject trees. At runtime we recently added TerrainData.SetTreeInstance API for you to fast update a single tree, with the restriction that position and prototype needs to stay the same...

    3. Yes 65k applies to one terrain. You can always use multiple terrains. If you really do want more trees.. (consider don't :)) you probably can file me a bug and I'll try remove this restriction in a later 5.x release.
     
  6. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    I've noticed a huge difference in performance between normal Unity Trees and SpeedTree Trees. In my scene I have close to the 65k tree limit on my terrain. I consistently can run my scene between 90-100+ fps (depending on where I look) when using normal Unity trees. However when I use the sample SpeedTree trees this drops down to about 25-35 fps. Has anyone noticed poor performance like this?

    SpeedTree certainly looks great, but performance has to be there or there is no point. For now I assume this is just a development bug.

    Edit: And to clarify, I'm mainly talking about the billboarded trees! In my example above I am not close enough to any trees to get them to shift into the lower lod levels.
     
  7. netvortex_dc

    netvortex_dc

    Joined:
    Jan 13, 2014
    Posts:
    126
    Sounds like you are not using Version b22 or higher yet... They improved the performance in that build a lot, give it a try!
     
  8. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    705
    So there will be no improvements for terrain to use SpeedTree? We need to go with some custom solution to place speedtrees that will work with LOD?

    Cause now when we placing the trees with terrain brush - LOD of speedtree is not working (and bunch of other terrain tree related parameters) (we on RC1)
     
  9. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    What did you mean by not working with LOD? If your trees have LOD then it should work.. if not could you please file a bug to us with a minimal reproducing scene attached?
     
  10. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    You're right. I downloaded b22 and re-setup my scene. Granted there is a small improvement, now I get about 40 fps, but still isn't really acceptable compared to normal Unity Trees (now 130 fps solid).
     
  11. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,784
    OK, with beta22 there seems to be a HUGE Improvement with near SpeedTree trees (lod0-lod1), but rendering large numbers of billboards is still pretty much an fps killer.
     
  12. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    705
    You right - LOD is working - my terrain was too small to see LOD kicking in - I had to lower LOD BIAS in quality settings to saw difference.