Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Advanced foliage shader [released]

Discussion in 'Assets and Asset Store' started by larsbertram1, Apr 24, 2012.

  1. blazespinnaker

    blazespinnaker

    Joined:
    Dec 20, 2015
    Posts:
    80
    Well, I think the discussion is getting a bit circular here. Good luck, all.
     
  2. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,523
    I am inclined to agree. You too.
     
  3. artistpetemac

    artistpetemac

    Joined:
    Sep 8, 2014
    Posts:
    19
    Hi Lars and friends,

    I've hand modeled a tree in 3ds max, and want it to render in 1 call, so I applied the Afs Tree Creator Leaves Optimized to whole thing, trunk included. This causes the geometry to get all bent out of shape for some reason. On the left is the model using Tree Soft Occlusion Leaves, it looks basically correct. On the right is the same model with the Afs shader on it. What's going on here? Is the shader making some assumptions about the model being a Unity Tree in some way?
    PinesCapture.JPG
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    yes, it is a replacement for the built in tree creator leaves shader which needs bending information stored in vertex colors and uv2.
    so for manually modeled trees you could either use the regular afs foliage shader and set up bending just using vertex colors added in 3d max, you could use the foliage tool which would even let you stiore bending information in vertex colors and uv4 giving you nicer bending - or you could use my "custom tree importer" package from the asset store which will give you probably the best results.

    lars
     
  5. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Lars, I sent an e-mail yesterday, but haven't heard back so I'll post the question here. I'm very interested in a lot of your tree packs, but they are all from Unity 3 and some reviews are complaining that they are not working in Unity 5 out-of-the-box. So, my first question is whether or not these tree packs will be updated for Unity 5? Second, are all those tree packs designed to work with the Advanced Foliage Shader?
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    sorry, i haven't had the time to answer yet.
    all trees are modeled using the built in tree creator. so there should basically work even in unity5.
    some packages contain old unity 3.x custom tree shaders (which are broken in u5), others contain copies of the old shaders (broken in u5) to allow you to assign the "optimized" tree shaders manually by dragging them onto your material.
    but if you simple get rid of the custom shaders, assign the built in tree creator shaders to the base materials and update the trees, everything should work fine - except from the highres 2048 textures.

    and of course all trees should simply work with afs. they are just regular trees.

    lars
     
  7. artistpetemac

    artistpetemac

    Joined:
    Sep 8, 2014
    Posts:
    19
    Hi Lars, Thanks for the tips. I tried the regular foliage shader, but that doesn't let me use the trees as trees. No billboards. I tried using the simple tree shader, which looked okay, but the billboards still had the mesh issues. Then I tried using your custom tree importer which worked pretty well except that it requires 2 materials. Then I remembered your script for collapsing down to one. Huzzah! Now we're in business. Thanks again.
     
    hopeful likes this.
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    you are welcome!
    lars
     
  9. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    So what can be done about the hires textured trees?
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    you will have to import the built in tree creator shaders so you can create a new material and drop the tree creator leaves optimized and/or bark optimized onto that material in the project tab.
    then you can add any texture you want.

    lars
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Alright. If I get the packs and get to that part I'll see if I can make it work. Thanks for the info. I definitely want to use those packs in my game.
     
  12. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    127
    hello guys. i got these warnings in console. is it something important or should i just ignore it?
    message:
    must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly.
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,523
    That is just saying the shader for the tree you are using with the terrain needs a correct shader or the billboarding is not going to work. You can use the AFS Simple Tree shader, think that is the name, but not the regular Foliage v4 shader with the terrain.
     
    kilju likes this.
  14. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    127
    It works now :) thank you for your help!
     
  15. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi, I would like to ask if afs could be used on trees, then if an object brushes against leaves if those leaves could move out of the way..is that possible?
    P.S I'm still using Unity 4.6
     
  16. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,523
    With AFS touchbending setup as it is the whole tree, plant bends when touched.
     
  17. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Oh wow sounds cool, is there a demo video of this, I cannot find one for some reason?
     
  18. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,523
  19. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Any idea why I'm suddenly getting this problem when making builds to PS4?
    I have the shader set to the fast tree shader.

    264:43:27 The tree blueFlowerBush_billboard must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly.
    264:43:27
    264:43:27 (Filename: C:/buildslave/unity/build/Runtime/Terrain/TreeDatabase.cpp Line: 181)
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    fast tree shaders are not supported by afs.
     
  21. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I meant the simple tree shader, but I figured out that if I added the shaders to the always loaded shader list the issue goes away.
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
  23. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Hey Lars,
    A while ago, we had to downgrade to Unity 5.1.4 due to issues with the new versions, and we're using AFS v.4.0.1 but I'm having some weird visual issues. We're using DX11, Deferred and Linear Color Space. The bark is using the Nature/AFS Tree Creator Bark Deferred and the leaves are using Nature/AFS Tree Creator Leaves.

    http://imgur.com/a/ZLDMF

    The first image is the tree how it looks in the scene and in the game without post processing. Some of the leaves and all the fronds are completely black.
    The second image is when I turn Scion Post Process on with only tonemapping. The black parts now turn white. With Unity's tonemapping I don't have this issue, but we've had too many other issues with it, so we can't use it unfortunately.
    I had this problem on the bark as well, when I was just using Nature/AFS Tree Creator Bark on there (With more weird black parts on the trunk, seen here: http://i.imgur.com/KEygIj8.png), but switching to the deferred version fixed that.

    I can't tell if this is an issue with AFS or Scion, but because I had other weird looking artifacts with AFS I thought I'd ask you first. Am I missing something? Why are some parts of the leaves completely black (Only to turn white with post processing)?

    I hope you have an idea :)
     
  24. Ramsdal

    Ramsdal

    Joined:
    Oct 18, 2013
    Posts:
    251
    Hi Lars

    I purchased this pack a while ago, and now I find myself working on a mobile project. Are anything in this pack suitable for mobile or would it be better for me to grab your free mobile shader pack? What I would like in particular is the touch blending feature :)

    Sorry if it has been asked but since you have "mobile" in your signature it is a little time consuming to search the thread :)
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hi ramsdal,
    personally i have never tested the shaders on mobil.
    so i can't really tell about their performance. but as a roule of thumb: if you can afford to run trees using the built in tree creator shaders you will most likely be able to use afs shaders too.

    lars
     
  26. M0rrigan

    M0rrigan

    Joined:
    May 29, 2015
    Posts:
    29
    Hi, I'm using AFS in my project and I would need an emissive effect on vegetation, also because my scene is pretty dark. I am using the Grass Shader v4, I think I should modify this shader. Do you have any suggestion?
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    you will have to write your own lighting function to do so. get the "Lighting.cginc" file from the built in shader resources and modify it. then include the modified version in the grass shader.
    but if it just too dark you may raise and brighten the albedo.
     
    M0rrigan likes this.
  28. M0rrigan

    M0rrigan

    Joined:
    May 29, 2015
    Posts:
    29
    Thanks Lars, I'll try that. Yes, the grass seems too dark. I've noticed that when I hit play it gets darker. Don't know if it's normal or not. Anyone has experienced the same situation?
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    grass is lit correctly in playmode – or when it is combined statically. pleas refer to the docs.
     
  30. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    127
    I seem to get some odd grey borders on my trees at nighttime. anybody got idea how to get rid of them?
    only happens with billboards
    heres screenshot of it:
     

    Attached Files:

  31. treshold

    treshold

    Joined:
    Nov 9, 2013
    Posts:
    225
    You could try to edit Billboard shader and adjust render queue setting.
     
  32. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    127
  33. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Is there any easy way to manually tweak billboard tint color? Or just make it look closer to mesh tree. For me there is very distinctive difference between mesh and billboard in terms of color, it isn't just lack of ao in billboard, the color itself is very different.
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    do you use gamma color space?
    in linear the color should pretty much match.
    but with any version of unity 5.x they have changed the way billboards get rendered or stored or whatever – so with unity 5.3.1. and linear lighting billboards more or less match 100% in color (using skybox ambient lighting).
    but of course they do not recieve real time shadows (including self shadowing). so in case you have very strong shadows and pretty low ambient light shadows cause problems too.
    lars
     
  35. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I'm seeing some really strange behavior and I'm wondering if it's an AFS issue or just a Unity issue in general. Anyway, I've got a Conifer tree from the AFS sample and the following terrain settings:

    Tree Distance = 128
    Billboard Start = 25

    I would expect to see trees as far as 128 away, but render as billboards starting at 25 from the camera. Since here is what the manual says:

    Tree Distance The distance (from camera) beyond which trees will be culled.
    Billboard Start The distance (from camera) at which 3D tree objects will be replaced by billboard images.

    However, in order for me to see the trees out to 128, I need to change the settings to the following:

    Tree Distance = 128
    Billboard Start = 100

    Very strange. Any ideas?
     
  36. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    127
    if u are using unity terrain and painting trees to it. u have to use simple tree shader to billboards work correctly
     
  37. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    You mean the Nature\Afs Simple Tree v4 shader? I've changed to that now, cleared, and re-painted the trees. It didn't help. Also, I have an issue where there are some terrain areas where it just refuses to paint AFS assets. I'll be painting just fine and then I hit a large patch of terrain and it just refuses to lay down any trees or grass.
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    to be honest: i have never tried such settings as in my opinion they do not do much sense:
    if billboards start at 100m distance then every tree beyond that distance will be rendered as billboard = more or less for free. not really of course but quite cheap.
    why do you want to have billboards only over such a short distance?

    lars
     
  39. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Desperate for performance gains since I am getting hit hard for what I would consider to be insignificant things. However, I've made some changes to shadow settings as it turns out that most of my issues were due to those settings being cranked up too much. So, I think I'm good to go now on performance issues regarding trees.
     
  40. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Thanks for reply. Using 5.3.1 and linear color space. Also using rtp, maybe this has something to do with it?
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    rtp should not effect billboard rendering.
    which ambient mode do you use? skybox should give you the best results…
    which version of unity do you use? dx9, dx11 or opengl?
     
  42. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Ambient using skybox, using default 6-sided skybox shader, dx11. I think it can be Unity bug, will try on newest version soon.
     
  43. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    The values in grass translucency specularity don't affect anything. Generally things just don't seem to work...
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hmm, that seems to be one of your favourite claims. but things work.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    Bildschirmfoto 2016-02-17 um 01.56.40.png
    this is on.

    Bildschirmfoto 2016-02-17 um 01.56.53.png
    this is off. nothing more to tweak here.
    any other parameters affecting translucency are not related to grass.
     
  46. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Ok, it was my fault mostly, I had terrain trees billboards tint set to red, but still after setting tint to black billboards were a little too bright, would be nice to have better control on billboards color/tint.
     
  47. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Having trouble with geometry brush. Followed the steps, but nothing is being placed. Am I the only one?
     
  48. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Oh, it had to do with my model being an odd scale instead like 1.
     
  49. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Curious, what is the reason the foliage shaders are one sided with doubled up geometry and not using Cull Off instead?
     
    RockSPb likes this.
  50. Wpitzer

    Wpitzer

    Joined:
    Sep 12, 2015
    Posts:
    1
    I've been using this to make custom plants and things have gone great so far! Thanks for all the hard work on this tool.

    I tried making some custom grass using the AFS Grass Shader though and I'm having a bit of a problem. I'm sure it's something stupid I did to the grass model but I'd love any help you might be able to offer. The red grass on the right, which works great, is before I added any values to the Alpha of the vertex colors of the model. So those models dont blow correctly in the wind, the base moves around in the ground. I added alpha = 0 to the base of the grass model using Maya, Alpha = 0.5 to the mid and 1 to the top. I bring the new model into Unity and the whole thing just renders as black, which you can see on the left side of the attached image. Any ideas?