Search Unity

Critias Tree System [Asset Store]

Discussion in 'Works In Progress - Archive' started by Assembler-Maze, Oct 21, 2016.

  1. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Being a 'tree only stuff' it supports only SpeedTrees sorry. I need to modify it to support other custom objects too, but I don't know when I'm going to do that. Ill keep you informed.

    But in the meantime the unity team is working on some componenet 'instanced static mesh' component (kinda like unreal's from what I've heard) that should support any object with auto-lod transitions etc. However that system won't have billboard support, so what I've done is not going to be completely deprecated.

    Check it out here: https://forum.unity3d.com/threads/g...enecked-by-the-cpu.429120/page-2#post-2927909
     
  2. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,567
    Well what i'm trying to do is basically trying to use your system to render standard foliage/tree meshes but custom made not using speedtrees.

    that instance static meshes component are a good news, just don't want to count on getting it soon if you know what i mean :D
     
  3. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yea, I kinda know. Well wait a year or so for that. Well, I'll try and do my best but I can't promise anything too soon either. Btw, if your project is cool and you're in a rush I think you can try that yourself. Just remove the non speed-tree from the batch generation and don't change the standard shader. Should be quite straight-forward.
     
    ghiboz likes this.
  4. marcatore

    marcatore

    Joined:
    May 22, 2015
    Posts:
    158
    @Assembler-Maze I've read that you'll not leave us alone....so I get benefit from this and I suggest you to support multiscene project.

    I'm writing this because I'm testing your solution and I have the situation where the main camera must be in a scene, the environment in another one and other gameobjects in another ones...so I think that it could be fine to make it working with multiscene.
    Thanks in advance if you'll develop this.
     
  5. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    461
    hello @Assembler-Maze !
    congrats for this fantastic asset!
    i've got a question about my usage: in my project I need to load the scene from an assetbundle created by my asset...
    I tried to do this: in both projects i added your asset, in the stage development i made all the things and the trees are working good, but when I export the asset and import into the main project, seems that all the billboards are lost, only the 3d trees are visible...
    have you got any ideas about this issue?

    thanks again!
     
  6. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    If you are having the trees as 'game objects' in another scene and wish to add those to the system, yea I should make that work.

    However I am pretty uncertain how I can do that since unity does not allow me to have cross-references in the scene and stuff. I'll have to look into that too, and if there's a workaround at that, since having to have the trees and the terrain in the same scene is quite bad for the performance, especially if you have multiple scenes with trees that are on different parts of your world.
     
  7. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I think I have an idea on why the billboards are gone. Since I am not creating 'mesh' assets that are stored and referenced by the guys that use the billboards, but are only in the scene's memory, when you use (whatever you use) to store your scene, (since I think it's not the Unity's standard stuff) it doesn't serialize the billboard meshes since there's no real asset for those.

    A very easy solution (that unfortunately I don't have time to implement) would be in the 'BillboardGeneration' code in the 'Treeifier' when the billboard mesh is created and assigned, just use the 'AssetDatabase.CreateAsset' in order to store that mesh, and after that retrieve that newly created asset reference and set the MeshFilter's reference to it so that it is a physical hardware-stored mesh and not only a memory one. I am 93% sure that this will solve your issue.
     
  8. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    461
    thanks @Assembler-Maze for your reply!
    looking in dept I noticed that if I run the .exe it import correctly the assetbundle and the billboards are visible, the issue happen only in the editor... the treeifier class seems to be reset in this phase, I will try to remove all the '#if UNITY_EDITOR' code :)

    reading your post, what do you mean as cross-reference issue?
     
  9. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    The multi scene scene stuff?
     
  10. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    461
    yes!
     
  11. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Well, it's about the scene organization. For example if you want to have let's say only hand placed object trees, you can't have them all in one scene since it will blow your pc up(we're talking of 20k+ trees).

    But you can organize those trees in multiple scenes (and maybe add them to my system additive) and you want to add them to my system.

    But at the moment my system for extra trees requires an input of a game object('s) that holds all those trees and adds them to the system. However since we can't cross reference objects in different scenes then you are forced to add all your trees in only one scene, which is kinda bad.

    So that's why I'll try see if we can have some workaround so that we can reference trees in other scenes and add them to our system. And also another option where you can add trees additive (that is keeping the existing trees to the system but to add new ones on top of the existing ones)
     
  12. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    461
    ok! it's clear and if you do some thing like this?
    Code (CSharp):
    1. foreach (var item in SceneManager.GetSceneByName("scene_name").GetRootGameObjects())
    2. {
    3.     var tree = item.GetComponentsInChildren<Treeifier>();
    4. }
    you can cycle over multiple scenes
     
    Assembler-Maze likes this.
  13. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yea, probs something like that. Thanks for the tip. However you'll have to hint the system with some GObject names (or type or something like that) so that I don't have to scan through the whole hierarchy of it. I'll try and see what's the best solution for that, and when I have time I'll make an update with that.
     
  14. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    461
    :cool: good to hear!!
    and about the 'issue' of the billboards, where in the .exe it's working (it's good this instead the editor working and the exe not) but I wish have everything working... maybe a solution comment all the 'unity editor code'?
     
  15. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Soz in the editor you have to hit 'play' so that those bills become visible. It's a unity problem I think, I don't know how to fix it.
     
  16. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    461
    :rolleyes: thanks!!!
     
  17. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,891
    I tried your latest v4 demo and it looks and performs great. Good job!
     
    Assembler-Maze likes this.
  18. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    137
    Hi,

    I was trying this amazing plugin and I was wondering:
    Will it work even if the trees are not painted on the terrain?
    I have all my trees placed as single GameObjects.

    Thanks in advance for the answer!
    Best regards,

    Dom
     
  19. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, the trees can be placed like individual game objects, painted on houses, cliffs etc... (it's in the docs)

    I'm also developing a feature so that you can also add trees from other scenes (that are game objects) and without having the requirement of the scenes to be loaded! In that case you can have million of single tree game objects across multiple different scenes and still work in my system.

    Ill post an update when I'll have that working.
     
  20. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    137
    Thanks for the quick reply!
    I checked the documentation. Are you referring to:

    Tree To Extract Extra ?

    If so, could be ok to put all the single trees under a main gameobject and feed it to your plugin?


     
  21. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes.

    I also plan an video tutorial (when I'll have a few free hours) explaining 'en detaile' the process so that it is all clear. Sorry that I don't have time right now :)
     
  22. Hybrid1969

    Hybrid1969

    Joined:
    Apr 19, 2013
    Posts:
    31
    Love this script but is it possible to use this with dynamically generated terrains, details and trees?

    I have a script that generates the terrain, adds terrainData for grass details and treeInstances fine but I would like the details and trees to be managed by you script.

    Is this possible and any recommendations as Ive been playing around with linking to the treeifier at runtime but without success so far.
     
  23. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    456
    I was going to ask the same question as Hybrid1969. My project requires the need to dynamically at runtime place trees in game. Is there a workaround to this product to allow tree's to be added and removed at runtime ? Otherwise is kinda limiting for edit time only use.

    I made modifications to the TreeSystem.cs and Treeifier.cs today to accomplish runtime loading of speed trees. It works directly from Resources.Load or Asset Bundle loading of speed trees. It accomplishes the Prefab and Extracts at runtime (not editor time). Works fine.

    What i've seen from this code its very innovative excellent solution for runtime speed tree instancing. Just needs grass GPU instancing as well on the same terrain for a mega product.
     
    Last edited: Feb 9, 2017
  24. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    To answer both questions (Hybrid's too), the system does not support runtime adding/removing of trees at the moment. But it can be modified by an coder to do so, however it is at least a week or so of work.

    I am not planning any update on this one since, I designed it with limited size open world RPG's in mind, with multiple terrains (something like max 50x50KM in size) but nothing like procedural planets, or procedural generated content. However I am planning to add support for larger terrains by storing the trees in the 'streaming' assets so that they are not ALL loaded in memory at runtime, thus supporting +1000x1000km of continuous very dense forests.

    Very good that you are dinamically loading the trees with 'Resources.Load', I was planning to do the same, since having all the trees in memory when you have dozens and dozens of them is not very GPU texture friendly.

    But your requirements seem to fit some quite big games, what are you developing?

    However the first think I'm going to tackle is the trees as objects spread over multi-scenes, as stated earlier.

    I haven't forgot abut the grass system, I'm probably going to release it after our kickstarter campaign that should happen somewhere in March/April.
     
  25. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    456
    My requirements are not so big as yours really ! My terrain sizes are 4K no larger requiring probably a maximum of 8 varieties of speed tree loaded at any one time in the game. This is why i asked the question regarding runtime dynamic loading of speed trees at startup since i dynamically save all the terrain data and load at runtime as a kinda terrain asset that i sell in world.

    Am i right in saying that once the generation has been done the terrain can be removed? Unsure if i understood this correctly. If so then any grass gpu instancing could be used on a duplicate terrain to perform this?


     
  26. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, everything is saved, you can safely delete the terrains after you are done with the generation. If you have problems doing that, then it's a bug and you can report it and how I can reproduce it and I'll see what I can do.

    And don't forget, you can also place trees as game objects too!
     
  27. marcatore

    marcatore

    Joined:
    May 22, 2015
    Posts:
    158
    @Assembler-Maze do you have planned to support hue variations for the billboard?
    I think it's a great feature of the Speedtree trees and it give us the opportunity to maintain the same visual feedback from 3d models to billboards.

    If it's already developed, could you let me explain how to do it because at the moment the billboards have the same appearance.

    Thanks in advance.
     
  28. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, it's planned, not enabled at the moment. I'll keep you all informed as soon as I update something.
     
  29. marcatore

    marcatore

    Joined:
    May 22, 2015
    Posts:
    158
    Nice! Thank you.

    I have another question for you.
    Is it possible to use 2 Critias Tree system (Treefier+Treesystem) in the same scene?

    The reason why is I'd like to have two different "max tree distance".

    Do you think that duplicate the tree system is not good as solution?
     
    Assembler-Maze likes this.
  30. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    It is possible, shouldn't be a problem but it will add the overhead of testing the bounding boxes again. I really hope that I can introduce cascade distance maps (I was planning the same thing for the grass) based on tree groups. Like having different groups of trees and billboards that fade at different distances.

    Awesomely usefull for dense regions of bushes around trees. We want the trees to be seen at a big distance (let's say 300m) and the bushed only visible at 150 meters.

    I would also like to make a modification so that you are not 'forced' to have trees have billboards. Again especially usefull for bushes. But I have to modify the shader to allow some sort of 'fade in' when getting close, feature that is now NOT supported, since the billboard switch happens invisibly between the 'real' and 'fake' batched billboards.
     
  31. marcatore

    marcatore

    Joined:
    May 22, 2015
    Posts:
    158
    it seems that 2 tree system(2 treefier, 2 treesystem, 2 cellholder, 2 terrains) crash Unity.

    If I enable one of those 2, it works...so I should imagine that every tree system is well configured.
     
  32. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I see, to be honest I never tried it. Will look into it and see what I can do.
     
    marcatore likes this.
  33. Hybrid1969

    Hybrid1969

    Joined:
    Apr 19, 2013
    Posts:
    31
    I was hoping for a more dynamic, flexible system i can use across all my current projects.

    But i will certainly be watching to see if this changes, as its a great system as it is and perfect for none dynamic terrains. I will go back to working on my own system.
     
  34. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Well, I'm sorry but as stated above I will not make any modifications for procedural generated content. It is not designed for that and I prefer working on improving performance, fixing popping, better managing, adding dynamic tree group distance cascades etc... making this better for RPG's where there is not very much procedural content, or, at least, it is generated at edit time.

    For your specific requirement you either have to develop your own (as you already told us) or modify this one.
     
    mons00n likes this.
  35. Hybrid1969

    Hybrid1969

    Joined:
    Apr 19, 2013
    Posts:
    31
    Sorry if I came across as rude, not intended.

    I do love your system and have actually recommended it to others.

    And I am indeed contemplating customizing it, if that's ok with you as I wont abuse other peoples work intentionally.
     
  36. Fatalis

    Fatalis

    Joined:
    Sep 9, 2013
    Posts:
    52
    I am having a problem with no mesh trees appearing once I am in play mode. The instructions seem very straight-forward, not sure where my setup could be incorrect.

    critias.PNG treesystem.PNG editor.PNG playmode.PNG
     
  37. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    No, don't worry! I'm also wanting to make this as general as possible and to make it fit the needs of all people, but it is not so easy :). And yes, you are completely free to customize it.
     
  38. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    The setup seems correct. One thing could be checking the logs, to see if there is an error there. Another would be to manually delete the extracted tree data and hit 'Extract Tree Data' again followed by a new 'Generate'.

    If it still poses problem, please, send me a project replicating the problem and I'll be happy to help.
     
  39. Fatalis

    Fatalis

    Joined:
    Sep 9, 2013
    Posts:
    52
    Thank you for the reply. I've checked the console, no errors show up. I've deleted the tree data, re-extracted and re-generated but the same problem occurs. I will send the project shortly.
     
  40. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    In case anyone stumbles across the same problem, it is because if you use a custom 'used camera' in the tree system script, i forgot to add the camera to the CullingGroup's 'targetCamera'. There's a fix on the gihub project, until I'll update it on the asset store.
     
  41. Jeremie-de-Vos

    Jeremie-de-Vos

    Joined:
    Jun 5, 2015
    Posts:
    120
    Hey,
    I have the following errors when i installed the asset from the Asset store.
    i'm using Unity3d 5.5

    * Assets/CritiasTreeSystem/Code/TreeSystem.cs(450,169): error CS0029: Cannot implicitly convert type `System.Type' to `Type'

    * Assets/CritiasTreeSystem/Code/TreeSystem.cs(450,51): error CS1502: The best overloaded method match for `System.Type.GetMethod(string, System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[])' has some invalid arguments

    * Assets/CritiasTreeSystem/Code/TreeSystem.cs(450,139): error CS1503: Argument `#4' cannot convert `Type[]' expression to type `System.Type[]'
     
  42. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Very weird, make sure that you use

    using System;
    using System.Reflection;
    using System.Collections.Generic;

    and that you are not conflicting with anything else in your project. I can't think of absolutely anything that might cause your error. If it still persists and everything is imported, don't import the system into some existing project but create a new one where you can build piece by piece and understand it's basic working before moving it to your big project.

    Maybe you are targeting web or something?
     
    Last edited: Feb 16, 2017
  43. Fatalis

    Fatalis

    Joined:
    Sep 9, 2013
    Posts:
    52
    So far I'm really amazed with this asset. Very easy to use and great results. I have a couple questions though: Are individual tree instances accessible via code? Do mono behaviors (attached to the trees) remain intact?
     
    Last edited: Feb 16, 2017
  44. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    At the moment there isn't support for destructible trees so you can't access them via code.

    The mono behaviors do not get attached to trees, since you are not using GameObjects, they are just drawin via 'Graphics.DrawMesh' or 'Graphics.DrawMeshInstanced'. There is no object there. However with a little bit of code you can modify the trees custom colliders and attach scripts to them in that 'TreeCollider' logic.

    It is far more optimal and you will only have the scripts attached to the trees surrounding the player. But it is not supported by default, you need to write some code for that.
     
  45. lezan_

    lezan_

    Joined:
    Nov 27, 2016
    Posts:
    50
    Hello,
    do you think there is some way to make it working with speedtree grass instead of tree?

    Thanks!
     
    Last edited: Feb 16, 2017
  46. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    The system is not designed for grass, my other [WIP] system is designed with grass in mind. When I'll have it ready i'll post here, don't worry :). With the current system you can only set denser regions of bushes, I'm afraid.
     
    lezan_ likes this.
  47. lezan_

    lezan_

    Joined:
    Nov 27, 2016
    Posts:
    50
    Do not be afraid for that, it is just awesome what you release it for free (and also open source).
    Thanks!

    EDIT: the most update version is 0.9.2 as I can see on the first post, but where can I find it? In the Asset store and on Github I see 0.9.1.

    EDIT 2: it does not work with unity 5.4 cause of use of DrawMeshInstanced that was introduce since 5.5. Am I right?
     
    Last edited: Feb 17, 2017
  48. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    0.9.2 is on github, i just forgot to update the versioning. And yes, 5.5+ not only because of 'DrawMeshInstanced' but because I can't extract the billboard coordinates from the speedtrees otherwise.
     
    lezan_ likes this.
  49. Fatalis

    Fatalis

    Joined:
    Sep 9, 2013
    Posts:
    52
    I have been experimenting with using Critias to generate plants in two different scenes because I need certain kinds of plants on different layers. It seems that no matter what they are put on the default layer, even though I specify other layers in the tree system script.
     
  50. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hmm... are you using multiple systems? In the code i am certainly grabbing the layer with 'm_UsedLayerId = LayerMask.NameToLayer(m_UsedLayer);' and using it in every 'DrawMesh'.

    Are you also setting the camera that should be used to draw those layers? For example if you have a main camera that has excluded your special layer but you set it by mistake in that 'UsedCamera' slot it will not display anything.

    Anyway I am looking now into this, to see if I can reproduce.
     
unityunity