Search Unity

Critias Tree System [Asset Store]

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

  1. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    I was thinking of using a dot product between the billboard normal and the main light direction to find out when the camera is seeing the "back side". This however was not turning out well and I skipped over this feature entirely due to time constraints. With the hue shift I experienced a different error - the 3d tree hue shift differed from that of the billboards.
    It was acting like there was a fundamental difference in the positional data stored inside the billboard uv coordinates and the model matrix of the trees. I don't know if I fixed that error or if it is still in the current version of the shader I use.
     
  2. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I've encountered some problem with the billboard hue variation too, it's the same thing that you mentioned. Unfortunately I've already sent it to the asset store for review in v1 of the foliage system. I don't really know how can the matrix be different from the UV sent data, but I see that for the billboard HUE they also use some extra data, not only the matrix one:

    float3 worldPos = IN.vertex.xyz + float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w);
    float hueVariationAmount = frac(worldPos.x + worldPos.y + worldPos.z);

    However I have no idea how that IN.vertex really comes in a billboard since it's practically a quad but it's not in quite the format I send it to the GPU. Anyway if I manage to fix it I'll post the shader here or on github.
     
    Marco-Sperling likes this.
  3. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I've solved the problem by setting the cell size to 250 instead of 50 and turning down the 'Max Tree Distance' to 100 from 999. Since at 999 meters you will never see a billboard, all trees would be meshes :)

    Let me know if anything else breaks after making those modifications.
     
  4. RoloJo

    RoloJo

    Joined:
    Feb 26, 2013
    Posts:
    28
    I would like to try do what you have suggested in order to remove a tree from the list.
    What is the name of the list and in which class is it sitting?
    Will the collider be removed if I remove the tree from the managed list?
    Can I add trees in a similar manner?

    Thank you!
     
  5. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    For a system that should fully support that see my 'Critias Foliage'.

    If you want add it to this tree system just look into the class 'TreeSystem' that holds the trees that get rendered. It holds a list of 'TreeSystemTerrain' that hold a list of structured trees or type 'TreeSystemStructuredTrees' called 'm_CellsStructured'. Those 'TreeSystemStructuredTrees' hold an array of 'TreeSystemStoredInstance' and 'TreeSystemLODInstance' both called 'm_Instances' and 'm_InstanceData'.

    Remove the data from those arrays at runtime (with any c# API of your choice) and that will remove the tree from the system. Not supported for billboard trees since the billboard can't be regenerated at runtime.
     
    RoloJo likes this.
  6. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi @Assembler-Maze , first thanks for an amazing system. Been playing with it in VR with dynamic weather, and some issues.

    First is the known billboard light: where it is not affected by light. Any updates/suggestions on this?

    Next: maybe it's due to VR, but tree distance doesn't seem to work completely. With a 2kmX2km terrain, if I'm at centre, a tree distance of 1000 should make almost all the trees I see into mesh, and if my light is pointing up (night), all trees should appear black. In practice, it works upto distance of 400 or so: trees close to me turns black and further away trees are still green (billboard?), even when my distance is set to maximum.

    Also, have you thought of season: i.e. Shader hue for all trees?

    Thanks again.
     
  7. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Hello,

    The billboards get affected by light but yea there are some issues there, I'm looking into them to try and solve them for the best results.

    I've just tried with the new Foliage System having a light straight up and it looks fine to me. However see that you have the reflection probes in the scene and that you baked your light so that the ambient term gets involved and doesn't make you trees completely black.

    Even if it works I would really NOT recommend having a light pointing straight up but I'd have some light during the night like the moon or anything else that might be hidden and give a little bit of color to the scene.

    Even if you set the distance to 1000 if you have let's say a cell size of 200 the maximum distance is 200 even if it shows 1000 in the UI. That is because of an optimization that is only the 9 cells around the player are tested for visibility and not more than that to save a lot of CPU time. In practice you will probably use a cell size of 100-500m and a tree distance of 30-50m for the best performance.

    In the new system I'm working on you can get around that by default (even though highly not recomended) and have the maximum distance of 1000m. However that will test for more than the default 9 cells around the player thus incurring a higher CPU overhead. You can also have per-type distances, for example have a bush distance of 20m and a big tree distance of 100m.
     
  8. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    OK, I'll give that a try.
     
  9. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi, actually the light pointing up was to quickly see which trees were meshes (would be black), and which were billboard (bright green); in reality, for this scene, I'm using late summer sunset time in 2017 Idaho (don't ask me why :D just because) - so it's quite a low light, and billboarded trees look wrong.

    >> Even if you set the distance to 1000 if you have let's say a cell size of 200 the maximum distance is 200

    Aah, that makes sense. But I'm afraid that calculation might still be a bit off - reason being, I'm pretty sure I've a 1kmX1km with cell size of 512 - being in the middle should make most trees into meshes.

    Ofcourse I'm not planning to have that high a settings: but at the same time, I'm looking at an adaptive system where it would tweak settings runtime.

    I'll try play with materials in the mean-time to see if I can get the light to look correct. Eagerly waiting for Foliage: even if I can achieve the same result with your two free assets, I want to support your work, and you will hear a lot from me :D
     
  10. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Getting following shader error on build:

    Shader error in 'Critias/Nature/SpeedTree Master': 'UnityApplyDitherCrossFade': cannot convert from 'struct v2f' to 'float2' at line 102 (on d3d11)

    using Unity2017.1.1
     
  11. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Update: My mistake with the billboards - though I had light up, it was the skybox that caused the tree to be visible at night. If I remove skybox, it behaves like the mesh tree.
     
  12. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I'm not entirely sure what that error is, but if you refresh the shaders and stuff it should go away. I think it's just a problem of Unity, not entirely sure that it's my system.

    Yes, watch for your ambient spherical harmonical generated by the skybox, it might be too bright some time and it can cause a lot of trouble.

    If you say that the distance doesn't work correctly, I'll look into it maybe I've missed something.
     
  13. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    80
    If this could just work in VR, it will be the greatest leap in VR for environments!!
     
  14. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    I got it working in Linear SinglePass Stereo rendering with SteamVR; no more bobbing billboards for me.
     
  15. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Please ignore that comment. I think I had 8 tiles instead of 4; which would explain the behaviour. I'll test some more and write down.

    Any eta on foliage? Dying to try it out.
     
  16. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    80
    Keep us updated on that test!!
     
  17. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    80
    Single pass stereo Rendering.... Where's that option?
     
  18. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    The full foliage system is still in review (week 3 already).

    And please if you have problems, don't post many short comments with each problem individually but make a post with all the problems so that I can respond without omitting by mistake anything that you might have said.
     
  19. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    It's under Player settings.
     
  20. ivabibliocad

    ivabibliocad

    Joined:
    Jan 11, 2014
    Posts:
    80
    GREAT, thanks!!!
     
  21. gamedeveloper512

    gamedeveloper512

    Joined:
    Jun 14, 2013
    Posts:
    16
    Hello! Testing your solution and find that chunks with trees are popping when i rotating camera. Moreover, the less FPS, the more its popping. Is there any solution for this? I use Unity 2017.1.0b10 & reproduced that in Unity 2017.1.0f3 too. Another issue is that when i rotate back billboards dissapered.
     
  22. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Could you send some info related to your CPU/GPU?
     
  23. gamedeveloper512

    gamedeveloper512

    Joined:
    Jun 14, 2013
    Posts:
    16
    AMD FX(tm)-4300
    GTX 1050 Ti

    Other guys in office have the same issues (tested on different CPUs (Intel based too)).

    Also find how to reproduce billboards bug: when you change tab in play mode they are dissapeared
     
  24. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Yes, the billboards vanish if you lose focus. However in a built game you should never lose focus so it should not be a problem.

    And is the problem appearing due to low FPS? Works bad on the GPU? Since the gtx is a decent card, you should not have problems with it.

    What would be your tree count/density, view distance, other objects in scene etc?
     
  25. gamedeveloper512

    gamedeveloper512

    Joined:
    Jun 14, 2013
    Posts:
    16
    The issue appears always, but it is easier to see with lower fps
     
  26. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Any other important data? Tree density, tree count, view distance, objects in scene etc? Since the billboards are not related to my system they are added as meshes with a lod group to unity they are not managed by me.
     
  27. gamedeveloper512

    gamedeveloper512

    Joined:
    Jun 14, 2013
    Posts:
    16
    2500х2500 terrain,
    ~40 000 trees,
    ~512 cell size,
    Objects count doesn't affect (I reproduced this on empty scene with default terrain, ~64, ~256 cell sizes, ~1000 trees also).
     
  28. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    As I've also said in the private message feel free to pack a project and send it over to me, to see if I can reproduce the issue.
     
  29. Erikduss

    Erikduss

    Joined:
    Oct 9, 2017
    Posts:
    5
    Hello,
    I've came across an issue, I have managed to create a reversed occusion. Everything that's far away renders in, and everything that's close is not visable. The objects close still have collision.

    As you can see here there are trees all around the scene.
    SceneCamera.png

    These trees are also generated already from the Treeifier script.
    If I preview the game scene something interesting happens.

    This is the preview with draw enables on the terrain for trees:
    GameDraw.png

    This is the game preview with draw disabled on the terrain for trees:
    GameNoDraw.png


    As you can see there should be trees close rendering, but not far away where they actually rendered in.
    I have been trying to fix this for a good amount of time now but I'm quite stuck.

    These are the scripts with the values etc, I simply followed the tutorial and looked at the values in the demo project.
    Scripts.png

    Here's a gif so you can see what exactly happens with the rendering.

    ezgif.com-resize (5).gif

    So basically when I get closer to the trees more of them render out, any ideas?
     
  30. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Well you can try the following:

    1. Regenerate all your tree data
    2. Set the cell size from 100 to something like 250 or larger and regenerate the trees
    3. Try a lower drawing distance like 80-100m at the beginning
     
  31. Erikduss

    Erikduss

    Joined:
    Oct 9, 2017
    Posts:
    5
    I've just tried this, and it doesn't make any difference. It still does the same exact thing.
     
  32. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    @Erikduss , what happens if you set Used camera in TreeSystem?
     
  33. Erikduss

    Erikduss

    Joined:
    Oct 9, 2017
    Posts:
    5
    @Assembler-Maze @ranaUK
    It doesn't change anything too, I do get this error log when pressing save on the TreeSystem script on line 115
     

    Attached Files:

  34. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Try deleting all data from CellHolder gameobject and all generated critias assets from your project before converting the trees. That's how we solved a similar issue.
     
  35. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    If it still doesn't work pack a project, I'll look over it and pinpoint the problem exactly. The error with the 'ShouldRunBehaviour' is not related to my system.

    PS: I was just informed by a user of the system that if in unity 2017 you set a camera to the 'used camera' it doesn't render the trees any more.
     
  36. Erikduss

    Erikduss

    Joined:
    Oct 9, 2017
    Posts:
    5
    I did not manage to fix this issue, I will send you the project in a couple minutes. I tried to reinstall the asset package. It didn't change anything.
     
  37. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    Have you tried enabling GPU Instancing on all produced materials? It worked for me.
     
  38. Erikduss

    Erikduss

    Joined:
    Oct 9, 2017
    Posts:
    5
    I managed to fix this, I created a new project. Nothing worked anymore on the old one. Thanks for the help though
     
    Assembler-Maze likes this.
  39. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    any idea if this works on mobile?
     
  40. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Only on metal/opengl3+ probably.
     
  41. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    Out of interest: Is this project dead? The Unity Asset Store tells me that the system is deprecated and no longer available.
     
  42. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    437
    OfficialHermie likes this.
  43. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Sorry, due to time constraints I can't manage 3 systems at once, it has been upgraded to the new foliage system.
     
    TooManySugar and OfficialHermie like this.