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
    Thanks!

    About the lighting, what would you mean by that? I am not entirely sure. They are drawn with 'DrawMeshInstanced' and support about everything from Unity (except lightmapping and lightprobes). And at which tree features do you refer?
     
  2. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Unfortunately there is no support for non-square terrains. And I haven't tested for oculus/vr, I am sorry :(.
     
  3. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    80
    I just made the terrain square, re imported it, re-converted it with the "object to terrain" script and went to settings and found the dimensions where 3500 by 3500.0001, So I changed the second value to be 3500, the proceed with the set up and then... the same result, the script can't gridify the terrain...

    I've now managed to test this on a simple unity square terrain and it doesn't work in VR with Oculus Rift.
    When I test the finished processed scene I have to manually uncheck the "draw" trees option in the terrain settings, and then When I play i Found out that no trees in a radius of 600 meters are generated, but the colliders are really present there.
     
    Last edited: Aug 20, 2017
  4. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    80
    I've just tested the system with a normal 3500 x 3500 terrain with 70 000 trees. The stats information correctly states that the framerate increases from 15 fps to 74 fps but it doesn't look that way. In fact it looks much slower and terrible.
    Using Unity 2017.1 with 2 nvidia quadro k5000 windows 10.
     
  5. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hello,

    There could be many issues with your setup.

    1. Try to build it stand-alone and see the gain then (if there's any)
    2. If the terrible FPS still persist then there might be a number of issues:

    A. Try lowering the count of batched trees from 1k trees to 100 trees. Maybe the GPU can't have so large UBO's.
    B. "Your GPU does not support 'proper' gaming instancing". I have found out that it might be the case of many non-gaming design GPU's. People with high-end design/VR AMD GPU's have complained here about worst performance, but that is not my design or anything that has to do with my code. For example your quadro k5000 is about 2x times slower than a gtx 970 and about 1.1x times slower than a gtx570 and being a design GPU I am not sure it properly supports everything a gaming GPU does.
    B. "There is a Unity bug inside instancing code on certain GPU's". For this I asked a lot of people to submit bugs with their projects and bug reporters explaining the issue to Unity (I did that myself no answer). I thought it is a AMD gpu only bug since people were reporting that only on AMD but now since you have a NVIDIA card it seems that it's not an AMD issue but it might be something related to the fact that non-gaming cards don't properly support instancing (Point B).
    C. "The whole instancing idea as I use it is bad". I really thought at that, and that maybe I do it wrong, but then I decided to ask help from professionals. I've managed to mail one of the main engineers at Ubisoft (working for ghost reckon wildlands) and I've asked them if they use instancing like I do (plain instancing, SV_InstanceID) or if they use smarter, more portable but more difficult to implement soft/merge-instancing or runtime VBO instancing. They confirmed me that they use plain instancing just as I use it for everything, from grass to trees and details, so there's no bad design/bug on my side.

    My advice would be to test the system on a gtx570+ or some other gaming card.
     
  6. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Hi,
    here someone asked you how to overcome the visible transition from 3d trees to billboards:
    https://forum.unity3d.com/threads/critias-tree-system-asset-store.437520/page-7#post-3104357

    You suggested implementing hue shift colorization as seen in the original SpeedTrees.
    Any more hints on how to implement this feature into your asset would be great.
    Wouldn't your billboard meshes get batched into one static mesh and wouldn't this cancel any operations that rely on the position of the given mesh? Ssince the resulting meshes would always have their pivot at world 0, 0, 0?
    If so - how does a billboard vertex know what pivot position it belongs to? Are you sending additional data per vertex to the billboard shader? If so - where?
     
  7. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, someone solved the issue but I don't have time to look on how to integrate his solution at the moment. You can ask how he did it. And yes there is extra data (world pos per billboard) passed to the billboard static mesh. The pivot is baked in the UV2 channel.
     
  8. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Thanks, got it to work few minutes ago. Now I need to brighten the backside of the billboards a little (translucency) and darken their front a little since they still look way brighter than any of the 3d trees.
    For others:
    You want to use IN.texcoord1 of the billboard vertex shader to calculate the HueShiftAmount. This can be evaluated per pixel later in the surface function.
     
  9. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Thanks for the tip, I'll try integrate it when I'll have some spare minutes.
     
  10. Sphira

    Sphira

    Joined:
    Aug 29, 2017
    Posts:
    5
    Hello,
    I've follow all the tutorial (http://www.unwrittencritias.com/?p=87)
    but everytime i push "Generate trees" my Unity crashes.
    What am I doing wrong? I tried in 2 different computers, same problem...
     
  11. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hello!

    I've noticed that the crashing comes up when the setup has not been done correctly.

    You can try the following:

    1. Regenerate all your speedtree's materials(in their prefab window) and regenerate all the system's data
    2. Make sure that your cell size is something reasonable at something around 100-300meters and not 1meter since that for a 1x1km terrain would generate 1 million cells that will result in a hard crash

    If those did not work out feel free to post me a demo project here or on your dropbox and I'd be happy to look into the problem!
     
  12. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    203
    WOW !!! TNX !!!
     
  13. Sphira

    Sphira

    Joined:
    Aug 29, 2017
    Posts:
    5
    Thank you very much
    it worked :)

    But now I'm using Gaia Asset for my Terrain,
    And everytime I push Play the Trees near the Player disappear, but the billboards far away does show up,
    Maybe i'm also doing something wrong...

    Edit: The grass also disappear...
     
  14. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    Hello Assembler-Maze,

    I was able to get the tree system working on our 4km game terrain with 70k trees, it really helps! One question, we had previously been using our own speed tree prefabs. As you know a lot of speed trees have these giant sphere colliders on top, and on steeper terrain this ends up blocking the player. So we have tags on certain colliders not to block the player.

    Using your system which requires the original spm trees, is there a way we could address this issue?

    Thanks and best regards,
    Heinz
     
  15. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Using Gaia should be absolutely no problem. Try disabling occlusion culling from the settings that makes a lot of trouble.
     
  16. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Well, I can think at 2 solutions:

    1. Make the colliders smaller on the prefabs
    2. In the script TreeColliders at line "GameObject collider = GetColliderForPrototype(hash);" you can try set the tags there for your trees. However I am not sure how you use those tags so I'm afraid you'll have to figure it our by yourself
     
  17. Sphira

    Sphira

    Joined:
    Aug 29, 2017
    Posts:
    5
    It's still not working and I have this Error
    (Sorry I'm not a programmer, I don't understand much about this kind of things)

    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:405)
    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:2121)
    TreeSystem.Draw3DLODInstanced (.TreeSystemLODData& data, UnityEngine.Matrix4x4[]& positions, System.Single[]& lodDetail, System.Single[]& lodFull, System.Int32& count, System.Boolean& shadowsOnly) (at D:/Collide/Teste_2/muffy-does-git/Assets/CritiasTreeSystem/Code/TreeSystem.cs:1074)
    TreeSystem.IssueDrawTrees (.TreeSystemPrototypeData data, .TreeSystemStructuredTrees trees, System.Int32[] indices, System.Single[] dist, Int32 count, Boolean shadowsOnly) (at D:/Collide/Teste_2/muffy-does-git/Assets/CritiasTreeSystem/Code/TreeSystem.cs:997)
    TreeSystem.ProcessTerrainCell (.TreeSystemStructuredTrees cell, System.Single& treeDistSqr, System.Single& shadowDistSqr) (at D:/Collide/Teste_2/muffy-does-git/Assets/CritiasTreeSystem/Code/TreeSystem.cs:836)
    TreeSystem.ProcessTerrain (.TreeSystemTerrain terrain, System.Single& treeDistSqr, System.Single& shadowDistSqr) (at D:/Collide/Teste_2/muffy-does-git/Assets/CritiasTreeSystem/Code/TreeSystem.cs:712)
     
  18. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    Thank you for those suggestions. Sorry I should have been more specific, we have those colliders on a specific layer.
     
  19. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Well, at that line of code where you can create the prefab I guess that you can move it to any layer you want with the standard Unity mechanisms.

    Use:
    collider.layer = LayerMask.GetMask("YourPhysicsMask");
     
  20. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hello!

    You have to go to the material that is used and tick the 'Enable Instancing' option inside the tree's material. If instancing is not enabled you will get that error.
     
  21. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    As a note for those interested, I plan in merging the Grass/Tree system into a bigger foliage system that will only require you to add the prefabs to the scene and paint them and will also do all the setup for you. It will be made close to the UE foliage system model.

    When I'll have more info I'll probably make a new forum post.
     
  22. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    Thanks for that tip! So far we're getting good results, here is a quick test I did last night with Critias running in our game map. Just have to figure out a good grass application solution.

    Running in Unity 2017.1p4 Editor, 4km terrain with 60k SpeedTrees and many game objects placed. i7-4930k + GTX 970 CPU.

     
  23. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Looks very nice!

    As for optimization just be careful with the tree distance, make sure that your LOD1+ do not cast shadows etc...
     
  24. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    Thanks! A couple of new issues I could use your help with.

    1) When I run the physics debugger I see multiple copies of the same tree colliders around the player. Is this just an artifact of the Editor trees? None of the trees are set to static, and these overlapping colliders have different rotations:



    2) There's a small tree attached to our player above and slightly behind (can be seen in the same screen above). Any ideas why that would happen?

    Thanks as always,
    Heinz
     
    Last edited: Sep 4, 2017
  25. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    1. For the physics stuff, make sure that the tree colliders from the terrain are disabled (you can disable the trees completely). However the wrong rotation might be a bug. I haven't encountered when I tested but it might be the case.

    2. The tree attached to the player does not have any colliders or any physics and they are only used for copying the wind and sending it over to the other trees around the player. I am working on some solution (like making them invisible with a shader or something) to make them as invisible as possible.

    As a note I already started working on some other tree system made from a combination of the foliage and the tree system that based on spatial-hasing with a sparse array that should work considerably better, not be dependent upon a terrain, and have foliage included.
     
  26. tryptic

    tryptic

    Joined:
    Nov 13, 2012
    Posts:
    55
    By 'disabled' if you mean turning off the "Draw" checkbox under "Tree & Detail Objects" in the Terrain settings, I've done that, but the multiple overlapping colliders are still showing in the debugger while the game is running fyi.
     
  27. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    It means that it might be a bug, I'll look into it when I'll have a spare moment.
     
  28. Sphira

    Sphira

    Joined:
    Aug 29, 2017
    Posts:
    5
    Hello!

    Thank you, it did worked :)

    Now I'm using Critias Grass System at the same time as Critias Tree System and I have 7 Errors like this

    Assets/CritiasTreeSystem/Code/RowCol.cs(7,15): error CS0101: The namespace `global::' already contains a definition for `RowCol'
     
  29. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Autch, I haven't tested them together with their latest versions I'm afraid. My quick tip is to delete the one the contains less code.

    And for the universal solving of those problems (I think I've mentioned before) but I'm working on another combination of Critias Trees/Grass into a full foliage solution that should work about the same like the Unreal one.

    Here's a screenshot of my current progress:
    Progress.jpg

    Should have the same features that other Critias systems have plus:
    - 1 minute setup - everything should be automated not like other Critias systems
    - auto grid generation (this time it uses some sort of spatial hashing so that we don't have to generate the cells)
    - no need to generate any edit time data
    - runtime instance adding (like for destructible trees)
    - runtime instance generation (like outputting data from Gaia or GeNa into the system)
    - edit time painting
    - support for any object object not only grass
    - support for millions of blades of grass and hundreds of k of trees
    - absolute independence from the terrain system
     
  30. Private

    Private

    Joined:
    Jul 30, 2014
    Posts:
    6
    Have and exception in runtime: Assertion failed: Assertion failed on expression: 'scriptParameterClass != NULL'
    any ideas? unity 2017.2
     
  31. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Sorry, I think that might be related to something else maybe? There's no param called that in my code. I'll see when I have time, maybe there's some 2017.2 only problem since the system was submitted for 2017.1.
     
  32. Private

    Private

    Joined:
    Jul 30, 2014
    Posts:
    6
    Thanks. And btw. slot for custom trees disappeared in latest version. Is it temporary?
     
  33. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Sorry, what do you mean by custom trees? Non-speed tree ones?
     
  34. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    For those interested in a complete grass/tree, easy to setup system based on this tree and the grass system check out 'Critias Foliage System'. It is a lot easier to setup than this system and with a lot in addition!

    No more terrain-dependent cells, no more gridification, no more data extraction. Just a button press!
     
  35. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    I was going to use this system but now it's been submitted as a 2017.1 project I can't as it doesn't allow a download with Unity 5.6 and says I have to upgrade. Sadly I can't upgrade to 2017.1 yet as it has too many issues with assets I'm using that haven't upgraded yet. Any way around this as I'm sure there are literally hundreds of developers like me who now just can't download or use this. Is it actually dependent on Unit 2017.1 now?
     
  36. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hello.

    The tree system isn't dependent on 2017 yet I've just submitted it with 2017 (unlike the foliage system that is dependant on 2017 due to some shader parameters). You can grab a version from github or download that one from the market with an 2017 unity and import it to your 5.6 project.
     
  37. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    ok, thanks, I'll give it a try
     
  38. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
  39. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    I'm just trying to setup a simple demo project (following the tutorial videos you produced) and I have two problems. First I'm just not getting any billboards showing up (trees just disappear instead of showing the billboard) and second when I look at the generated MeshCells I get the following error and it totally crashes unity ....
    upload_2017-9-22_15-31-21.png
     
  40. WinterboltGames

    WinterboltGames

    Joined:
    Jul 27, 2016
    Posts:
    259
    I guess that error is related to unity not to the tree system
     
  41. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    The tree system created the game object causing unity to crash out, so I don't think we can hang the hat on Unity being totally at fault here
     
    WinterboltGames likes this.
  42. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Make sure that your cell size is at least 100mx100m. If it is something like 1m it will generate 500x500 billboard batches that is 250k objects that will crash your unity. It's unity 5.6 right?

    If it's 5.6 and everything went cool and the cells are cool, I'm not totally sure what's wrong. It is the first time that I see that error.

    Try regenerating all the data, regenerating your tree's materials, and starting a clean scene with a terrain with trees only.
     
    Last edited: Sep 22, 2017
    catfink likes this.
  43. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    Here is a video of it all and what is happening, hopefully someone may be able to spot what is wrong ....
     
  44. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    No this is unity 2017.1 I haven't tried with 5.6 yet, maybe you will spot something in the video. Anyhow I will try generating from scratch again and see if it resolves.
     
  45. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, very weird. Everything seems to be in order in the video, can't say that anything is wrong. However I'd ask you to pack the project and share it to me. I'll look into it myself (Monday or Tuesday) if that is fine by you.
     
  46. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    I just tried to use your grass system with the tree system, but am getting a bunch of errors saying the Critias Tree System "namespace 'global::' already contains a definition for..." a whole bunch of things.
     
  47. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    Would love to see this implemented as well, the switch from model to billboard, especially around sunset/sunrise is very noticeable.

    I'm curious how you are supposed to adjust the back and front side of a billboard, though, when billboards always face the camera? Or are you talking about some shader code?
     
  48. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I'm sorry, some classes have duplicates, when I integrated them both in my project I manually removed some duplicate classes (like 'RowCol'). You should do the same.

    For your second comment I am not entirely sure what you mean. You mean something like subsurface scattering or something? Because that's what the 'translucency' comment seems like to me. Of course the billboards would look way better with SSS, however I'd also require a thickness map for them and I don't know where to pull one from.

    As for the hue shift i've implemented it in my new foliage system. Quite easy to do it by yourself if you need, you just need to copy the speedtree hue colorization code in your fragment shader. If I have some spare time I'll update a version of that shader on github or somewhere.
     
    Exbleative likes this.
  49. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
  50. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630