Search Unity

[Unity 5] Something weird with trees alpha textures

Discussion in 'General Graphics' started by Rocotosx, Mar 5, 2015.

  1. Rocotosx

    Rocotosx

    Joined:
    Mar 4, 2015
    Posts:
    16
    Hello everyone!
    After updating my project to a new version of Unity, I faced quite a strange problem:
    - Trees alpha textures (leaves) have some kind of an outline, that uses the skybox color. When I change it, the color of outlines also changes.

    Practically the same stuff I met in one of the Beta versions, but thought it'll be fixed towards the release.

    It could be done somehow if you change the "alpha cutoff" parameter in the model itself. But it's not the solution...



     
  2. dahrrr

    dahrrr

    Joined:
    Jun 4, 2012
    Posts:
    52
    I got the same problem.
     
  3. clawd31

    clawd31

    Joined:
    Aug 5, 2013
    Posts:
    26
    Hey! I've just upgraded to Unity 5 and I have this problem too, I don't know how to fix this :/
    In the scene I can see those grey outlines and in the game it's blue (like the sky's color)

    -> I do not have this problem with Unity 4.6, only with Unity 5

    Scene view:


    InGame view:
     
  4. RodzGames

    RodzGames

    Joined:
    Dec 9, 2014
    Posts:
    24
    I also have this problem.
     
  5. MisterGasman

    MisterGasman

    Joined:
    Dec 13, 2012
    Posts:
    2
    Guys, i had the same problems, also with the betas. I finally found the problem. Its the camera background. Somehow it overrides the alpha. Reset the alpha somewhere in your code like this:
    Camera.Main.backgroundColor = new Color(0,0,0,0);
     
    Strom_CL, Rocotosx and clawd31 like this.
  6. clawd31

    clawd31

    Joined:
    Aug 5, 2013
    Posts:
    26
    Thanks, it works :)
     
  7. RodzGames

    RodzGames

    Joined:
    Dec 9, 2014
    Posts:
    24
    It doesn't work for me :(
     
  8. Rocotosx

    Rocotosx

    Joined:
    Mar 4, 2015
    Posts:
    16
    It works only in game, not in editor
     
  9. RodzGames

    RodzGames

    Joined:
    Dec 9, 2014
    Posts:
    24
    In my case, it doesn't work in the game with that line of code.
    The outlines are grey in the editor and they turn black in the game.

    It works if I uncheck "Receive Shadows" on the trees, but... I want these shadows... :(
     
  10. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    I am also having this issue. I have narrowed it down to the shadow texture for tree creator trees. When you set the shadow caster resolution (in tree creator) to full resolution the problem gets significantly better but doesn't go away entirely.

    If you can somehow replace that shadow texture with the diffuse it does fix the problem (but its wrong, and the leaves no longer cast shadows properly) but any messing with tree creator will simply regenerate the tree and overwrite this shadow texture with the problem version. I really think the core issue is in the shader (Hidden/Nature/Tree Creator Leaves Optimized). I am looking at it but nothing stands out immediately (maybe its referencing an old include, etc). I really despise the way Unity handled the tree generator with it creating hidden materials and using hidden shaders and all.

    Update: Changing from deferred to forward rendering "fixes" the issue completely. Though I doubt the intention is to eliminate tree creator trees from deferred rendering so I still think this is pretty big bug.
     
    Last edited: Mar 9, 2015
  11. dajyareo

    dajyareo

    Joined:
    Dec 7, 2014
    Posts:
    11
    I hit this issue as well and the "reset the camera alpha from code" trick didn't work for me. Switching to Forward rendering from Deferred (legacy deferred also has this issue) also "fixes" the issue for me, but this is definitely a bug in the tree leaf shader. Never hit this issue in 4.6 and dragging a tree into the scene directly has no weird outline.
     
  12. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    I'm having the same issue. Setting to Forward rendering also "hides" the problem, but certainly not a viable solution. It cuts me off from taking advantage of all of the new Deferred benefits. Anyone discovering a solid fix for this yet?
    upload_2015-3-11_10-23-29.png
     
  13. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Turning off "Receive shadows" on the tree did it for me in f4, obviously still not ideal.
     
  14. Ramazoid

    Ramazoid

    Joined:
    Mar 11, 2014
    Posts:
    8
    In Camera settings you have to change Rendering Path from "Legacy Deffered (light prepass)" to "Deferred" and that's all))
     
  15. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    no. you don't, well not everyone, since I tried that, and every other combination of simple tests like that.

    Glad it worked for you however I needed a shader to sort mine out.

    (Also it is a good idea to say which point version you mean, p2 that may work f4 it certainly won't)
     
  16. incrediclint

    incrediclint

    Joined:
    Mar 3, 2015
    Posts:
    1
    Checking 'HDR' on the camera fixes it as well in f4.
     
    twobob likes this.
  17. RickyX

    RickyX

    Joined:
    Jan 16, 2013
    Posts:
    280
    And i have to say, nice looking game :)
     
  18. Remiel

    Remiel

    Joined:
    Oct 17, 2012
    Posts:
    105
  19. Zaxs_Reaper

    Zaxs_Reaper

    Joined:
    Jul 8, 2014
    Posts:
    13
    Hey guys I found out a temporary fix
    Try to change your graphics emulation to shader 2 or 3 whatever it suits to your game
    Temporary fix.png
     

    Attached Files:

    theANMATOR2b likes this.
  20. thinhdev

    thinhdev

    Joined:
    May 2, 2015
    Posts:
    1
    hi, i like it :D
     
  21. Remiel

    Remiel

    Joined:
    Oct 17, 2012
    Posts:
    105
    Setting it to Shader Model 2 "fixes" the issue. However, it still remains in Shader Model 3 for me.
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,

    the error you all get it caused by the fact that in unity 5 writing to the z-buffer and rendering the shadow map is more or less the same. so the old trick (using a low res shadow texture for the leaves to safe some bandwidth) simply corrupts the z-buffer and results in holes as shown in your screen shoots.
    you can either get fully rid of this by:
    a) buying (mine, sorry) advanced foliage shader from the asset store or
    b) manually edit the tree creator shaders.
    c) setting the shadow texture to "full res" might reduce the artifacts but will not eliminate them completely.
    d) another possibility would be to manually copy the alpha channel of your diffuse texture to all three color channels of a new texture and using this as shadow texture (with same resolution, aniso settings, compression etc as the main tex) but even this might not fully solve the issue: it is still 2 different textures: the alpha channel of the diffuse and the shadow map.

    lars
     
    Remiel likes this.
  23. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    @larsbertram1, I'm not sure that Unity offers an ability to change shaders for TreeCreator made trees. Are you sure it is possible? Did you tried it?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes. and it works fine.
     
  25. MyGenericUsername

    MyGenericUsername

    Joined:
    Sep 6, 2014
    Posts:
    95
    I have not recieved a fix yet. Anyone?
     
  26. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    i'm getting the problem tried just about everything that was suggested but the problem persists

    since its affecting numerous members and since it works great prior to U5 i'm hoping it will soon be fixed.
     
  27. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Don't get your hopes high. As far as I know, this problem plagues U5 since beta. You can say that it was ignored for more than 6 moths.
     
    Last edited: May 18, 2015
  28. Zaxs_Reaper

    Zaxs_Reaper

    Joined:
    Jul 8, 2014
    Posts:
    13
    Hi guys
    I noticed when I changed the shader emulation GI doesn't work so I returned to No Emulation and tried to make the background color in the camera to bit dark grey and it works fine
     
    Last edited: May 18, 2015
  29. MyGenericUsername

    MyGenericUsername

    Joined:
    Sep 6, 2014
    Posts:
    95
    I am seeing this issue both in game and editor, i believe it has something to do with the nature shader's trying to use the same execution method as the standard shader but with transparency. I am currently trying to produce a new shader for all to use. It is stupid that Unity 5 did not maintain unity 4's Legacy nature shaders.
     
  30. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    Yeah noticed that U5 legacy shaders not always the same as U4 shaders.

    Still happy that they got U5 out to us and hopefully things like this will get fixed or someone will find workaround that we all can use...
     
  31. Skirbyl

    Skirbyl

    Joined:
    Sep 15, 2014
    Posts:
    2
    Hi, I was going fine in my unity project until I came across this problem, after troubleshooting and trying several work arounds, I came across a solution which seemed to be the only way it would work, it seems like a legitimate solution.

    Instructions:
    1. Import your texture of a tree branch with Transparent background (PNG Format)
    2. Apply These Settings :
    Texture type: Texture
    Alpha from Grayscale unticked
    Alpha Is transparent ticked
    Wrap Mode:Clamp
    Filter Mode: Bilinear (Does not matter as far as I've tried)
    Aniso Level: 0-16 (Does not matter as far as I've tried)

    3. Create New Material and apply these settings:
    Shader:Legacy Shaders/Transparent/Diffuse
    Apply your PNG Tree Branch Image

    4. Now, apply this material to the leaves of your tree, you will recieve the warning that you must have a nature shader applied, hit apply.
    Voila! Hopefully..

    Anyway, from experimenting, this works everytime for me, and as far as I've experimented, you can use different transparent shaders with your branch material before essentially "converting" it through the tree creator.

    I really hope this sums up this solution for everybody, it seems to be a real frustration.
     
  32. Skirbyl

    Skirbyl

    Joined:
    Sep 15, 2014
    Posts:
    2
    Lemme know if it works too! I'm interested to know if this was a purposeful procedure or whether it is a bug they are still trying to iron out.
     
  33. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    OK... linking in some useful parallel threads and info to this discussion:
    (This bug is driving more of us crazy than we realize, LOL)

    Unity Case Number 674542 and 688932 that references this bug:
    http://unity3d.com/search?refinement=issues&gq=674542

    Fix for shimmering trees:
    http://forum.unity3d.com/threads/fix-for-shimmering-trees-in-deferred-mode.311961/

    Discussion that brought that one about:
    http://forum.unity3d.com/threads/terrain-trees-sparkle-in-deferred-rendering.278851/

    Discussions about this same issue when in beta:
    http://forum.unity3d.com/threads/trees-with-white-bordered-leaves.306452/
    http://forum.unity3d.com/threads/terrain-tree-creator-billboard-artifacts.296884/
     
    Last edited: May 20, 2015
    im likes this.
  34. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    Holy crap... just spent 2 hours applying the Unity 5 nature/leaves materials to all the trees in Michael K's Winter asset... so much work but so worth it. Screenshot to show the difference (I made the camera background blood red so the problem would show up more easily against all the white snow.) trees1.jpg

    Fixing this is like a huge weight has been lifted off my shoulders! I'll post a screenshot to show an idea of what I did with all the trees.
     
    Last edited: May 21, 2015
    MyGenericUsername, pixxelbob and im like this.
  35. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    So for each tree's texture folders I made a new Nature/Tree Creator Leaves material and filled it in... I let Unity change the normal texture's attribute to normal, and just used the same texture for both gloss/translucency.
    NewMaterials.jpg
    After that I had to go to each prefab of the Trees and apply the new material to the leaves.
    AppliedMaterial.jpg
    Then I just had to refresh all the trees in the terrain.
     
  36. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    wow great job, thanks for taking time and effort to help us all!
     
    Dreamaster likes this.
  37. MyGenericUsername

    MyGenericUsername

    Joined:
    Sep 6, 2014
    Posts:
    95
    This may also help those who don't find the above post a fix... When turning off receive shadows on the terrin mesh renderer, the problem goes away. So if you don't find the above post as any help, sacrifice your realism by turning off receive shadows :D .... Hope that this helps find a real fix
     
  38. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    Thank you Dreamaster, it works, this is the proper solution.
    I've started working on the Real Nature trees.
     
    Last edited: May 25, 2015
    MyGenericUsername likes this.
  39. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Thanks for the information in this thread. That tree issue was driving me insane. It sucks having to redo all of the shaders and materials, but at least that's something.
     
  40. Rico21745

    Rico21745

    Joined:
    Apr 25, 2012
    Posts:
    409
    Is there no better way to fix this? This seems like an Unity 5 bug rather than something everyone should have go through on all their upgraded assets
     
  41. Nieles

    Nieles

    Joined:
    Dec 27, 2010
    Posts:
    50
    Definitely a bug that Unity should fix!
    This makes the tree creator pretty useless.
    Replacing the materials with your own "Tree creator leaves" material isn't really a solution since the material won't have the translucency property.
     
  42. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    @larsbertram1

    I've bought advanced foliage shader. But I have a lot of questions and problems with the process of updating trees. Please check your PM.
     
    Last edited: Jun 16, 2015
  43. bahteles

    bahteles

    Joined:
    Aug 10, 2014
    Posts:
    29
    Someone found a better solution to this bug?
     
  44. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    Replacing the leaf material with the Unity 5 Nature Tree Creator material works 100% of the time... I'm not sure what Neiles is talking about it not having transulency property... it's right there in the shader and you can even see it in my screenshot.
     
    drumonman and MyGenericUsername like this.
  45. StoneHeartEntertainment

    StoneHeartEntertainment

    Joined:
    Apr 26, 2014
    Posts:
    7
    In the Rendering Path option in your camera settings, select either Forward or Legacy Deferred.

    It worked for me at least.
     
  46. Rocotosx

    Rocotosx

    Joined:
    Mar 4, 2015
    Posts:
    16
    Well. After more than 3 months of waiting we still haven't a proper solution? Changing the shader model decreases the use of a new Deferred render to zero. I've read the whole thread, but haven't understand how you avoid this bug. Everyone does it in their own way

    Turning off the "Anti-Aliasing" box is not working obviously
     
    Last edited: Jul 15, 2015
    Stardog and drumonman like this.
  47. drumonman

    drumonman

    Joined:
    Nov 25, 2013
    Posts:
    5
    I'm also having weird issues with Unity's Terrain and Place Trees. I set up prefab with proper material, but when I place the trees using the Place Trees within the Terrain gameobject, it looks like I lose alpha channel completely.

    YetAnotherUnityBug_Tree_01.jpg
    On the left, the base prefab for the tree placed in scene. Material is working properly. On the right the same prefab placed within the terrain gameobject, not alpha clipped like it should be.

    I'm using the standard shader with alpha cutout rendering mode. Am I missing something? Shouldn't it look like the base prefab?

    Edit: Dreamaster I tried that before posting and it didn't work, I tried it again and now it works, I guess it just bugged out first time, thank you
     
    Last edited: Aug 4, 2015
  48. Dreamaster

    Dreamaster

    Joined:
    Aug 4, 2014
    Posts:
    148
    Change the shader from "Standard" to "Nature/Tree Creator Leaves".
     
    drumonman likes this.
  49. Rocotosx

    Rocotosx

    Joined:
    Mar 4, 2015
    Posts:
    16
    How can I change the tree shader properly? When I just edit the material, trees on the scene remain sill and don't affect any changes. Even if I choose standart shader without alpha at all. I refreshed it from the TREES tab in the terrain editing menu, and restarted Unity several times. No way.
     
  50. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    This is still completely bugged. The shader is already "Nature/Tree Creator Leaves".

    You can update the prefab by changing the "Optimized" materials to your materials, as mentioned above, but then billboards don't work unless you use the "Nature/Soft Occlusion Shader", but then the tree prefab will complain the leaves aren't using a tree shader...

    Terrible. How was this ok'd for release?
     
    MyGenericUsername likes this.