Search Unity

Problems with Nature/Tree Soft Occlusion Leaves shader

Discussion in 'Shaders' started by chanfort, Feb 9, 2015.

  1. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I am using this shader with terrain trees just because otherwise I am getting warnings:
    "the tree must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly."

    So I started to play with this shader, but unfortunately I am getting very bad results. Here are some of my trees, visible in mesh mode and billboard mode:
    Screen Shot 2015-02-09 at 22.18.13.png
    And here is the shader, which I am using:
    Screen Shot 2015-02-09 at 22.28.53.png
    The problem with this shader is that when trees are in billboard mode, their leaves are very dark (nearly black), but when they are in mesh mode (close to camera), their leaves are too bright. I tried to change all shader parameters, visible in second picture, but I didn't got any better results.

    What could be suggestions / advices to solve this problem?
     
  2. hamasakisan

    hamasakisan

    Joined:
    Mar 18, 2015
    Posts:
    1
  3. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I just placed my trees in "Ambient-Occlusion" folder as it is said in this page. Unfortunately it does not change anything. Should this folder be in specific location or something else?
     
  4. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    The page linked here that has a ref to Unity asking us to place the tree in a special folder is from 2 years ago, last edited in 2013. I wonder if this is still the case, always seemed pretty goofy to have to do things this way. :/
     
  5. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    did you reimport them after putting them in the folder?
    I just did this and it's working alright
     
  6. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    I'm not sure where to post this, but I'm having a major problem with trees looking strange. I read the documentation and even created a folder for trees named "Ambient-Occlusion" in my trees folder as notated. Even re-imported the trees and yet they don't look right.

    I posted a pic so you can see what I mean.

    Anyone know what I can do in order to get this fixed? It's either I get the warnings or have messed up trees....
     

    Attached Files:

  7. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Gonna bump this thread in hopes of getting someone to take a look at this for me. No idea why it isn't working, but I could use a bit of help.
     
  8. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Did you tried to play with sliders on the shader? I kind of managed to get leaves to be not so bright. The only things I could not find out yet are that Soft Occlusion Leaves shader does not receive shadows and I can't find out how to disable warning if I use different shaders (i.e. standard) on trees, which are placed on Unity Terrain.
     
  9. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    I messed around with the sliders, but it didn't fix the problem. I tried reloading the model again, but that didn't work. I've kinda gone back to the standard leaf shader for the time being because using the Soft Occlusion doesn't work. There has to be something I'm doing wrong, but everything seems to be in place according to what I've read. Does it matter where the "Ambient-Occlusion" folder is located? What about upper-case letters?
     
  10. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I am not sure about "Ambient-Occlusion" folder. As I tried to change it's location, it doesn't change things. The good point here would be when you have a good and working example, to back it up as a copy and then start experimenting. If things goes wrong, you can always restore from backup. When experimenting with sliders it could be best idea to find out what individual slider actually do.
     
  11. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    It's been a year and I still haven't gotten this fixed. Has anything come out about how trees are supposed to work and where the Ambient-Occlusion folder is supposed to go? I'm wondering if it needs to be in the Resources folder, but without any real information, I'm not sure. Trees are still messed up and I think I need to finally need to focus on getting it fixed.
     
  12. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    157
    Have you tried simply darkening the main color of the soft occlusion shader?
     
  13. ArthurForst

    ArthurForst

    Joined:
    Oct 30, 2015
    Posts:
    5
    Hey, i just came across this thread searching for something different =D In Case you are still looking for the solution. I had a similar issue and I think your issue isn't with the Occlusion but with the transparent pixels of the leaf-texture.

    All the transparent pixels around the leaf are black, that's why you are getting a black color average once you go further away from the tree. You should give the transparent pixels a color similar to your leaf, because that's the color that far away trees' leaves will have.

    I made an example leaf-texture to show you what i mean:
    InUnity.PNG


    Some Image editing programs don't save pixels with 0 alpha and then these will get treated like black pixels in unity. Just use some alpha (ex. 1/255) for the surrounding pixels.

    I hope this will solve your problem.

    EDIT: Btw. I don't have an Ambient Occlusion Folder. My textures (and Materials) are usally in Assets/Textures
     

    Attached Files:

    Last edited: Jun 1, 2017
    chanfort likes this.
  14. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Interesting point. So if I create my leaf texture procedurally in Unity (not using any image editors), can the background pixels have the same R, G and B pixel values as the leaf pixels, but for example alpha=1/255 ?
     
  15. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Thanks for the information. Looks like I was able to get it taken care of by following the examples in this thread. It's good to finally have the trees in my game actually look decent.
     
  16. dan_wipf

    dan_wipf

    Joined:
    Jan 30, 2017
    Posts:
    314
    You have to place your Imported Tree in the "Ambient-Occlusion" folder, and the re-import it! Then it should work!
     
  17. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    It's incredible that this is still the method in 2018, but putting the trees in a folder named "Ambient-Occlusion" and reimporting the trees did in fact fix it for me too.
     
    AyuubMang likes this.
  18. me4lmnts

    me4lmnts

    Joined:
    Aug 2, 2016
    Posts:
    8
    But what, if the trees are all made with unity tree creator???
    And can someone explain or has a link to a documentation about what the slider of the "Nature/Tree Soft Occlusion"-Shader actually mean and do?
     
    dan_wipf likes this.
  19. me4lmnts

    me4lmnts

    Joined:
    Aug 2, 2016
    Posts:
    8
    Well, at least I found this:

    Baselight - How much basic self-illumination the material has.
    Amb. Occlusion - How much leaves are darkened by being in the center of the tree.
    Dir Occlusion - How much leaves are lightened by being on the side of the tree facing the light.

    But the shading still looks crappier than with other shaders, which obviously arent supported when the trees are supposed to be painted on the unity terrain...
     
  20. bayatsaleh

    bayatsaleh

    Joined:
    Feb 6, 2018
    Posts:
    1
    Unity 2019 and I had the same issue with the shader:( and the problem with trees
     
  21. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    104
    It's unclear from the warning message but you can remove this warning by adding LODs to the object in question, in the OPs case add an LOD group to the 'Tree' object. If you wish to have a fast way of doing this consider using 'AutoLOD', its developed by Unity and works pretty well. Link to the repo is here, and you can import it through the package manager with the github link:

    https://github.com/Unity-Technologies/AutoLOD