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. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    319
    Hi lars,

    Giving AFSv4 another go after giving up last time, tried following the guides but ending up with some weird billboards that don't match the in-scene trees at all.

    The trees are using the AFS materials. We are linear/deferred.

     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    the billboards do not look as if they were aligned to the camera perspective – so i guess you have forgotten to add the afs setup script to your scene?
    the script is needed to e.g. pass the correct ambient lighting to the rendertex shaders (which are used to render the billboard textures).

    how does your lighting setup look like?

    btw. it always take a while to update the billboards (unity engine restriction): you have to rotate the main camera a bit to force an update.
     
  3. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi Lars, Is AFS 5 going to be the product as AFS4 or will it be an upgrade path/completely separate?

    Also any roadmap to release etc.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    afs 5 will be the first update you will have to pay for :( i guess it will be something like 5$ or so.
    and it is nearly finished: i just have to clean up code.
    as i am very short of time right now you may expect in in january 2017.

    lars
     
  5. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    I do i uninstall this? everytime i delete to folder it just reinstalls itself once i select my terrain
    Also just disabling the script wont work as the default unity grass waving is not working then.
     
  6. GingerDr73

    GingerDr73

    Joined:
    Sep 25, 2013
    Posts:
    21
    Hi Lars, looking forward to AFS 5. Could you give a quick summary of the features that will be included in the new version? Will we be able to use it with SpeedTrees?

    Cheers:)
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    that sounds spooky... but i doubt is does.
    afs ships with a grass shader for the terrain, which overwrites the built in one.
    in order to get rid of it you have to find the "AfsGrassShader Terrain v4.shader" in the project tab. then delete it or rename it to e.g. AfsGrassShader Terrain v4._shader" so unity will not compile it.
    you may have to restart unity to make it work.
    the same goes for the "AfsFoliageShader Terrain v4.shader" which overwrites the built in vertexlit shader.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    no, speedtrees will not be handled by AFS 5. i may add that later though...

    here is my current changelog.
    • Lighting unified and optimized for deferred rendering. Except for grass all shaders use physically based shading built on top of Unity’s built in BRDF and support proper translucent lighting in both forward and deferred rendering.
    • GPU instancing support for foliage and tree shaders added.
    • Wind is now basically driven by a built in directional Wind Zone.
    • Foliage shader optimized for single sided geometry which lets you save a lot of vertices and still gives your correct lighting in both forward and deferred rendering.
    • Foliage shader for the terrain engine high quality tangents added (instead of the formally estimated ones) so bump mapping works perfectly.
    • Tree shaders use the new unified lighting which means physically based shading and deferred translucency. Transitions between mesh and billboard are improved as shadows will fade in. Added support for wetness (beta).
    • Billboards now use alpha testing and write to the depth buffer properly by default in order to make them work with depth based image effects like volumetric lighting. Alpha blending might be enabled manually.
    • Grass shaders now support wetness (beta).
    • Touch bending revisited. No need to use different materials and shaders anymore. Simply enable touch bending in the material editor and add the “touchBendingCollision” script to your model which now handles a (theoretically) endless number of registered touches.
    • Foliage Tool now supports Blueprints which let you copy settings from prefab to prefab in order to e.g. create LODs. Improved adjustment of vertex colors and Debug View added.
    • Wind on grass has been reworked. Please check your scenes and adjust the “Wind settings for Grass Shaders” properly.
    • Combined Meshes Proper information about the original pivot now are baked as well so you will get less stretching and advanced variation in bending.
    • Setup Script some performance improvements added.
    • Dropped support for static batching Use GPU instancing instead or combine instances using the Combine Children script.
    • Formally statically combined and baked meshes may be corrupted.
    • Tree shaders Dropped support for billboarded leaf meshes for performance reasons. I guess pretty much nobody uses that feature anyway. But in case you do you may reactivate it by editing the shader.
     
  9. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    thanks, that worked
     
  10. The_Geoff

    The_Geoff

    Joined:
    Mar 22, 2014
    Posts:
    7
    Does touch bending work with terrain trees / bushes, or only trees placed as GameObjects?
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    touch bending needs plants to be placed as game objects.
     
  12. Diwan81

    Diwan81

    Joined:
    Nov 16, 2016
    Posts:
    5
    Hi Lars,

    We just got this cool tool for our studio and I'm looking for a guide on how to use your tool, so far I can't find any good documentation. Thanks
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    the documentation is part of the package – but it might not be the "good" documentation you were asking for.
    so do you have any specific questions?
     
  14. Diwan81

    Diwan81

    Joined:
    Nov 16, 2016
    Posts:
    5
    Ah I completelly missed that, just saw ton of docs under the main folder will take a look. Thanks!
     
  15. david55527

    david55527

    Joined:
    Mar 24, 2013
    Posts:
    58
    hi lars - how's progress on AFS 5 going? Still expecting a January release? I'm ready to throw my money at you for it :)
     
  16. Deccard

    Deccard

    Joined:
    Aug 1, 2016
    Posts:
    6
    Hi there,

    I'm currently working on procedural plant mesh generation.
    Would this project be useful for me or is it made to be used in design time?
     
  17. Diwan81

    Diwan81

    Joined:
    Nov 16, 2016
    Posts:
    5
    Hi Lars, when I apply the Combine Children AFS script to my prefab the plant dissapears from the scene in game mode. Have I missed a step somewhere? Note that the prefab neither has animation nor is it set to static.

    Nevermind, after looking over the documentation again. I see that you need to put the mesh into another gameobject and this one contains the script.

    Thanks!
     
    Last edited: Jan 19, 2017
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    progress is fine – but it might get february...
     
    Lex4art likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    upcoming version 5 might be more interesting as it supports instancing.
     
    Baldinoboy likes this.
  20. Diwan81

    Diwan81

    Joined:
    Nov 16, 2016
    Posts:
    5
    Hi Lars,

    I have some problems with the combine children AFS script. When applied to a group of vegetation, they all lose touch bending and will no longer interact with the player.
    Another issue I have is with the geometry brush, when the object prefab has a collider they connect to each others collision mesh and not on the surface I want to paint on.

    Thanks!
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    touch bending needs single game objects – so you may not combine any plants using it, sorry.
    that being said you problem with the geometry brush should be solved…
     
  22. Diwan81

    Diwan81

    Joined:
    Nov 16, 2016
    Posts:
    5
    Hi Lars, thanks for the reply. I see! That makes sense.

    Geometry brush is still not acting according to expectations, here is a screenshot using your assets.

    One last question regarding combine children AFS script. Is there a asset count/vertex count limitation to how many childrens there can be under one script? For some reason they dissapear when I apply lots of them, maybe over 200 grass instances.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    well, usually "pass placed" foliage does not have any colliders... but i may have a look into the script some day.
    vertex count is limited by unity to something around 65000.
     
  24. Octavion

    Octavion

    Joined:
    Jan 24, 2017
    Posts:
    2
    Hi Thanks for this great asset, and is low price.I have a problem with touch bending. My player is made with third person controller, i have a rigid boby ,capsule collider , and touchBendingCollisionGS script . I use dry grass touch bending prefab with trigger on, but my player have collision with the plant (and can't interract correctly with the touch bending) .i m so dispointed...could you have a soluce please? ( If i make a cube with collider trigger on i have no problem to cross it with my player)
     
    Last edited: Jan 24, 2017
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    you have to mark the collider of the plant as "trigger".
     
  26. Octavion

    Octavion

    Joined:
    Jan 24, 2017
    Posts:
    2
    Thx for the answer, my collider plant is marked as trigger....like i said i can't cross the plant with trigger actived , i don't have this problem when a try to cross a cube with collider and trigger as true.. i followed all steps on the pdf..
    My player object have rigidboby, capsule collider and touch bender listener script and the plant prefab is dry grass touch bending by default (so with tigger as true and touch bending collision GS)...However my player object have a collision... (.sorry for my english)...I find a way to move y center axe collider, upper ,and it work well...
     
    Last edited: Jan 24, 2017
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    well, afs does not handle collision, that is done by the unity engine.
    so either you have detected a bug – or something still is wrong with your setup...
    please have a look at the provided demo scene.
     
  28. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    379
    Hi,

    I'm tempted to dive straight in for V4 but can see that V5 is on the way. Is there discount for V5 for V4 users or will it be a whole separate cost? If so, I think I'll hold out.

    Cheers!
     
    Lex4art likes this.
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    you will be able to upgrade fom v4 to v5.
    so buying v4 + upgrading to v5 will be = buying v5.

    so in case you should start with version 4 now please don NOT use legacy bending (bending only stored in vertex colors) but use "vertex colors and uvs" instead: v5 will most likely ship with a new bending wich drops ambient occlusion so all bending information can simply and properly stored in vertex colors.
    you should also only use single sided geometry. v5 will handle that in deferred better than v4. and it will save you a lot of data (and hassle editing double sided geometry...).
     
    Baldinoboy likes this.
  30. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    379
    Wooo! That's great, I'm going to grab straight away then. Thanks!
     
  31. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    379
    OK, looking great so far, thanks!

    Just wandering what general approach is for lightmapping, is it even possible? I'm having some issues with the trees coming out black. I'm guessing lightmapping trees a little problematic for foliage and trees that use wind.

    Just wondering what the approach is to lightmapping - whether the general approach is to go with real-time lighting and shadows?
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    lightmapping is not supported by the tree shader - but by all other shaders.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    Hi there,

    before i will start to clean up the initial package of version 5.0 i have taken some time to make a litte short:

     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    finally version 5 has been submitted today.
     
  35. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,523
    Awesome! Great to hear man. The above video is amazing!
     
  36. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    Question about pricing for updating from v4 to v5 - how much it will cost?
     
  37. GingerDr73

    GingerDr73

    Joined:
    Sep 25, 2013
    Posts:
    21
    Nice work! Looking forward to giving it a try :)
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    7 $
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    thanks
     
    GingerDr73 likes this.
  40. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    What are the requirements for using version 5?
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    unity 5.4 or above.
     
    magique likes this.
  42. ryschawy

    ryschawy

    Joined:
    Jul 28, 2012
    Posts:
    65
    Is it available? I can't see anything on the store.
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    unfortunately it is still in approval – for 14 days now :(
     
    Lex4art and Too-Nerd-To-Die like this.
  44. ryschawy

    ryschawy

    Joined:
    Jul 28, 2012
    Posts:
    65
    good things come to those who wait :)
     
    jdraper3 and Too-Nerd-To-Die like this.
  45. Shadex

    Shadex

    Joined:
    Dec 18, 2013
    Posts:
    89
    Hey, so i am interested in AFS as it seems many people have done great terrains with it. I am having trouble making grass look any where near realistic, so i am hoping this may fix that problem. I have a few questions though.

    1. Can you use other grass / folliage / tree assets with this? Are there any limitations (like speedtree doesn't work, or only grass meshes or something)
    2. How is the speed compared to the normal unity terrain system for tree's or grass assuming your using a lot of grass (i routinely am getting 2 mil tris + on normal forests due to unity grass amounts)
    3. Any video's on how to set it up or a workflow video?
    4. Demo's are not working, is there another link to any of them?
    5. Any tutorials on building terrain with this system? or game ready projects?
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    • grass: in order to fully benefit from all feature you can only use grass meshes – which however might be a single quad. simply adding textures will not let you use a lot of the advanced fatures.
    • foliage: there is no specific "foliage" in unity. in afs foliage are just meshes – either added to the terrain engine or placed as game objects and maybe combined into larger patches. in order to make bending work nicely on foliage you will have to set it up by painting vertex colors to your meshes manually in your 3d app – or by using the included foliage tool.
    • trees: afs replaces the built in tree creator shaders giving you nicer lighting and better billboards including nicer fading between mesh trees and billboards. speedtrees are not effected.
    speed is not really effected by afs as it is still unity's terrain engine which does most of the job. with version 5 at least the rendering of trees should be accelerated as the afs shaders take benefit from gpu instancing giving you far less draw calls.
    not at the moment. all i can offer is the online documentation of the upcoming version 5:
    https://docs.google.com/document/d/164MTEnV_-krBdMr-20QhPttY1bY5H46FtpSDM1UQdRk
    i have only on more or less up to date demo right now: it is called "the forest" and available at steam. unfortunately it is not free.
     
    Lex4art likes this.
  47. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    638
    Hello lars I talk about it in Lux shader forum but this is question about advnance foliage shader, Why if I use speed tree on terrain there are light probes on trees, but when I use normal unity tree with your shader there are now light probes (like on screen) There is ambient light off because I dont use it. But there should be indirect bounce from light probes? Am I doing something wrong? or should i Upgrade to version 5 of your shader ( I saw it is avaliable)
    upload_2017-3-13_13-55-9.png
     
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    as far as i can say unity does not bake light probes for tree creator tree added to the terrain.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    jdraper3, ryschawy, Lex4art and 4 others like this.
  50. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,523