Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

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
    Look please:


    GPU Instancing available only in Unity 5.5 +
     
  2. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    ahhhh that's why I don't see it. I'm on 5.4. Doh! I'll try in 5.5
     
    Diab1O likes this.
  3. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    So i'm using 5.5. The rocks are set to GPU instanced but they don't render. Upon further investigation, the Instanced shaders are not included in the pack.

    This is with a 100% fresh project with a new install of AltTrees.
     
  4. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    You need to download the package from AssetStore again. Need a version for Unity 5.5
     
  5. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    So this is confusing for your customers. GPU Instancing is supported in 5.5. The checkbox to use it is in your pack in Unity 5.5, yet the shader isn't included. There is no update in the asset store for specifically 5.5, so I'm going to try to install unity 5.6 and get the pack. Maybe it'll work then.

    You need a platform dependent compilation for 5.5 that leaves out that GPU instancing option if you're not going to support it in 5.5.

    *edit* Ok it works with 5.6, though GPU instancing doesn't use light probes. Is that possible?
     
    Last edited: May 26, 2017
  6. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Sorry, but it's not true:
    AssetStore caches the package for all versions of Unity.
    If you downloaded the package in version 5.4, then when you go to the store in version 5.5 you will not see the update. Unity will suggest that you install the package from the cache (from 5.4).
    To update the cache, you need to go to the Download Manager and click the Download button:

    Then you can import the downloaded package.
    Ok, sorry, I'll remove the checkbox.
     
  7. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    I have a problem. Something is saving every frame and the interface get blocked because of that. Check the screen. I have about 10k trees on this terrain with 70 different type of trees. Altree is blocking Unity because of calling a Findby function. I have no choice than kill the task. It took me 20m just to get the profile to that point and make a screen shot.
    And Btw, the cursor is doing the same as if it was saving something every frame.
    The asset is working in the context of the demo sandbox, but not in my game.
    Any idea of what would take too much time in editor with many different prototypes?
     

    Attached Files:

    Last edited: May 27, 2017
  8. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Also another question, is it possible to re-import the trees positions from a terrain but not the trees themselves?
    It takes about 2 hours to convert all my trees, and now I have them in the form of an Altree model.
    I just want to convert the trees positions from an Unity Terrain without converting the tree.

    Something like "if the tree exists, then do not convert it, but place the converted version at the x,y,z" so that I can continue to use my terrain generator with normal tree, and convert the positions only?
     
  9. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hello,
    Try removing void OnRenderObject() function in Assets\Plugins\AltSystems\AltTrees\Scripts\AltTrees.cs

    The tree needs to be converted only for the first time. Then you just do the import, and if the trees are already converted - there will not be a converting.

    Unfortunately no. This is the restriction of Unity Instancing:
    https://docs.unity3d.com/Manual/GPUInstancing.html
     
    Last edited: May 27, 2017
    jimburn likes this.
  10. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Thanks for the info Diab1O... my first tests are showing a +200% speed increase on a very very heavy map.

    That's encouraging. But it takes time to really dig into it. I will make a video once I have done.

    Oops btw there is no OnRenderObject in AltTreeManager.cs, there is one in Altrees.cs

    #if UNITY_EDITOR
    void OnRenderObject()
    {
    if (!Application.isPlaying)
    EditorUtility.SetDirty(this.gameObject);
    }
    #endif
     
  11. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Yes, I was wrong, sorry, in AltTrees.cs
     
  12. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Sorry to insist, but this problem is a serious one.
    After I convert my 72 trees, I cannot select the Altrees.cs editor windows, or I get something that eat all the processing.
    It is in InspectorWindows.DrawEditors->FindObjectsOfType
    This executes every frame, and Unity becomes unresponsive.

    Any help on that matter would help me to resume the development of my project. I try to find what is doing this, but not easy when I need to wait 20s to click on something.

    Check the profiler window.
     

    Attached Files:

  13. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    More info about this problem, it seems as shown from this Profiler screenshot that AssetDatabase.ImportAssets is executed every frame.
    For me it takes 14 seconds, every frame. Take a look at this picture:

    Note: there is nothing else in this project, it is the demo project but using AltTree imported with all my trees.

    upload_2017-5-28_8-55-25.png
     
  14. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Here is a video that shows that even in an empty project, even with the terrain disabled and even when the AltTrees compoment is disabled, the problem happen just because the Altrees component is selected in the inspector!
    My PC is a good gamer laptop with a Intel® Core™ i7-6700HQ Processor and 16 Gb Ram.

     
  15. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Ok I have found the problem. I will have to rant a bit because it is quite awful.
    Question? Did this asset was tested with more than 10 trees?

    Found in the AltTrees_Editor.cs
    Code (csharp):
    1.  
    2.  getDataLinks();
    3.  
    This is executed every frame in OnGui(), can this be put in OnEnable, or have a flag so that it is not executed every frame?

    This also is executed in OnGUI!

    Code (csharp):
    1.  
    2. for (int i = 0; i < countTrees; i++)
    3.             {
    4.                 if (textures[i].image == null && trees[i] != null)
    5.                 {
    6.                     schs[i]++;
    7.                     textures[i].image = AssetPreview.GetAssetPreview(trees[i].gameObject);
    8.  
    9.                     if (schs[i] == 5)
    10.                     {
    11.                         schs[i] = 0;
    12.                         AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(trees[i].gameObject), ImportAssetOptions.ForceUpdate);
    13.                     }
    14.                     Repaint();
    15.                 }
    16.             }
    17.  
    Any serious game is going to use a lot of different trees. Change your sandbox to use 100 different trees to avoid these problems.

    With 70 trees, this look is taking about 20 seconds to execute!
     
    Last edited: May 28, 2017
  16. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hi,
    Sorry for the inconvenience! I sent you a private message on this issue, please check.
     
  17. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Actually I have solved this issue.

    Now that I have learn how to use your asset, I must say that it is totally amazing.
    My game has 24km2 with 16 terrains. Average is about 8000 trees per terrains, 72 different trees, and a mix of Speedtrees, Mesh trees and Unity Trees.

    With Unity the best I can get without having the billboard in the face is 10 FPS... and 5 FPS if I want to have some distance and a satisfying visibility.

    After working 3 days with Alt Trees... now I can use it very easily and convert my terrains to Alt Trees.
    I get +40 FPS average!

    From 5 to 40! And in many cases 50-60 FPS when walking like the players (flying of course displays more trees).

    So kudo for having done this asset, I was ready to make something equivalent myself for my game because it was impossible to continue with Unity alone, it was too slow and the billboard was so pixelized it was unusable.

    So a game changer... thank for doing this asset and maintaining it. I have written a glowing review in the asset store.

    upload_2017-5-29_18-21-47.png
     
  18. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Excellent, thank you very much!
    The screenshot is beautiful! :)
     
  19. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Thanks and the best is when it runs at 50 FPS, on a NVidia 950M Laptop ;) in Fantastic Quality settings.
     
    Diab1O likes this.
  20. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    Hey @Diab1O have you ever gotten around to taking a look at and fixing @Baldinoboy 's trees? Still holding off on buying them for that reason but it would be awesome if you could make them work.
     
  21. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hey,
    This works, but with the standard TreeCreator shaders. If you need modified shaders from @Baldinoboy, then you need to do it yourself. Maybe in the future I will do it myself, but now I do not have time for it.

    This is the tree that sent me Baldinoboy for the test:
     
    Grendelbiter likes this.
  22. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    Thank you! Awesome!
     
    Diab1O likes this.
  23. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Just purchased this with high hopes that it'll solve our tree performance problems. It certainly does do that! But I've got a couple issues:

    1) The AltTrees look worse than the terrain (tree creator) trees. See screenshot comparison. For the mesh trees, I can't quite describe the difference, but it's noticeable, though not terrible. But the billboard trees are definitely darker and blockier than the terrain trees. Can I do something to make them look better?

    2) One big reason I want to use this is so the mid-distance Billboards cast shadows. Those are toggled on in the AltTrees inspector, but I only saw them once -- most times when I run the scene, only the mesh trees cast shadows. How do I ensure that the mid-distance billboards also cast shadows?

    3) The Mesh-to-Billboard fade is a bit obvious -- you can see it here. I'm on a Mac, in case that's a factor. Any way to make that less pixellated? Also, the colors don't really match well.

    4) And looking ahead, are you planning to make it possible to generate the trees before runtime, so players don't have to wait for it?
     

    Attached Files:

  24. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hi,
    Thank you for your purchase!
    Can you send me a test project? I'll check what's up

    I remade the fading in the new version. You need to wait for the update, soon.

    No, but I will speed up the startup process.
     
  25. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    I got the same problem. It is due to the HUE set by default to red.
    I think Diab1O need to fix this problem.
    Either you edit all the converted Alt Trees and set the HUE to white, or you edit the shaders and remove all the HUE section that is slow and useless in 90% of the cases.


     
  26. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I'll PM you with a link to the project.

    And @jimburn, I did try changing the Hues to white (and even unchecking the toggle on them), but that didn't make any difference.
     
  27. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    What did you do to solve the issue?
     
  28. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Hi,
    I sent you a link with the file.
     
  29. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Thanks.

    I have a question about the initial startup time. It still takes a very long time after the game actually runs before the trees appear in the game. Are you working on a solution to this so that we can see the trees right at game start?
     
  30. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    How long does it take to loading? Time is written in the Log after loading. And how many trees, objects on the scene?
    You can not see the trees right after the scene loads. It takes time to load.
     
  31. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I don't have the exact times, but I can check when I get a chance. The problem is that it takes any time to load the trees after the scene is running. Because then the game has started and the player is in the scene, but trees are slowly popping into view for 20-30 seconds or so afterwards. And even longer if there are lots of trees.
     
  32. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    In version 0.9.8, I added multithreading - the loading speed should increase.
    I also added the API (one, two) with which you can find the loading is complete. At boot time, you can display the boot screen.
    I will also think about how to increase the loading speed even more in the following updates.
     
  33. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    This should help. I'll look at that so I can make sure I don't start my scene until it's completely loaded.

    Sounds good.
     
  34. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    OK, so I added the load delegate to see how long it's taking to load all the trees in my scene and here is the result:

    AltTrees Loading time: 202349

    That's almost 3 and a half minutes. I have 1,126 trees in my scene.

    Also, there are no colliders for some reason. I can run right through my trees.
     
  35. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Wow, that's a lot. Can you show your AltTrees settings?
     
  36. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Here they are:

    upload_2017-5-31_23-28-43.png
     
  37. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Disable the option "Generate All Billboards On Start". This option works well only for very small terraines. I will delete it in the next update.
     
  38. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Yep, that helped a lot. Got it down to between 3.5 to 9 seconds.

    What about the collision though?

    Also, I'm seeing very bizarre billboard issue. The trees from a distance look really large and as soon as it changes from billboard to tree it pops to something nearly half the size it was as a billboard. I don't even see any fading either. I'll make a video soon and show you.

    [EDIT]
    @Diab1O sent you a PM with the video.
     
    Last edited: Jun 1, 2017
  39. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    When I build for stand-alone, I get the following errors:

    NullReferenceException: Object reference not set to an instance of an object
    AltSystems.AltTrees.Editor.AltTrees_Editor.OnEnable () (at Assets/Plugins/Editor/AltSystems/AltTrees/AltTrees_Editor.cs:159)

    NullReferenceException: (null)
    UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs) (at C:/buildslave/unity/build/artifacts/generated/common/editor/SerializedPropertyBindings.gen.cs:73)
    UnityEditor.Editor.GetSerializedObjectInternal () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:153)
    UnityEditor.Editor.get_serializedObject () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:146)
    UnityEditor.TransformInspector.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/Inspector/TransformInspector.cs:26)

    Looks like some editor code is not properly setup to only exist in editor mode.
     
  40. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    What I did is to remove all the HUE stuff in the shaders, which makes them faster and the color is not turned to red anymore.
    Do a backup first and then and edit all the shader, it is quite easy, they all use the same code for the HUE
    The shaders are located here: Assets\Plugins\AltSystems\AltTrees\Shaders\

    For example for BarkAltTree.shader, you should end up with this surface
    Code (csharp):
    1.  
    2.         void surf (Input IN, inout SurfaceOutput o)
    3.         {
    4.             o.Albedo = tex2D(_MainTex, IN.uv_MainTex) * _Color.rgb;
    5.         }
    6.  
     
    magique likes this.
  41. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Also try to use "check tree per frame" with a lower value. Like 10 for example. This will speed up your game.

     
  42. clamchoda

    clamchoda

    Joined:
    Jan 21, 2017
    Posts:
    11
    It seems that the billboard does not always match up to the tree model. This causes a big pop in first person. Any ideas on resolving that?

    https://imgur.com/gallery/LL6kJ
    (Note wind is checked, but it doesn't work)
    I don't use shadows in my game. Any idea why my billboards are being made so dark. I tried using light probes to light them up as well, so it doesn't seem to be a lighting issue.)

    http://imgur.com/WvifVOT

    Trees prior to conversion

    http://imgur.com/oJPHhR1

    They are Tree Creator trees and I am using 5.6.0f3
     
    Last edited: Jun 1, 2017
  43. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Yep, I already changed mine to 10 last night. Thanks for helping.
     
  44. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I just reported same/similar issue as well.
     
    Last edited: Jun 1, 2017
    clamchoda likes this.
  45. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    I'd like an update with the hue issue resolved if possible.

    Thanks,

    Andy
     
    magique likes this.
  46. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Does this stop the build? Did it happen once, or always?

    Answered by mail ...

    I'm now looking for a solution to the problem.
     
  47. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    The build completes and I can play, but if I were building for Wii U it would never get past that. It does happen every single time.
     
  48. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Along with what @jimburn said about the Hue stuff in the shaders. I think it would be nice to be able to #define whether or not we want that feature and have it turned off. Especially if it saves performance. I'd rather not hack all the shaders so I'll leave them alone for now, but it would be good to have the option of turning that off in future version.
     
  49. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    Okay, I'll add a toggle switch in the next version.
     
    jimburn and magique like this.
  50. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    318
    I made a fix for the problem with the dark billboards. This fix will be included in the next update.
    I can send it now if you tell me the version of Unity.