Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Assets AltTrees System [WIP] [AssetStore]

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

  1. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    Hi Diab1O,

    using Unity2017.1.0f3 and altTreesVersionUnity = 560 with patched AltTreesManager -- here are the issues I'm facing;

    Bug (?)
    Importing tree prefab as AltTree - it does import but the Material does not contain any texture; so the trees are drawn as white. Same thing with billboard;
    At this point, I can manually add the texture to Material + mark GPU instancing + Apply & Refresh Scene + Update billboard Texture & Refresh Scene... at this point, billboard is updated but all three materials (1 material and 2 billboard materials) don't have "Enable Instancing" set.

    Suggestion (?)
    I've some models downloaded with wrong scale; if I use 0.1 for all scale, it is the correct scale. When importing, AltTree doesn't respect this scale; I've tried changing scale on generated AltTree but that didn't help. Finally it comes down to "Random Tree Height" from place trees - trouble is, it has a lowest range of 0.1, which means at the lowest setting generated tree is the correct size - random between 0.1 to 0.2 looks too large.
    So can AltTree either (1) respect AltTree tree scale (preferred) or (2) change random range to go down more - which may not be feasible.

    Question: It might have been answered somewhere in last 13 pages - so sorry for the repeat. Is there any way to delete an altTree from database/scene, and any quick way to clean/clear the database.

    Thanks again.
     
  2. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hi,
    Sorry for late answer!

    Which trees do you use? SpeedTree or others?
    Which trees do you use?
    Open "Assets\Plugins\Editor\AltSystems\AltTrees\AltTrees_Editor.cs" file, find
    Code (CSharp):
    1. EditorGUILayout.MinMaxSlider(ref heightTemp, ref heightRandomTemp, 0.1f, 2f);
    2.  
    3. and
    4.  
    5. EditorGUILayout.MinMaxSlider(ref widthTemp, ref widthRandomTemp, 0.1f, 2f);
    and replace with
    Code (CSharp):
    1. EditorGUILayout.MinMaxSlider(ref heightTemp, ref heightRandomTemp, 0.01f, 0.2f);
    2.  
    3.  
    4.  
    5. EditorGUILayout.MinMaxSlider(ref widthTemp, ref widthRandomTemp, 0.01f, 0.2f);
    Just remove the manager from the scene and add a new one. Or use these buttons: http://i.imgur.com/stmhF8U.png
     
  3. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    Hi Diablo,

    I figured out the first issue: at-least why it wasn't getting the textures; it's a mesh tree with a custom shader which used _Diffuse as texture instead of _mainTex
    is that also related to the instancing issue?

    Does "Delete all Trees" from places screen removes all trees in database? Cause it almost gives the impression that those buttons on places screen would only remove it from scene.

    Suppose I've imported a tree with wrong settings; I can't reimport it, as AltTree detects it's already in database.
     
  4. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hello,
    No, apparently this is a bug. I will check it.

    Correctly

    You can remove AltTree prefab from "Assets\Plugins\AltSystems\AltTrees\DataBase\Trees".
     
  5. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    48
    Sorry if this has been asked.

    Does the shaders you use also run on the GPU ?
    thanks
     
  6. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hi,
    Sorry for late answer!
    Yes, if you enable the "GPU Instancing" option
     
    Mark_01 likes this.
  7. Mark_01

    Mark_01

    Joined:
    Mar 31, 2016
    Posts:
    48
    No problem, thank you. :)
     
  8. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    324
    hi there.
    im triing to make a build in 5.6.3p2 but unity dont allow because of:

    Assets/Plugins/AltSystems/AltTrees/Scripts/AltTreesPatch.cs(2016,32): error CS0103: The name `AssetDatabase' does not exist in the current context

    Assets/Plugins/AltSystems/AltTrees/Scripts/AltTreesPatch.cs(2016,21): error CS0103: The name `pathStr2' does not exist in the current context



    can you help with that please?
     
    Last edited: Sep 7, 2017
  9. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    74
    Is AltTrees still under development? The last update came out almost 3 months ago, and while generally I don't have huge problems with it there is certainly room for improvements. If so, when can we expect an update? Also is it possible to use different settings for different objects? (like trees should be visible from far away but small objects shouldn't)
     
    ranaUK likes this.
  10. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hi,
    Sorry for late answer! I currently do not have access to my computer.
    Look here please: link
     
  11. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hi, at the moment I do not have free time to develop. As soon as the time comes - I will continue.

    Set the Checkbox IsObject to small objects
     
  12. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    324
    thx alot.
    but you willl include this fix too in next version, right? for sure i'll forgot to fix this next time =)
     
  13. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Oh sure!
     
  14. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    137
    hi,
    I am using World streamer as my map is very large with many terrains.World streamer uses a script for floating point fix, so it streams the terrains and move close to (0,0,0), avoiding shakings of objects and shadows.There is no problem with unity trees, as they are part of the terrains but, is possible to do this with Alt trees?

    thanks
     
  15. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    Hi @Diab1O

    couple of things I am hoping you can advice me with.

    1) I want to load my scene from AssetBundle, and I want the asset to be decoupled from any other codes. Once scene loads, it broadcasts a message which continues my main logic;

    For AltTree, similarly I would want my main scene to broadcast a request telling me trees are needed - at which point I would like to initialize altTree; In essence, altTree manager is on a different scene that the one holding the terrain.

    I haven't checked your code, but I'm assuming you are storing some data about trees placement somewhere; I am guessing my asset bundle can have that placement data that I feed back to altTree.

    2) Seasonal trees - to keep gpu instancing, I can't go and change materials on individual trees; I'll test to see what happens if I do it on shared Materials. If that fails, what would be the correct way to handle it? Delete all trees and recreate with different hue+bark colour?

    thanks again
    Rana

    PS: Additional: cleanup all string "Assets/Plugins/" with one variable and set it with Path.combine to ensure better cross-platform compat. for editor.
     
    Last edited: Sep 15, 2017
  16. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hey. Please see the demo scene, it has a move to (0,0,0) coordinates.
     
  17. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hey. You can save the trees yourself and load them in the scene through the IPA.
    I think that at the moment this is the only solution.
    Sorry, I do not understand, why?
     
  18. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    Well all the paths are constant. Meaning I can't move AltTree under a different folder for organisation. Which makes it harder to exclude items from build. I've just changed all your paths to const string (with relative paths in shader).

    You mentioned saving the trees myself and IPA: what's that? Or do you mean API? Are you suggesting I use getTrees method to read/save and addTrees to put back in?

    Update:
    GetTrees + AddTrees method didn't work for me; I wrote a helper that uses GetTrees and serializes to a json file. Next, I loaded copy of the same scene without AltTree; with another helper, I tried creating AltTrees at runtime, and then having an existing AltTrees in scene - but same problem. When I use AddTrees, it tells me it's not Initialized yet; That variable is only getting set from AltTreesManager.UpdateFunk, which is also checking for variable initTimeStartedCount != -1; now this part is never invoked in my useCase.
    Temporary hack, I set that variable to 0 so it would initialize; then I get the error
    AltTrees: Prototype 6349344 not finded!

    Please advice.

    Rana
     
    Last edited: Sep 16, 2017
  19. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    Further Update: Working solution

    I didn't realize AltTreesManagerData was a public property to AltTrees (Editor was hiding it);
    Knowing that,
    1. can create a new GameObject and SetActive to false (without this, when we add AltTrees, it would create an unique altTreesManagerData.asset );
    2. then add AltTrees component to it.
    3. set altTreesManagerData with correct referenced database asset
    4. Finally enable GameObject, which would trigger all the required sequences for Trees to Appear.

    This works within scene test; have to test it as bundle
     
    Last edited: Sep 16, 2017
  20. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    137
    Mmm,can´t see too much in the demo as is not a scene.I have created a new project with 100 tiles(100 terrains).When World Streamer moves for example the terrain nº 64 to (0,0,0) ,move its trees too as part of terrain(unity trees).
    If a convert them to alttrees, they disappear from the terrain(unity trees) and appear inside the alttree object.The problem is this object has all the trees from all terrains, so is not possible to move(stream ) the trees for nº 64 only,or i haven´t found the way to do it.
     
  21. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Yes, sorry, google translate broke the word.

    I'm glad if this works.

    In the demo scene a "FloatingOrigin" script is attached to the camera. Look at him. Most likely it will need to be changed to work with World Streamer
     
  22. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    137
    i am sorry, but i don´t found the demo scene inside the project.I downloaded the one in the description in the asset store but is only a executable.
     
  23. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hello,
    Look here: "Assets\Plugins\AltSystems\AltTrees\Scenes\Demo"
     
  24. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    who's your daddy :)

    Works flawlessly.

    SteamVR, SinglePass stereo forward linear. Gaia terrain of 2kmX2km with around 4K trees and 5.5K bushes and foliage and Wind: super smooth in my 1060Gtx

    Next thing to solve: seasonal colours...

    @Diab1O , does altTree support baked shadows?
     
  25. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    I'm glad to hear it! :)

    No :(
     
  26. Vagrod

    Vagrod

    Joined:
    Aug 4, 2017
    Posts:
    39
    Hi! I've just converted one SpeedTree to AltTree and mass-placed it to terrain for testing -- and got 999+ errors:
    InvalidOperationException: Material needs to enable instancing for use with DrawMeshInstanced.
    UnityEngine.Graphics.DrawMeshInstancedImpl (UnityEngine.Mesh mesh, Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Matrix4x4[] matrices, Int32 count, UnityEngine.MaterialPropertyBlock properties, ShadowCastingMode castShadows, Boolean receiveShadows, Int32 layer, UnityEngine.Camera camera) (at C:/buildslave/unity/build/Runtime/Export/Graphics.cs:411)
    UnityEngine.Graphics.DrawMeshInstanced (UnityEngine.Mesh mesh, Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Matrix4x4[] matrices, Int32 count, UnityEngine.MaterialPropertyBlock properties, ShadowCastingMode castShadows, Boolean receiveShadows, Int32 layer, UnityEngine.Camera camera) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/GraphicsBindings.gen.cs:2177)
    UnityEngine.Graphics.DrawMeshInstanced (UnityEngine.Mesh mesh, Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Matrix4x4[] matrices, Int32 count, UnityEngine.MaterialPropertyBlock properties, ShadowCastingMode castShadows) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/GraphicsBindings.gen.cs:2142)
    AltSystems.AltTrees.AltTreesManager.DrawMeshes () (at Assets/Plugins/AltSystems/AltTrees/Scripts/AltTreesManager.cs:820)
    AltSystems.AltTrees.AltTreesManager.LateUpdate () (at Assets/Plugins/AltSystems/AltTrees/Scripts/AltTreesManager.cs:441)


    Because of it, I can see only far-away trees. What can be wrong with material? GPU instancing is on. Unity tree system renders this speedtree without any troubles.
    Another speedtree converted to alttree behaves the same way.
     
    Last edited: Sep 21, 2017
  27. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    116
    @Vagrod, make sure all the materials for the trees are marked for GPU instances; also in Billboard folder, there should be two materials; XXXX.mat and XXXX_group.mat - out of these two, XXXX.mat also needs to be set as GPU instances.
     
    Diab1O and Vagrod like this.
  28. Vagrod

    Vagrod

    Joined:
    Aug 4, 2017
    Posts:
    39
    GPU instancing was off on two materials in Billboard folder. Now I can see trees in run time :) Thank you!

    UPD: I turned off GPU instancing on billboards due to performance. It became possible by changing directives conditions in AltTree script (I am using Unity 2017, on Unity 5.x this should work without any code changes).
     
    Last edited: Sep 26, 2017
  29. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    @Diab1O

    Ok, so I bought your asset yesterday, but I ran into a few problems...

    1̶.̶ ̶F̶i̶r̶s̶t̶ ̶o̶f̶ ̶a̶l̶l̶ ̶n̶o̶n̶e̶ ̶o̶f̶ ̶t̶h̶e̶ ̶m̶a̶t̶e̶r̶i̶a̶l̶s̶ ̶h̶a̶v̶e̶ ̶G̶P̶U̶ ̶i̶n̶s̶t̶a̶n̶c̶i̶n̶g̶ ̶e̶n̶a̶b̶l̶e̶d̶ ̶a̶n̶d̶ ̶I̶ ̶h̶a̶v̶e̶ ̶t̶o̶ ̶m̶a̶n̶u̶a̶l̶l̶y̶ ̶e̶n̶a̶b̶l̶e̶ ̶i̶t̶ ̶o̶n̶ ̶a̶l̶l̶ ̶t̶h̶e̶ ̶m̶a̶t̶e̶r̶i̶a̶l̶s̶.̶ Fixed using Vagrod's help
    2. Trees seem to disappear when looking at them. An example of that here where I moved the camera just slightly: https://imgur.com/a/Kpkp4
    3. The editor crashes all the time for some reason and it often happens when I hit save...

    4̶.̶ ̶R̶o̶c̶k̶s̶ ̶b̶e̶c̶o̶m̶e̶ ̶s̶e̶e̶-̶t̶h̶r̶o̶u̶g̶h̶ ̶(̶t̶r̶a̶n̶s̶p̶a̶r̶e̶n̶t̶)̶ ̶f̶o̶r̶ ̶s̶o̶m̶e̶ ̶o̶d̶d̶ ̶r̶e̶a̶s̶o̶n̶ Fixed when changing tree import settings. Set it to bark instead of leaves and it's not see-through anymore.

    I am running unity 2017.1 Personal and I'm using the latest version of the software (I bought it yesterday).
    Any help is appreciated.

    - Ruben
     
    Last edited: Oct 1, 2017
  30. Vagrod

    Vagrod

    Joined:
    Aug 4, 2017
    Posts:
    39
    Ruben_Chris likes this.
  31. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    Thanks, this fixed the 1. problem I had at least. Still have the big problem that trees disappear when looking at a specific angle though. Your help was highly appreciated :)
     
  32. Vagrod

    Vagrod

    Joined:
    Aug 4, 2017
    Posts:
    39
    You're welcome! :)
     
    Ruben_Chris likes this.
  33. Theformand

    Theformand

    Joined:
    Jan 2, 2010
    Posts:
    254
    First off, this plugin is absolutely awesome. The speed increase alone is insane. Good job on that!

    That being said, I have a bug report. Theres a shader compilation error in Unity 2017.0.1p4 which stops me from making builds.
    Ive made builds successfully before where this error also occured randomly during edit time and play time, without issues, but now it seems its a blocking issue (meaning I cant test the game properly).

    Also, I'm doing a VR game, so anytime you could take a look at disabling camera facing billboards in trees, that would be awesome. I'm using the standard SpeedTree BroadLeaf model, which has billboards in the tree crown even close up. In VR those arent great :)
    I tried my hand at commenting out anything billboard related in the shaders and .cginc files but I couldnt.

    Anyhoo here is the shader compilation error.


    Code (CSharp):
    1. Shader error in 'AltTrees/SpeedTree': 'CrossFadeUV': cannot convert from 'float[500]' to 'float' at line 57 (on d3d11)
    2.  
    3. Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN INSTANCING_ON CROSSFADE GEOM_TYPE_BRANCH_DETAIL
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME
     
  34. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    Does anyone know how the collider events work?
     
  35. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Hi,
    Sorry for late answer!
    Can you send a video? Or, even better, a demo scene with this bug?
    You get some error during crush?

    What is your platform? Do you get other errors?
     
  36. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
  37. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    Here's a video describing the problem. It might be because of the size of the tree / object, but I'm not entirely sure.


    No I don't get any errors. The whole program just quits.

    Thank you for the links.
     
    Last edited: Oct 1, 2017
  38. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    How do I cull trees? I have like 20 000+ trees and it's lagging a lot... I only see LOD0 and billboarding mode when selecting my trees.
     
  39. Theformand

    Theformand

    Joined:
    Jan 2, 2010
    Posts:
    254
    I'm on Windows 10. [EDIT: On DX11] This seems to be the only error I get. Like I said, it occurs randomly during play time, and edit time. Doesnt seem to be an issue, but when it comes to build-time Unity wont allow a build with that error present.

    I tried looking at it, and I couldnt see any reason why theres a float[500] in there, but its probably above my head :)
     
    Last edited: Oct 2, 2017
  40. _Luthien_

    _Luthien_

    Joined:
    Apr 24, 2015
    Posts:
    45
    I have been in a similar situation with TerrainComposer2 and was able to help the developer find the cause of why it didn't work on my mac, so he could fix it (next to there being some other issues with the GPU / Metal support of the editor, that seem to be resolved now).
    This is another plugin that I am potentially interested in getting, so if you are willing to find a solution to make it work on the mac, maybe I can help you in the same way.

    I just need to figure out if altTrees works together with TC2.
     
  41. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    I think the problem is in the trees. Can you reproduce this problem on a small test scene and send it to me?
    Delete the trees? You can in the patches section

    I will try to find this error.
    No, they are not compatible. Only if you import trees as game objects.
     
  42. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    Yes, I can create a small test scene.

    What I meant was: Is it possible to NOT draw (cull) trees at all that are a certain distance away? There is no need to draw trees that are 10km away from the player. I managed to reduce the lag by setting the distance patch factor to a lower value, but it would still be nice if I could set a max distance for trees to be drawn.
     
    Last edited: Oct 4, 2017
  43. Ruben_Chris

    Ruben_Chris

    Joined:
    Mar 10, 2013
    Posts:
    53
    I created a sample scene (project) and sent it to you on email.
     
  44. Diab1O

    Diab1O

    Joined:
    Mar 31, 2013
    Posts:
    311
    Sorry for late answer!
    I'll see the project in the near future and I'll let you know.
     
    Ruben_Chris likes this.