Search Unity

Advanced foliage shader [released]

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

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    unfortunately: no. but a 4k atlas should offer plenty of space.
     
  2. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Does AFS work with Metal? The asset store description does not say...
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    i think so.
     
  4. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Hi, I tried to use the shader with skinned mesh. We have some monsters which are tree or have many leaves. Rather than animating all of those branches or leaves, I just want to test if we can also use this shader or not. And it didn't work nicely. My knowledge of shader is still very limited. Can you explain to me why does the shader not work with skinned mesh? Do they calculate vertex color differently between mesh filter and skinned mesh? Is it possible to modify shader so that it also works with skinned mesh? If it's yes then where should I look into?
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    what actually happened?
    skinned mesh renderes should not have any impact on the vertex colors.
     
  6. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    It turns into something like this.
     

    Attached Files:

    • bush.JPG
      bush.JPG
      File size:
      52.3 KB
      Views:
      714
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    hmm, i would expect some glitches, but not such heavy distortion.
    that is with a gentle breeze or heavy wind?
     
  8. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    I tested it in Foliage Shader Overview Demo scene. It starts to distort when main value of wind zone is more than 0.
     
    Last edited: Nov 7, 2018
  9. WeirderChimp

    WeirderChimp

    Joined:
    Nov 21, 2012
    Posts:
    26
    Hello, I have a question regarding the compatibility and limitations of the Advanced Foliage Shader v5 asset.

    Do the foliage shaders have to be used with Unity's Tree Creator tool, or can they be applied to a non tree creator mesh and still benefit from Wind & touch blending?

    Are the wind animations based off unity's wind solution or a custom one - (wind masks? to specify exactly which parts of the mesh should be effected).

    Thanks ~Scott
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    the foliage shader can be used on custom meshes – although these have to have baked bending information.
    the package comes with a tool tht allows you to bake simple bending information right within unity.
    for more complex animations you would also have to paint vertex colors in your 3d app.

    model and texture guide:
    https://docs.google.com/document/d/...Y5H46FtpSDM1UQdRk/edit#heading=h.3zmd2wgozbsj

    foliage tool
    https://docs.google.com/document/d/...Y5H46FtpSDM1UQdRk/edit#heading=h.bruc835yaov5
     
  11. WeirderChimp

    WeirderChimp

    Joined:
    Nov 21, 2012
    Posts:
    26

    Thanks for the reply.

    So does this "baked bending information" cover both touch bending and wind animation. And can this tool be used on "tree's / grass" or only foliage?

    And is the "wind animation" done using unity's wind component or a different method?

    ~Scott
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    only foliage.
    afs tree shaders only cover tree creator shaders.
    and grass is a completely different story as well.

    wind is derived from unity's built in wind zones.
     
  13. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    508
    Why looks like this? (After upgrading to Unity 2018.2.9)
     

    Attached Files:

    • AFS.png
      AFS.png
      File size:
      495.6 KB
      Views:
      730
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    i guess you are using deferred but haven't assigned the afs deferred lighting and reflection shader.
     
  15. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    508
    I didn't change anything, just import the asset and then I take this pic.

    Edit: In a new project there is no same issue! I don't know what's wrong with my project! It's a deferred and linear color space project.
     
    Last edited: Nov 13, 2018
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    you have to assign the shaders manually in any new project. please follow the docs:


    • Before starting please make sure that your project is set to use the linear color space in Edit -> Project Settings -> Player.

    • In case your camera uses deferred rendering you also have to assign the Afs deferred lighting shaders in Edit -> Project Settings -> Graphics:

      • Under the Built-in shader settings change Deferred to custom, then assign the Afs_Internal-DeferredShading shader.
    Also change Deferred Reflections to Custom and assign the Afs_Internal-DeferredReflections shader.
     
    muzboz and Crossway like this.
  17. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    508
    Thanks for help, can we use those samples from demo scene in our game?
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    yes.
     
    Crossway likes this.
  19. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    Hey Lars,

    Any idea on how to convert a translucency map with subsurface scattering colors (RGB, like the ones from megascans) to a grey one used in your shader?
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    not really... simply convert to grayscale and adjust the contrast?
     
  21. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    hmm ok i think i will try to make a new texture by comparing the rgb colors of the albedo and the translucency map, wherever the difference in color is bigger it will have the greatest transmissivity which would be more white. If this doesn't work ill try your solution, thanks!
     
  22. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Hi. When Unity 2018.3 is released, do you plan to support HDRP?
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    i have not really looked in this, but i guess sooner or later afs will :)
     
  24. GWStudio

    GWStudio

    Joined:
    Sep 27, 2016
    Posts:
    109
    Does AFS support HDRP ?!
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    not at the moment as it is still in beta.
     
  26. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    When you said beta do you mean 2018.3 is still in beta or HDRP is still in preview?
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    hdrp
     
  28. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Hi, this is regards to creating Textures, I just find it a bit confusing.

    I don't know how to generate Transculency Map, from what software do I generate that?

    Also:

    Normap Map: Red (A) / Green (G)
    Transculency: Grey (R)
    Smoothness: Grey (B)

    And you have to combine these textures. How long does it take you to do this?
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    i paint it in photoshop...
    roughly 30 seconds.
     
    UnityRocksAlt likes this.
  30. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    30 Seconds? Can you please put a video so I can do it that way. It is the thought process. I will be happy, because right now I have so many plants but I do not know. Please, the asset is incomplete without that video.
     
  31. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Would you mind creating a shader which gives access to all channels, rather than combining textures? I just want to drop and run. I know there is performance loss but I will be using only few.
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    no video, sorry.
    but you just take the regular normal map. then:
    - select red channel and copy it to clipboard.
    - add alpha channel, paste from clipboard.
    - open your translucency texture (grayscale), select all and copy to clipboard.
    - switch back to the normal, select red color channel, paste.
    - do the same with the smoothness and the blue color channel.
     
    UnityRocksAlt and hopeful like this.
  33. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Thanks and sorry for late reply.
     
  34. jamie-jenssen

    jamie-jenssen

    Joined:
    Apr 3, 2014
    Posts:
    11
    Hey Lars, this is a very belated reply but I've come across the time where i'm needing to set these grass shaders up again and I've gotten to the same place where I got stuck at before and to me everything seems normal but my grass still goes black in play mode, everything else about the shader works i just cant get my head around it, oh and everything is combining
    as well. I would appreciate any help upload_2018-12-28_10-45-52.png
     
    Last edited: Dec 27, 2018
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    hmm, if everything is combined normals should be fine.
    in case you use deferred you could enter play mode and then use the frame debugger to have a look at the grass normals.
    btw.: which version of unity do you use?
     
  36. jamie-jenssen

    jamie-jenssen

    Joined:
    Apr 3, 2014
    Posts:
    11
    Thanks for the reply Lars, Yeah everything looks to be combined and i'm using unity version 2018.2.18f1

    upload_2018-12-29_9-27-33.png

    also i'm not to familiar with the frame debugger but I did manage to find the combined mesh in there maybe you can find something wrong in here?

    upload_2018-12-29_9-32-56.png upload_2018-12-29_9-33-29.png

    Much appreciated lars.
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    hmm, i tested grass in unity 2018.2.15 and everything looks just fine.
    so you must do something wrong... not sure what tho.

    combined grass in playmode:

    combined_grass.PNG

    and here you can see the grass normals in playmode: the ypretty much fit the underlaying ground normals as they show up the same color:

    grass_normals.PNG
     
  38. jamie-jenssen

    jamie-jenssen

    Joined:
    Apr 3, 2014
    Posts:
    11
    yeah it's odd, the normals seem to be good aswell I think, here's what they look like upload_2018-12-29_12-31-9.png
     
    Last edited: Dec 29, 2018
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    if that is in play mode then they are fine, yes.
    so the only difference left between edit mode and play mode are the vertex colors:
    while in edit mode the shader sets the vertex colors to white it expects the vertex colors to be set by script in play mode.

    so check the attached "combine children afs" script and look for the Healthy and Dry Color: are these set to black?
     
  40. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    It says it supports vegetation studio pro. And has indirect instancing support in the shader. Does it still renders in deferred rendering path with vegetation studio pro?
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    yes. why should it stop doing so?
     
  42. jamie-jenssen

    jamie-jenssen

    Joined:
    Apr 3, 2014
    Posts:
    11
    Hey lars, that was in play mode and yes these are set to white upload_2018-12-30_10-42-14.png

    I am using the grass model processor script to set up vertex color alpha maybe I am doing this wrong I have named my model "GrassClump_AfsGM03Testnew" should it just do it automatically on import? also when I don't combine the colors look fine but because i'm not combining the normals are broken. upload_2018-12-30_10-52-9.png
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    hmm, that is very strange: normals seem to be correct and vertex colors are set to white.
    no i have no other idea what might go wrong when entering playmode – as normals and vertex colors are the only difference.
    that looks fine.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    @Game_DevKH described a problem he had in the reviews on the asset store:


    it looks as if some normal maps are broken and some models lack proper vertex colors.
    latter seems especially strange because other instances of the "same"?! mesh look totally fine.
    but without further information about your normal maps and the actual setup of the models i can't really tell you what is going on.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    who knows... but adding grasses to paint trees does not seem to be a good idea.
     
  46. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Why are my grasses and foliages black when adding to the Paint Details and invisible when adding to Paint Trees?
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    actually i have not tested afs in 2018.3.
    so does the included demo scene look correct?

    if so shaders should be fine and you must have done something wrong.
    unfortunately the video does not show e.g. the healthy and dry colors you have chosen nor the rendering mode you have selected like gras or vertexLit.
     
  48. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Black object solved! Well... now how can I get Touch Bending work with terrain?
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,901
    touch bending is not supported on the terrain.
     
  50. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    What do I do? Who's going to place grass one by one? Is there some other way or any asset recommended?