Search Unity

Unity Custom Tree and Terrain Issues

Discussion in 'General Graphics' started by JanDawid, Feb 17, 2017.

  1. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Might be an easy solution but I can't find out what to do to remedy this:



    I've made my billboard distance quite short so you can see the difference; the lighter coloured trees/bushes (in contrast to the darker ones at the bottom) are the billboard versions of the speedtrees that populate my terrain.
    Why are they so bright? I've messed around with the Ambient Occlusion, scene lighting, etc. etc. but nothing fixes this. And yes, it looks the same in game mode and in the build.

    This ISN'T using speedtree, but the built-in Unity tree creator.
    Any ideas??

    Edit: I think what I want might not be possible with billboards... any other ideas on how I can render more trees in the distance without them being full res? (Bonus points if this is still using the built in terrain-tree system) Even if it has to be billboards then how to get them to be lit the same way as the 3D trees?
     
    Last edited: Feb 18, 2017
  2. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Changing the translucency colour on the tree prefabs seems to help a bunch, but it's not perfect. Might be the best I'll get with billboards.
     
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Have the same issue the billboard trees are not good at all.
     
  4. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    I've found a happy medium for now. Set the translucency colour to grey (128, 128, 128), the dependency to 0, shadow strength to 0.5, ambient occlusion ON and intensity to 0.2. Do this by dragging in your tree prefab onto the scene, changing the values and then applying the prefab.

    I think it's just something we have to deal with when it comes to billboards because it doesn't make sense for a 2D image to react to 3D lighting all around.

    I wonder if there's a way to, instead of turning the trees into billboards, they turn into low-res meshes?...
     
  5. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,875
    Low poly mesh tree is a lot better than billboard. You can use a 4 side billboard as LOD2 slot for performance reasons. (Just for side view).
    Unity 4 billboard trees works prefect with both dynamic and Lightmapped lightings.
     
  6. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    How do I get the tree mechanic in the terrain system to use a 4-sided billboard? And are Unity 4 billboard trees different from unity 5 billboard trees? And any way I could get the terrain system to use low-poly mesh trees instead of billboard?
     
  7. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,875
    No. Unity terrain system is not good for place trees. You can make LOD of your trees and paint with prefab painters on ground. Set an 4 sided tree billboard as LOD2 slot and paint to your terrain.
    For culling, you can use Per Layer Camera Clipping as well. I have tested this option in my mobile games and is a lot better in performance compare to unity terrain system trees. Also scene lighting is a lot better with mesh tree . You can also light mapping your scene easily.
    Unity terrain system grass and trees uses a lot of memory and some times my game is crashed in low end devices. Billboard system is just good for sand box games.

    Unity 4 terrain system is not different. Just Unity 5 lighting has a few bugs in some cases.
     
  8. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    I think I'll look into the best way of making different LODs for trees, perhaps abandon using the terrain tree painter.
    I'll keep you all updated.
     
  9. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Okay, is there any way I can add a low poly mesh tree between the full-res mesh tree and the billboard one? I think it's a bit lazy that all Unity did was give you those two options; the difference in detail between the two is too jarring to fade between them properly. Can I add another 'level of quality' between them so that it can still be used by the tree painter on the terrain?

    Or is it just as efficient to simply make 3 separate prefabs (full mesh, half res mesh and billboard) for each tree, blend between them in a script and place them on the terrain manually as game-objects?
     
  10. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,875
    You need to use Level of Detail component in your models. Or just simply use Simplygon to create automatically level of details(LOD) for your models. Unity doesn't support fade option.
     
    JanDawid likes this.
  11. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Alright, this might be what I've been looking for; I'm gonna try simplygon (I think THIS LINK is a bit more helpful) and I'll report back!
     
  12. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Was really excited to use Simplygon but looks like they've abandoned the asset; you need to login with an account to use it but there's no way of getting an account. So many people complaining in the asset reviews, it's kind of strange...
     
  13. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Okay, solution found!
    Simply get an empty object, apply the LOD Group component and attach the different LODs as children (each child is a tree or billboard). Save the new empty object as a prefab (make sure you configure your LODs, obviously). Then just import it as a tree in the tree painter for the terrain!
    Why was this so tough to discover?! Haha.
     
  14. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,875
    Add a simple LookAt script to your billboard tree
     
    MatheusPereiraBarros likes this.
  15. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    I won't have them looking directly at the camera because it's weird in first person. I'll have them look at the x,z position instead.

    Okay so I've got it working quite efficiently with my above set-up, however there's one last issue.
    So I make this LOD prefab with the separate quality trees as children (high, low, billboard) and if I place the prefab into the scene (as a gameobject) it reacts to the wind zone like it should. But for some reason, when the prefab is painted on to the terrain as a tree, it doesn't react to the wind at all! Why's this?
     
    Last edited: Feb 20, 2017
  16. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,875
    Use wave shader in tree leaf material
     

    Attached Files:

  17. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Shader didn't make a difference. :(
     
  18. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,875
    It's not affected by terrain settings:
     
  19. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    The tree prefab is affected by the wind zone on its own, just not when it's painted on as a tree on the terrain, I think it's a bug.
     
  20. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    Okay so I've got a good set-up now that essentially disregards Unity's terrain tree system. Instead I use it to just paint on the trees but then my method works its magic and boom, results! I might sell this set-up on the asset store so I'll contemplate that idea (it'll be super cheap though). It's mainly my script that you use at the end so it's more-so the way you do this all.

    This basically means that you can make trees with multiple LOD groups, paint them on the terrain, take advantage of wind and not suffer any performance loss. As far as I can tell, it seems better than the built-in terrain tree system. I'm getting around 200-300 set passes in a very dense forest with dense grass, image effects, advanced water, etc. running at a smooth 60fps on ultra settings. I know it's not the most specific description of how good the performance is here, but take my word for it that it's running silky smooth.
     
  21. jmarcos007

    jmarcos007

    Joined:
    Mar 2, 2017
    Posts:
    11
    That´s it! Nice work man! Saves me lot of time. Works perfectly for me. God bless you!
     
    MatheusPereiraBarros likes this.