Search Unity

Advanced foliage shader [released]

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

  1. PutridPleasure

    PutridPleasure

    Joined:
    Mar 3, 2015
    Posts:
    11
    Hey Lars, I am really excited about testing afs in Unity 5, could you maybe give us an ETA?
    I'm currently updating this thread ever few hours to not miss the update :D
     
  2. larsbertram1

    larsbertram1

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

    right now i am spending a lot of time on working on the new release of the advanced foliage shaders for unity 5.
    but unfortunately i do not have as much time as i would like to have.

    so i would like to give you a brief overview over the current development status.

    afs 4 for unity 5 is progressing nicely.
    however i made a major mistake when i started to work on it six moths ago: i focused on the new lighting features which turned out to be very far from being finalised and changed pretty dynamically during the betas: so whenever a new beta came out lighting completely broke which in the end costed me a lot of time i would have better spent on things which are unique to afs – like bending.

    even though unity 5 is finally out i have changed my strategy meanwhile and now work on other core features such as bending and editor scripts.

    right now i think that the final release will contain the following features:

    Grass (manually placed or placed using the terrain engine)
    • enhanced bending following the given wind direction and giving you much more variation
    • approximated translucency depending on ONE defined directional light source (sun)
    Foliage (manually placed or placed using the terrain engine)
    • advanced bending
    • physically based shading using the built in lighting functions with added translucency on top (i might add wrapped around diffuse lighting as well – we will see)
    • support for non directional, directional and directional specular lightmapping (no translucency here – sorry)
    • support for dynamic lightmaps = GI
    • physically based wetness
    • legacy bending (stored in vertex color only)
    • ao
    Foliage (manually placed only)
    • advanced bending giving you full control over primary and secondary bending (using uv4)
    • touch bending
    Trees (placed using the terrain engine and trees created with the built in tree creator)
    • advanced bending which prevents most distortion artifacts you get from the built in shaders
    • smooth fading towards the billboard by fading out out wind, point lights and real time shadows (leaves only)
    • correct fog – which is broken in untiy 5 right now when using deferred rendering
    Billboards
    • support for skybox based, gradient and color based based lighting
    • camera alignment
    • fancy features from the latest release for unity 4.x – like shadows casted by billboards or fading shadows – are most likely not going to get into this version as unity 5 has completely changed the way the regular pass and the shadow caster pass are handled
    Foliage tool
    • improved integration and interface
    • bake primary and secondary bending to uv4 (needed by the new foliage shader bending option)
    • convert tree creator trees to be compatible with the foliage shader while keeping all bending information
      (this is just like a dream come true: super nicely bending trees, bushes and whatsoever which can be combined, batched and simply cause a single draw call).
    All other scripts (SetupAdvancedFoliageShader, RepositionTreesAFS and ShadedBillboardsAFS) will be updated o work with unity 5.

    so in the end:
    i had to drop some features due to the fact that unity 5 changed the rendering pipeline.
    but i have cleaned up and refactored a lot of the code and most features you are used to will simply work
    the next update will give you much nicer bending features so you might have to rework your meshes – however the updated foliage tool should make tis an ease.

    i still have to clean up the code, test it on windows and update all the documentation and example files.
    so please do not expect the update to be available within the next weeks.

    cheers,
    lars
     
  3. PutridPleasure

    PutridPleasure

    Joined:
    Mar 3, 2015
    Posts:
    11
    Sounds awesome!

    Will it be a new asset one the store or an update to afs 3?
    You once mention afs v4 and further down you talk about an update.
    I don't mind either way, you deserve it, just curious.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it will most likely be a free update ;-)
    good for your – bad for me.

    but to be honest: i really would like to be able to charge the full pice from new customers and charge a little upgrade fee from current users (like 5$ or so) as it really took me a while to get it working with unity 5 – not to mention all the improvements.
    but the asset store does not allow this at the moment as far as i know...

    lars
     
    OnePxl and x_african_warrior_x like this.
  5. MarcusWatson

    MarcusWatson

    Joined:
    Dec 9, 2014
    Posts:
    53
    How about letting current users donate via paypal or similar? It's not guaranteed income, but some cash is better than none.
     
    OnePxl likes this.
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    thanks a lot for your care about us asset store publishers. i will think about it.
    nevertheless it should be a built in feature to the asset store: that would make it just transparent if one thinks it is time for older customers to upgrade...
    but that is nothing you should make care about: as long as i have the time to wok on afs i will make sure that it is up to date.

    lars
     
    MarcusWatson likes this.
  7. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    How long time do you think it'd take to get this done? :)
     
  8. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    So in Unity 5.0's current state, is it even remotely possible to have terrain tree billboards casting shadows, lightmapped or otherwise? as far as I can tell lightmapping the scene doesn't even make shadows like it did in 4.x :(
     
  9. konsnos

    konsnos

    Joined:
    Feb 13, 2012
    Posts:
    121
    Not soon.

    But nevertheless, I thank you for the time you put in it lars. Your work is amazing :)
     
  10. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Prime, in Unity5 terrain trees dont have lightmapping support sadly. I really hope they will fix this asap.
     
  11. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Why wouldn't it be fast to make it happen on Unity 5? :O I mean, is it something shader related? I'd appreciate to know as it sounds as an interesting topic.
     
  12. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi Lars,

    Have you thought about making it compatible with SpeedTree Models? Actually, SpeedTree Unity Shaders are very bad, but SpeedTree Modeler is a great tool to speed the model creation. ¿Any way?

    P.D: The idea about donations its pretty good. I could donate the 5$ even much more if you need it.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i have to tounch everything: shaders, scripts, demos, documentation...
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    why do you think that speed tree shaders are bad?
    they use single sided leaves so they do not support "correct" diffuse lighting, bump mapping, translucency or specular lighting... but they render in deferred. you would have to skip this in case you would go with double sided geometry.
     
  15. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Do you have any time at all that you can think of this would be done? I loved your asset and am looking forward to its update!
     
  16. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    They have only single sided leaves!? The ones advertised have pretty high tri counts.
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes: single sided geometry only.
    that is why speed trees may look pretty weird if there are no real time shadows: just try it out.
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you would have to have your own speed trees with double sided geometry...
     
  19. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Whut? o_O
     
  20. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    They look pretty bad cause the tranlucency on leaves. Take a look on this comparison of the same speedtree model in UE4 (using translucency) and unity 4:

    UNITY 5:
    speedtree1.jpg

    UE4:
    speedtree2.jpg

    Im still tweaking lighting and materials to match the results (bloom etc...). But as you can see, there is huge difference in the natural look of the leaves.

    And its not only that, the shader optimization its poor compared to AFS, and if I could use AFS in unity 5 to compare im pretty sure your shader will look much more natural.
     
  21. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    I wonder if the reflection at the wall, the blooming effect of the sky and the realistic colors in UE4 would be achieved in Unity 5!
     
  22. Deleted User

    Deleted User

    Guest

    I'm sticking with Unity 4.x, and I'm interested in buying AFS in the near future.
     
    x_african_warrior_x likes this.
  23. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Seems like I was able to duplicate that issue in Unity 5 by not having a normal texture assigned to the leaves.
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,
    you have to edit the combined diffuse texture and set the alpha to white on the parts covered by the bark texture.
    lars
     
  25. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    I dont know what do u mean, im using the same normal maps (with Y inverted) as UE4.
     
  26. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Ofc you can, the problem is more about the artist and knowedge than the engine (and UE4 developers have very good artist comunity).

    I'm still tweaking it but here it is:
    Lightroom1.jpg
    The secret about the wall reflections/specular is enabling "Directional Specular" in directional mode of the GI setings.
    Now i need a refraction shader compatible with geometry normals to match the pots, some more bloom tweaking and ofc, color tweaking.

    But yes, you can do it.

    One more thing, Unity its using full realtime GI, I can change lightning in runtime. UE4 demo its using baked lighting (can use realtime GI, but doesnt look that good).
     
    Last edited: Mar 6, 2015
    x_african_warrior_x likes this.
  27. x_african_warrior_x

    x_african_warrior_x

    Joined:
    Jun 24, 2014
    Posts:
    80
    i did that, in photoshop went to channels, added alpha then painted the side where the bark resides to white(lefthalf), or am i doing it wrong... Untitled-1.jpg
     
  28. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    That is absolutely incredible! Would you mind telling me what effects you use and lightning settings? :) That looks absolutely amazing, keep it up!
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i think that photoshop can not handle png created by unity – at least not if they contain an alpha channel.
    so usually i open the pngs in graphic converter, cut the alpha and add it later in photoshop.
     
  30. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @larsbertram1, I might of missed it somewhere..

    But is there any estimate to when the touch bending will work with Unity5?
    I'm really looking forward to this. I don't currently own this asset, so I am also wondering if it will see a price increase?
     
  31. larsbertram1

    larsbertram1

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

    upcoming update for unity 5 is shaping up.
    so here is the what i might think the change log might look like.

    please comment on it—especially on the features that will most likely be skipped in the next update.

    Grass Shaders
    - Improved bending now following the given wind direction.
    - Possibility to add approximated translucency. More to come in future versions i guess.
    - Legacy vertex lit has been skipped for the moment. It might follow in upcoming updates.

    Foliage Shaders
    - Custom pbs and image based lighting removed. Shaders now use unity’s new pbs lighting, reflection probes, ambient lighting and GI.
    - Removed a lot of different shader variants: Now almost one size fits all. The shaders might be a tiny bit more expensive but they are much more flexible and easier to use.
    - Improved bending: Wind animation has moved from the setup script to the shaders which makes it a bit more expensive but will give you much more variety.
    - Secondary and primary bending now can by controlled separately using UV4. Legacy bending is still supported (and needed if you want to place foliage using the terrain engine).
    - Ground lighting hasn’t yet made it to unity 5. It might follow in upcoming updates. But it might also be skipped.
    - Legacy vertex lit has been skipped for the moment. It might follow in upcoming updates.

    Tree Shaders
    - Improved bending giving you less distortion and some more variety.
    - Simple tree shaders have been skipped as they simply are not needed any more. You still got the possibility to simplify or merge trees created with the tree creator though. You even can convert those to be compatible with the foliage shaders without having to tweak anything—using UV4.

    Billboards
    - Support for all ambient lighting modes: skybox, gradient and color.
    - All fancy shadow features had to be removed—as unity 5 handles shadow casters completely different from version 4. I am really sorry about this but i could see no other way.
    And bugs in the terrain engine concerning real time shadows made it easy for me to take this decision: Shadows do not get culled/drawn correctly right now so adding shadows casted by billboards are more or less worthless.

    Touch bending
    - Scripts and shaders updated.

    Combine Children script
    - Updated to support Unity 5.
    - Updated to support UV4.

    Set up Foliage Shader script
    - Updated to support Unity 5.
    - Improved bending: Bending has moved from the setup script to the shaders which makes it a bit more expensive but will give you much more variety.

    Foliage tool script
    - Updated to support Unity 5.
    - Updated to support baking bending into UV4.
    - Let’s you convert tree creator trees into (new) simple trees (only one material) or to meshes compatible with the foliage shaders (supporting vertex colors and vertex colors and UV4).

    Reposition trees script
    - Updated to support Unity 5.

    Shaded billboards script
    - They theoretically work, but i have skipped the script for this version.

    that is it for now.
    looking forward to read your comments,

    lars
     
  32. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Sounds amazing, can't wait!
    Is there any approximated time that it might be available at? :)
     
  33. adventurefan

    adventurefan

    Joined:
    Jan 17, 2014
    Posts:
    230
    Part of the problem can also be Unity's default color balance is pretty washed out, especially compared to Unreal.

    Adding a simple contrast/brightness/saturation script to the camera and tweaking that can be a huge help if you want to bring out the beauty of scenes.
     
  34. x_african_warrior_x

    x_african_warrior_x

    Joined:
    Jun 24, 2014
    Posts:
    80
    wow, major overhaul.

    i havent even got unity 5. ok, looking forward. i think everyone will be looking to convert current unity trees to afs trees to reduce drawcalls after merge.

    1) so please is there a way you could make the process seamless... that is,(can u put a checkbox) to force the alpha channel of bark to be painted white since most are 50%bark,50%leaves. that way we dont have to download other software other than PS to do it.

    2)is there a way you could incorporate texture atlases(so as you could use one material for many trees). i know am asking a lot here as it would require UV recalculation etc,.... i just think if this would complement the package well since you're not tied down to fancy lighting stuff anymore,
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    already in.
    this does not make sense for trees (one tree = at least one material = at least on single draw call).
    and it is a bit over the top for the foliage shaders... so not for the moment.
     
  36. HaBe

    HaBe

    Joined:
    May 29, 2014
    Posts:
    31
    Great read, looking forward to the release. I'm upgrading my project to U5 atm, and was just checking if I can keep the nice AFS features. I'm especially happy about the wind bending, does it support spherical zones as well out of the box?

    Also grerat to hear that you've switched to the standard lighting path, can't wait to try out realtime GI on grass. :D
    Should make asset setup much easier that way as well.

    I'd happily donate 10€ as voluntary upgrade fee, if you prefer bank transfer, pls PM me the details (living in Germany as well, so not a problem)
     
    MarcusWatson likes this.
  37. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    Very interested in the U5 version, will definately get it once it's out!
     
  38. seansteezy

    seansteezy

    Joined:
    Nov 28, 2013
    Posts:
    122
    I feel bad for you man, you have this amazing working system in Unity 4 and then boom, they drop the 5, change the way everything works, breaks your stuff, and now you gotta do a ton of work to update it and you can't get any extra money from your current u4 to u5 customers.... I'm one of those that will generously donate for an upgrade. I never got a chance to use in Unity 4, but I am very much looking forward to the update to see what this shader package can do :)

    Thanks for your hard work Lars!
     
  39. Axiomatic

    Axiomatic

    Joined:
    Feb 7, 2014
    Posts:
    30
    Yes, thanks! Update sounds amazing!
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,
    just a short update on the current status of the upcoming version:
    most features are implemented, have been tested on opengl, dx9 and dx11. so now i have to clean up the code and update the docs.

    Anyway—here is a first preview on the improved grass shaders:

     
  41. Axiomatic

    Axiomatic

    Joined:
    Feb 7, 2014
    Posts:
    30
    Thanks Lars, looking really good.
     
  42. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    Simply amazing looking.
     
  43. Coltrain

    Coltrain

    Joined:
    Mar 4, 2015
    Posts:
    8
    Really wonderful stuff. Will purchase as soon as it's available. There's been some discussion about compatibility with SpeedTree above, and I'm a little confused about the potential. There's some talk about single sided leaves, can you clarify, is it possible to output trees from the SpeedTree editor with double sided polys that could swap in the next version of AFS for the leaves or fronds?
     
    Last edited: Mar 17, 2015
  44. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    The most interesting part in your asset are the tree and grass shaders. The billboards for Trees mostly looking strange and you see billboard activation flip mostly. I never used this because it looks too ugly to me. And it doesn't work fov changes anyway.

    1) A very great and required feature would be drawing your grass on meshes (as on terrain in unity)
    Drawing with a brush procedural on any objects align the steepness by percentage.

    2) A script that have the ability to create procedural grass on a predefined single texture, mesh or GO automatically. Because grass is nearly everywhere. It doesn't matter if you have a landscape or city scene. Especially in a city scene you have a lot grass (but smaller) parts, and it's impossible to place each grass object manually.

    The easiest and best work-flow should be script is attached to a GO and where you paste all the meshes into that should have procedural grass on.

    The mesh can be culled and and be transparent. Further it should be possible to attach any objects to by script, think about stoned rocky river side.. etc.

    What do you think?

    sceneU505.jpg
     
    Eric2241 likes this.
  45. adventurefan

    adventurefan

    Joined:
    Jan 17, 2014
    Posts:
    230
    Looking good.

    A question about your unity 5 tree shader... I assume your tree shader supports normal, diffuse, and specular/roughness map... but will it have an occlusion map slot too? Because occlusion I can get pretty easily from doing the other stuff and it would be a shame to not use it.
     
  46. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    224
    I have been prototyping my own tree/foliage engine this week, and I was adding batchers for AFS. When I load a chunk in with trees tagged as static (e.g.. your touchbending ferns), I use StaticBatchingUtility.Combine to combine them dynamically. However, neither the static version nor the dynamic version of that prefab reacts correctly to touch (it springs way up in the air) when statically combined. I would have though using this utility method was no different than just dropping the static objects in the scene at design time. I could of course just load them in as game objects, and they work fine, but I'd prefer to batch them if possible.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    @DirtyHippy:
    that sounds like a pretty common global versus local space problem. touch bending shaders and scripts support both, so you will have to find out which one fits in your given case. please have a look at the docs.

    but what is about your chunk based vegetation engine? i am very interested in getting to know more about this.

    @adventurefan:
    sorry, but it is not "my" unity 5 tree shader—but a modified and enhanced version of the built in tree creator shader. it already support ambient occlusion (baked into vertex color alpha). however this is multiplied on top of the albedo so it darkens certain parts of your tree. but it does not occlude ambient diffuse or specular lighting like the new standard shader does.
    only the foliage shader supports "correct" ambient occlusion.

    @quantum1000:
    this is already supported since version 2.0 if i remember correctly.
    and using the free geometry brush makes it pretty easy to distribute all your grass.

    when it comes to a script doing all this procedurally: that is not on my list right now, as it would be either very special or very complicated, sorry.

    lars
     
  48. Axiomatic

    Axiomatic

    Joined:
    Feb 7, 2014
    Posts:
    30
    Hi Lars, just curious if the new afs will come out this week or not? This is not to pressure you in any way, just asking becuase we have a game update going out this week and depending on timing of the new afs we might delay to incorporate it. Thanks again.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i do not think so. i do not have time to work on it this week. and you must not forget the toimes it takkes to be approved. 2 – 3 weeks might be possible.
     
  50. Axiomatic

    Axiomatic

    Joined:
    Feb 7, 2014
    Posts:
    30
    Ok, makes total sense, thank you!