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
    I see. There are some things that are better than mine I see, (like painting trees on objects and better documentation) but I hope I can make up for that in the future. For free of course :)

    Atm I, unfortunately, have some trouble submitting v3 to github, but i hope that I can fix it in the next few hours. The demo is fine.

    And yea, sorry that I couldn't make it pre-5.5 avialable for the general public for your Wii problem but you can try contact the SpeedTree guys for the custom 'exe'. I've left the old code generating the data from the 'xml' and also the instancing is 'disable-able' for cases like yours.
     
    one_one and Knightmore like this.
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,892
    I did some English editing for the AltTrees author and he's giving me a free key for my efforts so I'll be giving it a try soon. If it meets my needs then I'll probably just go with that. However, if it doesn't then I might take another look at Critias.
     
  3. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,156
    Hi

    Can you elaborate on how 5.5 solves the problem of not having speed tree xml exports?
     
  4. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    It extracts the Billboard XML data from the BillboardAsset class. You can find the docs here:
    https://docs.unity3d.com/ScriptReference/BillboardAsset.html
    I use:
    https://docs.unity3d.com/ScriptReference/BillboardAsset.GetImageTexCoords.html

    And with that feature I don't need to extract that data from the XML any more. I hope that tomorrow (still trying to fix the buggy git, it doesn't want to push :) ) based on those more detailed docs, I'll also be able to solve the angle rotation issue (since they were so kind to provide it) and make this system 100% and fully functional.
     
    Hikiko66 likes this.
  5. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    tequyla and one_one like this.
  6. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    257
    I can't quite update to 5.5 yet due to my other projects, but are there any limitations to this working on osx/linux as well?
     
  7. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I can't see any, except the fact that, if you use instancing, which is completely optional, you might need to change the MAX_BATCH count from 1000 to something like 128 maybe? But i'm not sure, i think it will work just fine...
     
  8. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,156
    Trying the update now.
    When I enable the TreeSystem script in the scene, my billboard grass disappears, do you know how to fix that?
     
  9. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I'd require a little more info. Is it your scene or the one provided? Have you read the docs too?

    And note, I would really not recomend this system for grass, it's not a good idea.
     
  10. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,156
    It's my scene. The demo scene had issues with the latest beta, so I downloaded 5.5 release.
    The demo works in 5.5 release, so I'm using that.
    The grass is not speed tree grass, just regular billboard grass.
    Yeah, I read the docs and I think I have it setup correctly, in the same way that yours is.
    Your demo doesn't have billboard grass though, it has small foliage instead.

    Here is a vid
     
  11. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, I know now :).

    When the scene starts the terrain's option 'draw' for 'Trees & detail objects' is turned off. So I would recommend painting your grass on a different terrain, and have a terrain specially made for trees. Since one solution would be to remove the trees that have been added to the system from you terrain but that is not cool, since you can loose your work.

    The idea is that the system is not an editor, you just edit the trees in the standard unity way and update them in the system. The system will turn off the tree/detail drawing routines for the managed terrain so that it doesn't draw the trees 2 times.

    I hope I was clear enough, if not shoot again :)

    I'll also add that detail on in the docs, so that people are aware of this.
     
  12. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    Looks just amazing!
    How would this work together with a streaming system such as World Streamer that splits up into different scenes thats loaded during runtime? And same with the grass system? Would i need to do any special setup for such a case?
    You dont have any repository for the grass system? Its not yet available for testing except for a demo?
     
  13. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,847
  14. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Sorry, old link. Get the one from the first post, marked with '! DEMO !'. It's with _V4, forgot to update the link that you quoted :)
     
  15. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Sorry, the grass code is not available, and it is also a quite complicated piece of software. I don't have time to make it very user friendly in the near future. But feel free to implement a solution based on the details I've provided, and the tree system. It shouldn't be a huge difference between them.

    I don't know how would this scale with the world streamer. I am afraid that the trees are always loaded into memory at the moment. I should implement something smarter to only load the surrounding terrains (making the limit practically infinite) but I'm afraid I also don't have time for that :).

    I already provided quite a lot for free and I hope to do even more in the future, but I also need to focus on developing my own game too.
     
  16. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    Ok, good to know about the trees.
    I was just a bit surprised when i saw the post about a "free grass system" and no code was provided, but then i know there is no free grass system in reality : )
    We all need more time for our games for sure : D
     
  17. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Sorry, not at the moment. I really hope that I can provide it in the future. Providing it now would cause more of a hassle than good, since it is quite difficult to use.
     
  18. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    Ok, seems like an awesome system though : )
     
  19. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Amazing work! I spent all day yesterday optimizing my SpeedTrees, only to find your system at the end of the day, haha.

    I do have one question - the limitation with grass - "At runtime the managed terain's trees and foliage is turned off, so your terrain's grass will go away. In order to mitigate that I would recommend having two terrains, one for trees and the other for grass."

    This is difficult with my current workflow, using procedural generation. Do you think this limitation is fixable? If not, I will probably still find a way to make your system work, because your billboard performance is phenomenal. Thanks in advance.
     
  20. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    257
    Is there really no way to separate out grass & trees? Due to the size of the terrains in my project making a duplicate is unfeasible.
     
  21. GingerDr73

    GingerDr73

    Joined:
    Sep 25, 2013
    Posts:
    21
    Tried this system out this morning, seems to be working quite well. However it seems to have missed some of my tree prototypes. I went back and double checked and found it wasn't generating data for all of the tree prototypes. From my 15 prototypes only 11 were showing up in the managed list. I tried reducing down the number of prototypes on the terrain to 12 this time it only generated 8 in the managed list. I had a look around to try and see if there was anything unique about the import settings of the Speedtrees being excluded but I didn't find any pattern. Some of them are Speedtree made, some by me. Has anyone else encountered this problem? Any clues as to the cause?

    Thanks for making this btw, and for making it free:)
     
  22. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hey!

    I am trying to think at something. I could completely remove the trees from the terrain after the tree generation but then trees might be lost, and you can't edit them properly any more.

    Or maybe I could have an option, that after generation all the trees added to the system from the terrain are removed but kept in memory somewhere with a 'restore' button.

    But I have no idea how that would scale with procedural generation.
     
  23. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hey! You can check out my previous post and see if, maybe, that could help you in your problem.

    Question, how large is your project? More than 30x30 sq km? How many tile-able terrains? More than 4? Since for my project (4 tileable terrains, 20km2) I have a script that automatically manages 4 other terrains (by copying the heightmap + tree prototypes + tree instances) by the click of a button. Those terrains are disabled at runtime, and after everything will be finished they will be completely removed, since the system holds it's data in-memory, doesn't require the terrains around.
     
  24. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    The system only uses SpeedTree at the moment. It is built around SpeedTree especially. Trees that are not SpeedTree are not used.

    If that is not the problem, please, feel free to provide me more details, I will look into it.
     
  25. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    One thing I know for sure is that at runtime my tree system does not use the trees from the terrain, but uses them from memory (since they are generated at edit-time by the treeifier). One better thing to do, would be to do what you are doing at 'Start' and let the terrains as-is, without creating a copy of it, but only set the tree instances to zero, WITHOUT creating the copy.

    Try ONLY: "m_ManagedTerrains .m_ManagedTerrain.terrainData.treeInstances = new TreeInstance[0]" in the 'Start' at runtime. That will also let all the trees in-place at edit time, for you to edit by your heart's content.

    Your idea seems quite good I'll, maybe, introduce it as a temporary workaround in the master branch, for people that can't manage multiple terrains just like yourself, until I can think at something smarter.
     
    Last edited: Dec 3, 2016
  26. GingerDr73

    GingerDr73

    Joined:
    Sep 25, 2013
    Posts:
    21
    I meant that some of the trees were purchased from Speedtree while others were made by me in the Speedtree modeller. They are all .spm SpeedTrees.
     
  27. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Ah, I understand. Well, make sure that all your prefabs are added to the 'Tree To Extract Prefabs', delete all your previously extracted data at the 'Data Store Path' and press 'Extract Tree Prototypes' again. If it still doesn't generate everything, go with the debugger through the code and which prefab is skipped and why.

    I have dozens and dozens of tree types so the count should not be a problem. I have not limited it. I am sorry I have to make you look through with the debugger, but I don't have your code :). The custom made SpeedTree's are also not a problem since mine are also a combination of SpeedTree standard ones from them and custom made by me.
     
  28. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,156
    Actually, I mistakenly thought that the difference between those two methods, was that the terrain tree instances persisted in the editor, but I was wrong. In both cases they are deleted.
     
  29. GingerDr73

    GingerDr73

    Joined:
    Sep 25, 2013
    Posts:
    21
    Solved my problem, I had assigned prefabs of the trees on the terrain. This worked fine when the prefabs had the same name as the .spm's but doesn't work when they are different. I just re-assigned the .spm's to the terrain and it all works fine.
     
  30. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Outch, forgot to tell people that the prefabs require unique names, and require to be added to the terrain.

    The requirement for them to be in the terrain's prototypes is quite bad, since I implemented some add-on to the system so that you can add trees from the exterior and it is not mandatory for the trees to come from a terrain now. They can also be hand-placed.

    Should also make some documentation notes on this, so that people don't have to look through the code, and change the logic a bit.

    Will come in a future patch.
     
  31. marcatore

    marcatore

    Joined:
    May 22, 2015
    Posts:
    158
    Sorry @Assembler-Maze but if I've read well your system is working only with Speedtree trees...correct?
    If yes, is there a particular reason to exclude, for example, the trees made by Unity Tree editor? And is it too much work to extend this instancing method to standard 3d objects?
     
  32. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    It works only with SpeedTree since, for foliage, they are the performance bottleneck. The standard Unity trees don't need any optimization, they works just fine. It is a problem of meshes and wind animation. I don't think I can extract those meshes for Unity-creted trees.

    As for any game objects, that's the work of a terrain detail system for than a tree system. This is neither a grass for a detail system.

    But, since I still need a detail system, (the standard unity one is quite bad with the poor-looking vertex-lit items and missing normal maps) I will, probably, try to see how we can fit in extra objects with custom shaders. But there must be modifications, extra gridifying, etc...

    I'll keep you informed on the progress...
     
    one_one likes this.
  33. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    61
    Hi,

    I would like to know if it is possible to use this tool with a mesh and not a terrain.

    Thanks!
     
  34. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    69
    Hey there,

    first of all, thank you very much for your generous contribution. Your tree system has helped to boost performance in my use case by cutting down setpass calls for trees down from 1200 to 100 and have it look the same. I have a question though. Is it possible to determine whether trees outside the camera's view frustum drop shadows visible by the camera and draw those trees? I have a dense forest with progressing time of day and the disappearing shadows when turning around while the sun is standing low are very noticeable.

    I looked into the scripts and saw that you determine which trees to draw only by the camera clip planes which transform along with the camera and found no obvious way of changing this behavior.

    Greetings!
     
  35. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hey!

    Yes, I have just made a little update (will post it on github in the near future) that you can now use this tool to add trees from meshes and not only the terrain. For example, let's say that you have some big cliffs sitting on your terrain and you want to paint some trees on them. No problem! Paint/place your trees and tell the system that those trees must also be added to the system!

    The only bad thing is that the tree painted meshes must be inside the bounds of a terrain. I haven't introduced yet a gridifying mechanism that can gridify arbitrary meshes. I'll probably need to do that in the future.
     
  36. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, I know the issues (since I also have times of day, I couldn't not notice this), and I will have to fix it for the future, don't worry. I'll get my ideas from here. I have to determine the trees that are in the 'shadow set' that is trees that are between the camera and the light source and 'might' cast shadows inside your frame.

    But unfortunately, I didn't have time to look into this just yet. I'll probs have some 'working' unoptimized version the in near future.

    One thing is that we could request Unity to have us a 'GeometryUtility.IsShadowVisible' that takes as a parameter the camera, a light and the bounds of the object to ease our computations. Maybe I could ask them about that, but even if they would do it, it would probs take them till 5.6 and that's a lot of time :). I hope to have something going a little faster.
     
    Last edited: Dec 8, 2016
    jimmikaelkael and No0B25 like this.
  37. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    will this solution support tree destruction?
     
  38. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    No, and I don't have any plans for having something like that. However, when we'll have custom collisions (+100k trees) maybe we can add some 'trigger' to the custom colliders to get notified when we hit a tree. And we can 'remove' that tree from the managed list, create it as a real, instanced SpeedTree (out of my system) and destroy it. That is one thing that comes into my mind.

    But I will not do anything into that direction. It should be quite straight-forward if you need that feature.
     
  39. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    61
    Hey assembler, thanks for the reply.
    I have lots of terrains that have 3600 x 3900 size. Is there a way to use your asset? I tryed using cell size 300 but it didn't worked.

    Thanks.
     
  40. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hm... If there are even sizes it should work. But to be honest I have never tested it with non-square terrains, only with multi-tile square terrains.

    When I have time I'll look into it, fix it, and will make the next update with:
    - tree shadow fix
    - painting objects on non-terrains
    - non-square terrains
     
    Mukabr and No0B25 like this.
  41. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    61
    Hello @Assembler-Maze, I'm using your tree system in my project and it is pretty awesome.
    I would like to ask if there is any way to moviment the trees. Currently the terrain have more or less 45 km X 35 km and there are a lot of trees. It is working pretty fine, but since the terrain is huge, we have a paging system, so we need to move the terrain+the trees from time to time depending on the player postion.
    The terrains and the Trees are static in your project, so I dont have the option to move it. So, there is a way to use the system without it being static?

    Thanks,
    Murillo.
     
  42. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hey, I'm glad that it works for your project. Unfortunately I didn't had time to make the fixed I've talked about in the previous post, I hope that I'll be able to do it in the near future.

    For moving the trees around there is nothing of that kind implemented. I think that you have to apply that offset with the stored trees yourself, in the 'TreeSystem' script (they're all stored there).
     
  43. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    61
    Hey @Assembler-Maze, I'm having some trouble to to move the Billboard asset.
    I tryed changing the information from TreeSystem>ManagedTerrains>Cells>Instances but it only worked for lod 0, lod1 and lod2, but not for the Billboard.

    Also, I would like to know if there is a way to make the project work with multiple cameras.
    Sorry for bothering so much, its because your project is openning so many doors for me :)

    Thanks again,
    Murillo.
     
  44. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, about the billboards. The thing is that they are 'baked' into a mesh in world space. What you can try is regenerating that in real-time or apply the offset to the game objects containing the baked meshes.

    You can make the project work with multi-cameras by going in the 'TreeSystem' and in the 'Graphics.DrawMeshInstanced' pass in 'null' for the camera slot. It will render the trees for all the camera then.
     
  45. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    61
    Hello @Assembler-Maze, how could I apply the offset in the game object that is marked as static?

    I was able to use the project with lots of cameras (of course it was not as fast as just one camera :( ). Thanks!

    Murillo.
     
  46. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    As i wrote before, im using world streamer to stream in my terrains using several scenes. But i still have one "design scene" that has all terrain present at once. Would it be possible to create the trees there and then somehow transfer the baked information to the "game" scene? The game scene dont have any terrains at all in it self, but if i somehow can use the baked information, this should not be a problem?
     
  47. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    You can uncheck the 'static' checkbox. But from what you have told me, you are developing a huge 40x40sq km open game? I strongly suggest to, at least, have some programming advisor, since you will find for the course of the project more and more technical problems.

    I will solve as many bugs/problems as I can for this system, but I can't promise world streaming, spherical worlds, unreal like world offset, and other things that people might require.
     
  48. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, I am sorry for this, but I made some silly terrain dependent operations in the system, that are quite useless, since they can be 'baked'. I have to fix that for my game too, since my case is exact the same, I use some terrain that I delete after, and the trees/bounds colliders are already stored in world-space.

    But in that case I also need to, somehow, make that tree colliding system, since removing the tree-terrain removes the tree's collisions, that are terrain-dependent at the moment, and that is no easy task.

    I hope that the next update can come next weekend.
     
  49. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    Ok, cool!
     
  50. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    61
    The Non-Squared terrains will be supported in this version?

    Thanks!
     
unityunity