Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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,911
    hi there,

    thanks a lot for your post.

    in fact a was already thinking about some video tutorials. but the package is progressing so fast at the moment that probably any video tutorial would be quite outdated just the moment it is finished… :
    i introduced touch bending at the end of july.
    august first brought slope aware lighting, advanced grass shaders and the customized geometry brush. later i published a new version of the foliage tool and did major improvements to the combine children afs script.
    october was time to make all shaders work with unity 4.2 properly and take the new shadow caster / shadow receiver batching into account.
    not to mention the tree and billboard shaders and scripts.

    so you might imagine how much time it takes to just keep the docs in sync.
    or to create little demos and test all features as there ate so many by now.

    but i hope the demos shipping with the package give you some good examples of how to use the shaders or scripts.

    nevertheless, if you have any specific question donnot hesitate to ask it.
    and i will look if i find the time to make some video tutorials.

    lars.
     
  2. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Lars keep up your great work, one suggestion maybe if i can make. Have you been thinking of adjusting shader that way for grass on terrains so that it reads underlaying splat map hue color or pixel hue color and matches it more for grass, this will blend grass and splat better. Also i havent been checking yet but are your shaders (vegetation especially) working with RTP v3 terrain pack from Tom?
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi janpec,

    thank you for that.

    that might be a nice feature but we do not have access to the detail meshes created by the terrain engine. so i can’t bake any extra information to those like the color of the underlying terrain.
    nevertheless i find it pretty easy to make both match by using a more or less greyscale grass texture and picking "dry" and "healthy" color directly from the terrain textures.
    both work together perfectly. in fact i have been helping out tom and peter on the upcoming rtp3 demo scene and when it is finished it will show some of the vegetation features shipping with the advanced foliage shader package.

    lars
     
    Last edited: Nov 16, 2013
  4. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Thank you very much for taking into consideration my request, I understand that now is not possible. Thank you for your quick response ^ ^.
     
  5. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I'm having some problems. I do not know how to replace the color channels in gimp. Also Is there a difference between pro and indie touch. Besides the fact that one is for Unity Pro and the other for Indie.

    Also with vertex painting in Blender it only paints one side of the leaf plane. For some reason it leaves the other side white.
     
    Last edited: Nov 10, 2013
  6. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Ah great.
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    which color channels do you mean? those for the combined atlas?
    well, i use photoshop, but as color channels are pretty basic to any kind of image editing i am sure that gimp will have a channel palette, from which you can chose the color channel you want to work with. then it is a simple copy/paste thing.

    there is no difference featurewise. but some demo scene uses static batching which will speed up rendering in some cases but is only available in pro.
    touch bending e.g. works with and without static batching but needs special scripts to handle both cases.

    sorry but i am not a blender artist. but may be you will get help on a blender forum.

    lars
     
  8. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I see the channels in gimp but as far as I know it doesn't let you move a channel from one image to another.

    Thanks for answering. Also thanks for making this pack. Makes the scene come alive.
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    you are welcome.
    and as far as the layers are concerned: in photoshop i would just turn off but one color channel, select all, then copy.
    turn on the destination color channel and paste...

    lars
     
  10. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
    are billboards normal mapped?
     
  11. malikcgcs

    malikcgcs

    Joined:
    Jun 11, 2013
    Posts:
    26


    please help we need tessellation in terrain or system grass like your system can apply in any mech (on an object without terrain ).
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi blueivy,

    billboards are not normal mapped as they are still based on unity’s built in billboarding system.
    so billboards are pre-lightened textures mapped on a quad completely unlit when rendered to screen which makes them extremely fast to render.
    what the advanced billboard shader do: they allow you to tweak the rendered billboard texture to make it fit better with the mesh tree representation and – even more important at least to myself – they add perspectively correct projection. so combined with the advanced tree shaders you will get very, very smooth transitions between billboards and mesh trees allowing you to lower the billboard distance which will help you to save up to several hundreds of draw calls.
    finally the "shaded billboard" script allows you to make billboards get "shaded" by real time lighting.

    lars
     
  13. larsbertram1

    larsbertram1

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

    i doubt that tessellation on grass meshes will give you any visual impact as you will mainly deal with simple quads…
    so may be you mean LODs… and that is something that can already be done using the advanced grass shaders and creating different LODs for your patches.

    lars
     
  14. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Hi larsbertram, i was thinking about picking this up as well as the afs package, but it seems a bit unnecessary to get both the shaders because i guess this one is superior to the one that comes with the afs? Any chance you could release just the plants from afs as a separate package or something?
    Also, whats the polycount for the plants in the afs package?
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi virror,

    the foliage package ships with version 2.02 of the shaders whereas the shaders themselves are currently at version 2.041.
    polycount is between 100 and 400 tris.

    it really trapped me to built this package, making it depend on the advanced foliage shader and then picking up the work at the shaders again…
    i am not very happy about the current situation. but i guess that the foliage package will not be updated as far as the shaders are concerned. it is in a stable version right now – however it does not offer all features of the advanced foliage shader package. and this gap will become wider.

    lars
     
  16. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Ok, thanx for the info, im really just interested in the plants from the other package and the shader from this one, but luckily you are cheap so i can afford both of them even though i get some extra shaders : )
     
  17. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
  18. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
    also have you taken a look at how crytek did the mass simulation of grass in crysis 3? its in the poweroint all the way at the bottom called the rendering technologies of crysis 3 http://www.crytek.com/cryengine/presentations
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    best choice!
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    thaht is nothing i have to add to the shader!
    you can simply apply a linear gradient on top of your grass texture.
    that is much cheaper as it is no extra work for the shader and much more flexible.

    lars
     
  21. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
    and is the occlusion on the grass already possible?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    they do software-skinning and "rope like physics" – that might be something for the future.
    right now the method used by the advanced foliage shader package has only a minimal impact on the cpu and should be (much) faster, but also more inaccurate…: no physics simulation, no skinning, no dynamic mesh generation/combination… but of course: very interesting.

    lars
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    yes, like i have written: simply add a gradient to the grass texture.
    doing this in the shader would make sense if the ambent occlusion would change e.g. over distance.
    otherwise it is cheaper to just bake it.

    lars
     
  24. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
  26. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    sorry, but that is NO grass – at least not as it is defined by unity terms.
    the "grass" in your animated gif consists of mesh modeled blades.
    and for this reason this is easy to achieve using the afs package.
    so if you do not have it already: go and get it.

    lars
     
  28. larsbertram1

    larsbertram1

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

    right now i am pretty confident that billboards casting real time shadows will make their way to the next release.
    they look pretty stable and as good as one can expect from a billboard texture. really huge broadleaf trees are a problem and will probably ever be but on other trees like spruces those work rather well:


    $billboard_shadows.jpg

    lars
     
    Last edited: Nov 12, 2013
  29. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Thats a huge improvement : )
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi virror,

    thanks for the comment!
    i will tweak it a little further (i will have to rewrite the billboard/mesh blending functions) and publish a webplayer.

    lars
     
  31. larsbertram1

    larsbertram1

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

    here we go: billboards casting real time shadows.
    it is not perfect i have to admit: shadows of very wide trees (like the oak trees) do not look very well and also trees which have a very special shape (like the "dead trees") are not very convincing – but for rather symmetrical trees (spruces) viewed from a moderate perspective (first person) this might be interesting:
    https://dl.dropboxusercontent.com/u...treeShader04_fly/afs_v2_treeShader04_fly.html

    lars
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    not to forget:
    next to billboards casting real time shadows the webplayer also shows "terrain trees" positioned on top and below of manually placed geometry…
     
  33. larsbertram1

    larsbertram1

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

    i can not resist to show you what one might do using the advanced foliage shaders.
    so here is a trailer from the upcoming title "the forest" which shows some use of the shaders.
    (as far as i know practically all foliage uses one shader of the afs package).

    i hope you like it!

    lars

     
    Last edited: Nov 12, 2013
  34. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    They made such a great looking environment, it's very admirable. Your shaders are awesome Lars!

    When I saw the construction of the wall...I was like... :(

    I'm using something similar:

    $buildingwalls.jpg

    I may have to change it up, just so it doesn't look to similar. Granted, theirs is transparent.
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi jc,

    i really do not know what you are talking about ;-) walls made of lumber?
    they always look the same - and even if the color to highlight them might be the same: unity just gives you a hand full of colors…
    so i would not worry at all!

    and yes: they did a great job!

    lars
     
  36. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Wow. I've been following this game but haven't seen the new trailer. Thanks for posting it. That is Next Gen stuff.
     
  37. URGr8

    URGr8

    Joined:
    Sep 10, 2012
    Posts:
    25
    Hi Lars, I sent you an email, but not sure if you saw it or not, so I will post here.

    I am having a problem with the overall lighting on my trees using your ATS Foliage Shader v.2.041. I have gone in and customized the vertex colors so they animate really nicely when I hit play. However, when I make the lightmap so the trees will show up, the trees have this odd light-to-dark gradient going from the top to the bottom.

    I am using maya to edit my models, and I have followed your instructions to bake the lightmap information into the vertices alpha.
    Attached are some pictures so you can see what is happening.

    Do you know what could be wrong with this or the way the models are done?

    Thanks

    Here are some example pictures of what is going on.
    $Tree1.jpg $Tree3.jpg
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    i haven’t seen it, sorry.

    with "lightmap" you mean ambient occlusion ;-)
    and it really looks odd in your pictures: just like a linear gradient.
    so i doubt that the alpha channel contains the right information. may be something gets switched...

    i don’t know how you bake ambient occlusion in maya into vertex.color.alpha. but one way to do so would be to create a 2nd color set, bake ambient occlusion to that, then copy the information to the alpha channel of the first color set using a mel script.
    just have a look here:
    http://www.polycount.com/forum/showthread.php?t=117868

    please let me know if this works for you.
    and it would be great to see a short video or webplayer of your tree bending in the wind!

    lars
     
  39. larsbertram1

    larsbertram1

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

    i have just made a little update to the "billboards casting shadows" demo and added some more trees in order to let you see which kind of trees might work and which one might not:

    https://dl.dropboxusercontent.com/u...treeShader04_fly/afs_v2_treeShader04_fly.html

    new are the birches and the palms.
    please note: palm have a pretty huge bending factor applied so you will clearly see, how the bending is faded in during the transition from billboard to mesh.

    lars


    $billboardsCastingShadows.jpg
     
  40. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Definitely the smoothest transition between full and billboard I've seen.

    :)
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    thanks!
     
  42. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Hi Lars,

    Great shader, very happy with how it makes my plants animate. However, I'd like to have my plants self illuminated rather than lit by directional light.

    How can I do this with your shader?
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi feracon,

    thank you.
    but in order to get self illuminated plants you will have to edit at least ONE shader and add "o.Emission" to the surf function and feed it with probably a texture sample.
    you must not use "TreeLeaf" lighting function but write your own – or just use one of the built in ones (mostly BlinnPhong" i would guess).

    lars
     
  44. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Sounds a little over my head. Thanks Lars.
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    can you post some screenshoots of what you have now (landscapes, scenes) and what you want to achieve?
    may be we can figure something out…
     
  46. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    @URGr8 Your problem with lighting are simply normals (faces). Adjust your normals to all be pointing upwards into sky in your modeling software. If you are using 3ds max simply add Normals modifier and youll see what to do.


    Lars do you know if those guys from The forest use Global illumination or soemthing, becouse it all looks so well let i dont think its all vegeation shaders work.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi janpec,

    ben told me that they have added some ibl but i am not sure if this also applies to the advanced foliage shaders:
    usually ibl raises contrast. nice but that is something that negates the "wrapped around diffuse" lighting which is used for the leafs as it is the goal to make lighting smooth (there are people who even suggest to "flatten" the normals).

    but i am still testing different approaches on how to improve the lighting on foliage.
    right know i think ibl is more for just the bark, not the leafs – at least not if you have rather huge and only a "few" leaf planes.

    $lighting.jpg

    lars
     
  48. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    The directional lights in my scene were causing a flower texture to be blown out bright. I've realized it's the "Shininess".

    When I turn shininess all the way up the problem is not as bad. I'd like to get rid of this all together though. If I view from right right angle I can still see this hot spot.

    $Untitled-2.jpg
     
  49. larsbertram1

    larsbertram1

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

    you have to edit your gloss map too.

    but to be honest: i think using the foliage shader on a more or less "flat" or slightly curved plane is a bit of a waste…
    using the advanced grass shader would be much more suitable for such a simple geometry that does simply not allow "real" lighting.
    or you might think about reworking the mesh: give it a real shape, a real blossom, some real leaves – just like the "nettle" from the package.

    lars
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    p.s. and do not waste so much fill rate, that is deadly! have a look at the upper right corner: quads which are simply empty.
    reworking the geometry, giving it a real shape and adding 8 – 12 single flowers and combining them will give you a higher poly count but rendering might be as fast as using a curved plane as it would safe a lot of fillrate.
    and bending will just look awesome.

    lars