Search Unity

Assets AltTrees System [WIP] [AssetStore]

Discussion in 'Works In Progress - Archive' started by Diab1O, Sep 19, 2016.

  1. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    In the next update, I'll add an API.
    Can you send me a line where the error is?
     
  2. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    I've pasted call stack in my previous message, unfortunately, I have no extra information to share

    BTW, I've fixed this issue and issue with requirement to check "Enable Instancing" flag by changing this lines (patch):
    Code (csharp):
    1.  
    2. 542c542
    3. <                                                 for (int p = 0; p < treesPoolArray[i].objsArray[curLOD].materialsMesh.Length; p++)
    4. ---
    5. >                                                 for (int p = 0; p < treesPoolArray[i].objsArray[curLOD].mesh.subMeshCount; p++)
    6. 550c550
    7. <                                                 for (int p = 0; p < treesPoolArray[i].objsArray[curLOD].materialsMesh.Length; p++)
    8. ---
    9. >                                                 for (int p = 0; p < treesPoolArray[i].objsArray[curLOD].mesh.subMeshCount; p++)
    10. 585c585,592
    11. <                                 Graphics.DrawMeshInstanced(treesPoolArray[i].mesh, 0, treesPoolArray[i].materialBillboardCrossFade, matrixDrawBillboards, attDrawBillboardsCrossFadeCount, mpbTemp, (altTreesMain.altTreesManagerData.shadowsBillboards ? UnityEngine.Rendering.ShadowCastingMode.On : UnityEngine.Rendering.ShadowCastingMode.Off));
    12. ---
    13. >                             #if UNITY_EDITOR
    14. >                             if (!treesPoolArray[i].materialBillboardCrossFade.enableInstancing)
    15. >                             {
    16. >                                 treesPoolArray[i].materialBillboardCrossFade.enableInstancing = true;
    17. >                                 EditorUtility.SetDirty(treesPoolArray[i].materialBillboardCrossFade);
    18. >                             }
    19. >                             #endif
    20. >                             Graphics.DrawMeshInstanced(treesPoolArray[i].mesh, 0, treesPoolArray[i].materialBillboardCrossFade, matrixDrawBillboards, attDrawBillboardsCrossFadeCount, mpbTemp, (altTreesMain.altTreesManagerData.shadowsBillboards ? UnityEngine.Rendering.ShadowCastingMode.On : UnityEngine.Rendering.ShadowCastingMode.Off));
    21. 607,608c614,621
    22. <                          
    23. <                                 Graphics.DrawMeshInstanced(treesPoolArray[i].mesh, 0, treesPoolArray[i].materialBillboard, matrixDrawBillboards, attDrawBillboardsCount, mpbTemp, (altTreesMain.altTreesManagerData.shadowsBillboards ? UnityEngine.Rendering.ShadowCastingMode.On : UnityEngine.Rendering.ShadowCastingMode.Off));
    24. ---
    25. >                             #if UNITY_EDITOR
    26. >                             if (!treesPoolArray[i].materialBillboard.enableInstancing)
    27. >                             {
    28. >                                 treesPoolArray[i].materialBillboard.enableInstancing = true;
    29. >                                 EditorUtility.SetDirty(treesPoolArray[i].materialBillboard);
    30. >                             }
    31. >                             #endif
    32. >                             Graphics.DrawMeshInstanced(treesPoolArray[i].mesh, 0, treesPoolArray[i].materialBillboard, matrixDrawBillboards, attDrawBillboardsCount, mpbTemp, (altTreesMain.altTreesManagerData.shadowsBillboards ? UnityEngine.Rendering.ShadowCastingMode.On : UnityEngine.Rendering.ShadowCastingMode.Off));
    33.  
    34.  
     
  3. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Thanks, I will fix this in the next update
     
  4. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Hey

    Found another issue - if I have AltTrees object enabled I'm getting 30ms stall in FindObjectsOfType at SceneCamera.Finish. If I turn AltTrees object off, everything works fine

    I've tried to disable all FindObjectsOfType in AltTree*.cs code, but this didn't help. Is there any information what might cause this issue?

    EDIT: even if I toggle "Draw" to off, I'm getting this FindObjectsOfType every frame
    EDIT2: issue exists only in Editor, if I hit play, everything is fine
    EDIT3: only disabling Alt Trees game object or AltTrees script on it helps
    EDIT4: I've "fixed" issue by removing [ExecuteInEditMode] for AltTrees, but, obviously, I'm not getting all trees rendered correctly now

    EDIT5 (Fix): by removing void OnRenderObject() I've got all trees back and no 30ms lag
     
    Last edited: Apr 10, 2017
  5. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hey,
    It is very strange. In my scene this function takes 0.76 ms http://joxi.ru/WL21Jg4H4BnBAX
    I will study this problem.
     
  6. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    It should depend on something, our scene is 8 square kilometers and it has tons of trees and objects. Most likely complexity is a key to difference between 30ms and 0.76ms
     
  7. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Hello! I just purchased Altree and I am having some trouble. Basically I followed the tutorials but The system iisn't working correctly for me. The trees are appearing but the ones in front of the camera are disappearing and the editor is just throwing hundreds of "Invalid operation" and "Index out of range" exceptions. Can't seem to figure it out. I'm using the standard asset free speed trees.
     
  8. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hello! Can you copy the text all errors from the console?
     
  9. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Haha, I guese it helps to have the error.

    Im getting
    and
    I've tried going through all the materials (Fresh project) and enabling instancing on the materials and billboards but it didn't seem to help.
     
  10. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Hi
    Will these work on landscapes made with standard meshes or just with unity terrains?
    Thanks
     
  11. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    92
    I think it will be a good decision to have an intermediate update for 5.6 compatibility
     
  12. MarkusGod

    MarkusGod

    Joined:
    Jan 10, 2017
    Posts:
    168
    Can this system be used with ForestVision?
     
  13. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Fix for Unity 5.6

    Find lines 1905 and 1964 in AltTreesManager.cs file (Assets\Plugins\AltSystems\AltTrees\Scripts\AltTreesManager.cs)

    Replace line 1905
    Code (CSharp):
    1.                         treesPoolArray[indexTemp].objsArray[i].materialsMesh[j] = new Material(rendererTemp.sharedMaterials[j]);
    with
    Code (CSharp):
    1.                         treesPoolArray[indexTemp].objsArray[i].materialsMesh[j] = new Material(rendererTemp.sharedMaterials[j]);
    2.  
    3.                         if (treesPoolArray[indexTemp].tree.gpuInstancing)
    4.                             treesPoolArray[indexTemp].objsArray[i].materialsMesh[j].enableInstancing = true;
    5.                         else
    6.                             treesPoolArray[indexTemp].objsArray[i].materialsMesh[j].enableInstancing = false;
    Screenshot
    Replace line 1964
    Code (CSharp):
    1.                   treesPoolArray[indexTemp].materialBillboard = new Material(treesPoolArray[indexTemp].tree.materialBillboard);
    with
    Code (CSharp):
    1.                     treesPoolArray[indexTemp].materialBillboard = new Material(treesPoolArray[indexTemp].tree.materialBillboard);
    2.  
    3.                     treesPoolArray[indexTemp].materialBillboard.enableInstancing = true;
    Screenshot

    If there are problems - write to me, I will send the ready file.
     
  14. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hello! Try to make a fix from the previous message.
    Hi, Yes, it will work (except mass planting of trees on the terrain)
    No at this moment.


    Update 0.9.8 is almost ready.
     
    jangomoose and crudeMe like this.
  15. Totchinuko

    Totchinuko

    Joined:
    Apr 14, 2016
    Posts:
    14
    Hello @Diab1o.
    I'm working on a project that could benefit a lot from an asset like AltTrees. I just have one tiny question. In our setup, we have a day/night cycle, and during sunset or sunrise, big shadows can come from trees outside the view, as the sun is on the horizon. Question is: Will I have any problem of shadow poping with your asset in that situation?
     
  16. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hello,
    Yes, it is may be. But I plan to fix this in future updates.
    At the time of sunset or sunrise, I advise you to smoothly remove the shadows, because Most likely at night no shadows are needed. Then you will gain in quality and performance.
     
  17. Totchinuko

    Totchinuko

    Joined:
    Apr 14, 2016
    Posts:
    14
    Hum ok. But If I start to remove shadow, it will be very noticeable, specially in town. I'll probably get your asset anyway and try to solve those kind of problems by cutting big area's and improving level design. I don't have much solutions, unity current implementation of speed tree is just horrible in term of performance, and the look of the tree creator is... simple.
    Thanks for the information =).
     
    Diab1O likes this.
  18. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Works perfectly now thank you! Also It turns out that using the rebuild/refresh tree data for AltTree prototype data was turning off the instancing. So I was manually setting the materials than assuming that I had to refresh them in AltTree and it was setting them back..haha.
     
    Diab1O likes this.
  19. metteigel

    metteigel

    Joined:
    Aug 6, 2012
    Posts:
    33
    Can anybody say something about VR Performance ?
     
  20. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Is it possible to add Alloy SpeedTree shader support to AltTrees shader?
    They have rather nice and proper tree shader

    EDIT: or, maybe, Lux Plus translucency shader?
     
    Last edited: Apr 14, 2017
  21. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    I do not know, I do not have these assets.
    Most likely not. AltTrees has its own special shaders, and it is difficult to connect other shaders without modifications. Modifications, I can not do, because I'm not the author of these shaders.
     
  22. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    I've tried Lux, it's rather simple integration, but it creates a lot of mess - AltTrees uses absolute paths in shaders and code, making transition rather complicated. But as soon as all references are fixed - it works as intended with Lux features (like transmission mask) making trees look natural
     
  23. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Ok, I'll study this when I have a Lux asset
     
  24. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
  25. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    Is there an Alt shader in the package that works with vertex colored trees?
     
  26. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    AltTrees is based on standard shaders SpeedTree and TreeCreator(I took the source files and reworked them.). If you have other shaders, then you need to rewrite AltTrees shaders
     
  27. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    Ok, I will try to modify the included shaders for vertex color. One more question. Any tips for why my billboards always come out black? I am using mesh trees and they come out fine, but their billboards are always completely black.
     
  28. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Can you send me a screenshot?
     
  29. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    Here you go. Also, I am not using normal maps if that could be part of the issue.
     

    Attached Files:

    Last edited: Apr 17, 2017
  30. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Please send me a texture of the billboard, or a screenshot of the texture. (Assets\Plugins\AltSystems\AltTrees\DataBase\Trees\TreeResources\Your_Tree\Billboard\)
     
  31. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    It looks like just a black image in the editor, but when opened in image editing program this is the result.
     

    Attached Files:

  32. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    I think it's because of a custom shader. If you can send me this tree - I'll check
     
  33. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    Is there any reason this wouldn't work on the PS4 or XB1?
     
  34. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    I do not have access to PS4 and XB1. No one has yet reported problems. If there are problems - write to me, I'll try to help.
     
  35. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    Is there a guide about what have to be changed in a shader in order to make it work with AltTrees?
     
  36. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    A while ago it was mentioned you would look into improving the delay at start. Has anything been worked on this?

    Also for GPU Instancing, do we have to set all of the materials to instancing enabled?
     
  37. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    There is no such guide at the moment. Your shader should contain the following properties to work with AltTreez:
    Code (CSharp):
    1.         [PerRendererData]_HueVariationLeave("Hue Variation Leave", Color) = (1.0,0.5,0.0,0.0)
    2.         [PerRendererData]_HueVariationBark("Hue Variation Bark", Color) = (1.0,0.5,0.0,0.0)
    3.         [PerRendererData]_Alpha ("Alpha", Range(0,1)) = 1
    4.         [PerRendererData]_Ind ("Ind", Range(0,1)) = 0
    You can see the shaders to understand how they work(Assets\Plugins\AltSystems\AltTrees\Shaders).
    In the future I will do a guide, how to write custom shaders.

    Update coming soon (I think during the week), where I improved loading.
    Unity 5.6? Yes, that's right. Or you can make this fix for 5.6: #413
     
  38. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Are there any specific benefits for TreeCreator trees in AltTree? SpeedTrees performance are significantly increased but I found with the instancing and build in batching on 5.6 standard TreeCreator trees appear ( I could be wrong) to perform better or equal on there own.

    Haven't experimented with object trees in alt tree yet.
     
  39. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    I develop for the consoles and have both so if it doesn't work on them, I couldn't use it. Would you issue a refund if it doesn't work and you can't fix it?
     
  40. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Diab1O,

    is it possible to use AltTrees from Assets\Plugins\AltSystems\AltTrees\DataBase\Trees as a regular game object?

    I've tried to put them on scene but noticed that wind do not affect them and LOD system doesn't work

    We need to put extra details on top of our terrain (and baked terrain trees) and those details reside in prefab which spawned around camera when necessary, currently we use SpeedTrees in those prefabs, but we want to use AltTrees instead due to performance issues with SpeedTree

    Thanks!
     
  41. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Unity TreeCreator will be faster, because AltTrees has more features.
    Ok, if I can not help you run on consoles - I'll do a refund.

    You will not get a performance improvement over SpeedTree, if you plant trees with prefabs. You need to add trees through the manager.
     
  42. sSuite

    sSuite

    Joined:
    Sep 28, 2014
    Posts:
    17
    Are the LOD distances working properly? It seems to function fine when I drag in an AltTree prefab manually, but if I plant trees using the manager, they all switch to billboard at the same distance (roughly 20-25 units away) no matter what I do. Any idea why this could be happening? Thanks.
     
  43. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Show me the screenshot of the manager settings please.
     
  44. sSuite

    sSuite

    Joined:
    Sep 28, 2014
    Posts:
    17
    Sure, no problem:
     
  45. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hey,
    You need to lower the parameter "Max LOD Patch", or set the checkbox "Auto Configuration".
     
  46. sSuite

    sSuite

    Joined:
    Sep 28, 2014
    Posts:
    17
    Oh! Thanks! What exactly does Max LOD Patch do?
     
  47. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Affects the number of patch levels. You can enable the "Draw debug patches" checkbox, and see how it affects. Meshes and single billboards can only be in the last level of patches. All other levels are group billboards.
     
  48. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Are there any base-line settings you go by for say Low, Medium, and High? I've messed with the settings quite a bit and they all seem to perform the same whether the billboard distance is really close or really far.
     
  49. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Try "Distance Trees LOD Factor" and "Distance Objects LOD Factor" (link)
     
  50. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Update 0.9.8 is available on altsystems-unity.net (in AssetStore update will come soon)!

    You can download the latest version from here: http://altsystems-unity.net/AltTrees/LastVersion/

    Changes:

    - added multithreading(distance checking, billboard generation, frustum culling, object loading)
    - added API
    - added documentation
    - optimized the objects system
    - fixed the problem with shadows from point lights in deferred mode
    - added PBR settings
    - added range adjustment mipmap
    - support for multiple cameras
    - support for Unity 5.6
    - added collider events
    - optimizations...
    - bug fixes...