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:
    5,430
    it is always 1 image per tree prefab at a given time showing the tree from an averaged viewing angle according to the main camera’s orientation. the billboard image will be updated when the camera rotates.
    we can not influence the render camera that generates the billboard texture. all we can do is to manipulate how the billboard is rendered on screen: usually as a simply screen aligned quad – which the afs billboard shader squeezes if "align to camera" is activated.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    thanks for the info.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    hi there,

    now i have been able to reproduce the grass problem on dx11.
    and i am pretty sure that i have solved it. the patch will come with the next update.

    meanwhile you could fix it manually:
    - open: AfsWavingGrass.cginc
    - replace: CBUFFER_START(UnityTerrain)
    with: CBUFFER_START(AfsGrass)
    - reimport both grass shaders

    i hope this will fix the problems. feedback is welcome.

    lars
     
  4. ThunderTruck

    ThunderTruck

    Joined:
    Sep 25, 2013
    Posts:
    61
    Thanks,

    solved for me...
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    fine.
    anybody else?
     
  6. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    110
    This worked for me also. Thanks for the quick solution, Lars!
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    you are welcome.
    and thanks for your patience.
     
  8. seansteezy

    seansteezy

    Joined:
    Nov 28, 2013
    Posts:
    115
    Hey Lars, You gotta link where we can donate some $ for your updating efforts?
     
  9. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    755
    Mesh with asf grass material stays black

    Untitled-1.jpg

    Hi,

    I'f created a new quad and the v.4 grass material on it. Placed it into afs /prefab then into the Manually placed Grass - Cluster GO. Setup the new quad mesh in the same way as the your default grass mesh (including mesh filter [my mesh] and removed collider). Then pressed play. The new quad is combined with the your meshes well.

    The new grass quad stays black and didn't weave while your grass works well.
    All other meshes I attached to the mesh filed didn't work. Is there any thing special to your grass mesh?

    Thanks
     
  10. Axiomatic

    Axiomatic

    Joined:
    Feb 7, 2014
    Posts:
    30
    Seconded.
     
    seansteezy likes this.
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    i have not... but if you want to donate and support the ongoing development you could buy one of my other packages from the asset store :)
     
    seansteezy likes this.
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    i guess your mesh does not have proper vertex colors... rgb set to 1.0, alpha stores max bending value.
    you may simple rename it and let the AfsGrassModel Postprocessor do the rest.
    a file named:
    „MyTallGrass_AfsGM05_test.fbx“ would be processed using a max alpha value of 0.5.
    a file named:
    „MySuperfern_AfsGM03Testnew.fbx“ would be processed using a max alpha value of 0.3.

    let me know if this helps.
    lars
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,332
    Not sure if anyone has posted this problem yet but when I use SSAO I get this effect:


    When the camera is rendering Depth Normal this happens. Using AFS tree creator optimized shaders. Like blue ghost leaves bending separately from the tree. It does this in any render mode. Although in Forward it looks more like a shadow than a baby blue effect. This is happening with the bark too. That dark and line you see on the trees trunk.
     
  14. astrand130

    astrand130

    Joined:
    Nov 9, 2014
    Posts:
    21
    I already posted a report of that... it's supposed to be fixed in an upcoming release.
     
  15. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,332
    Oh okay. Cool. I thought it was posted already but for some reason could not find it. Thanks
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    i has been fixed and we be available with the next release.
    lars
     
  17. Project-Mysh

    Project-Mysh

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

    Have you noticed that the Mesh Brush tool its not working with LOD prefabs? Its sarching a Mesh renderer on the LOD group.
     
  18. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,332
    Thank you Lars.

    I did not have pro LOD in Unity 4 but the LOD system I did use did not work either. So I added a disabled mesh renderer to the LOD prefab. The only problem I had with this was that you cannot erase the placed objects with the brush.
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    well, it is a free tool…
     
    ThunderTruck likes this.
  20. PutridPleasure

    PutridPleasure

    Joined:
    Mar 3, 2015
    Posts:
    11
    This isn't an issue that exists because of AFS, but I was hoping it would somehow solve it, anyway maybe someone can tell me how to solve this:



    The grass has this unpleasant shininess when using Deferred & LinearLighting, which I'm trying to get rid off, any thoughts?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    that is caused by unity’s new physically based shading: grass gets specular highlights due to the fact that its normals are aligned to the ground.
    so talking about your first screen shoot: grass is lit as if it would be a rather flat surface which means that the angle between viewing direction and normal is very high.
    and due to the laws of physics it get specular reflections (fresnel): everything gets shiny at grazing angles.

    so unless you hack the internal deferred lighting pass there is no way to get around this, sorry.
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    p.s.: using "approx transluceny" somehow works against this making it more believable i think.
     
  23. vishalid100

    vishalid100

    Joined:
    Apr 1, 2015
    Posts:
    2
    hi ........ I am new to this and just wanted a video tutorial from scratcho_O...
     
  24. PutridPleasure

    PutridPleasure

    Joined:
    Mar 3, 2015
    Posts:
    11
    Using the Translucency Approximation did help a bit, thanks for that hit!

    So if I want to get rid of it completely my only realistic option would be to just not use terrain details for vertical grass and use GO's instead? I wouldn't even know what file to look into to turn off specularity for terrain details completely
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    the afs grass shader also uses the underlaying ground's normal. thta is simply how grass lighting should work.
    so using go’s will give you:
    a) very harsh lighting if they do not use the underlaying ground's normal. grass will pretty much stand out on slopes and lighting will pretty much depend on the viewing angle. i would say will look even worse.
    b) if you use go’s and the afs grass shader you will get pretty much the same specular highlights.

    so the only solution i can think f is hacking the lighting function. i have tested some other brdfs which looked a bit better, but did not solve the problem entirely. one would have to go even further using stencil buffers for example…

    sound complicated? it is complicated...
    sorry,

    lars
     
    seansteezy likes this.
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    me too.
     
    OnePxl likes this.
  27. gergsadas

    gergsadas

    Joined:
    Jun 13, 2014
    Posts:
    4
    just bought the pack and having some problems, for some reason the grass isnt showing up at all if i just paint it onto the terrain, after some experimenting with the demo scene ive found that you have to be within a certain range a a tree made with the tree creator for any of the grass shaders to work, any fix for this?, if i remove all trees from teh terrain the grass just dissappears

    PS : more specifically it happens when the tree reaches its billboard distance

    PS PS : my apologies i did not read properly, the fix posted further up on this page works fine
     
    Last edited: Apr 3, 2015
  28. seansteezy

    seansteezy

    Joined:
    Nov 28, 2013
    Posts:
    115
    Will do!!!
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    enjoy!
     
  30. vishalid100

    vishalid100

    Joined:
    Apr 1, 2015
    Posts:
    2
    i just bought AFS v4 for unity 5 and want to place tree on non terrain objects.. please help me out on this topic....
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    read:
    04 Tree and Billboard Shaders.rtf -->
    5. Repositioned terrain trees
     
  32. PutridPleasure

    PutridPleasure

    Joined:
    Mar 3, 2015
    Posts:
    11
    I found a really easy solution that takes away only the stupid specularity but leaves all the rest, have you not considered it for a specific reason?

    Solution:
    In the AFS Grass Shader Terrain V.4 change "Queue" = "Geometry+200" to "Queue" = "Geometry+600" and it looks great.

    Edit: Nevermind, it also ignores Shadows casted on it
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    well, that would make the grass being rendered in forward … instead of deferred.
    and it would force unity to even sort the grass... :-(
    from unity docs:
    (http://docs.unity3d.com/Manual/SL-SubshaderTags.html)
    Queues up to 2500 (“Geometry+500”) are consided “opaque” and optimize the drawing order of the objects for best performance. Higher rendering queues are considered for “transparent objects” and sort objects by distance, starting rendering from the furthest ones and ending with the closest ones. Skyboxes are drawn in between all opaque and all transparent objects.
     
  34. seansteezy

    seansteezy

    Joined:
    Nov 28, 2013
    Posts:
    115
    Hey Lars, sorry to keep bugging you, I see you got lots of nice trees, have you thought about a mega pack, combining some of those birch/beech/pine/spruce into like one big package (with a nice big pricetag)? I'd be happy to purchase something like that since I will be needing lots of nature in my upcoming project :)

    Oh an all the trees you make, I am assuming they all play nice with AFS v4?
     
  35. ThomQ

    ThomQ

    Joined:
    Nov 23, 2010
    Posts:
    303
    I 'll be getting AFS 4 later tonight, just wanted to say great job on all the work, and also for you other shaders. Been using them for years :)
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    thank you very much!
     
  37. airblaster

    airblaster

    Joined:
    Oct 5, 2014
    Posts:
    8
    Is it possible to create trees that can be jumped upon with AFS?
     
  38. astrand130

    astrand130

    Joined:
    Nov 9, 2014
    Posts:
    21
    If you are looking for something that allows for better terrain tree collision this might be what you are after:
    https://www.assetstore.unity3d.com/en/#!/content/21839
    You will probably need to modify it for use with the AFS tree re-positioning script but It should work with all other terrain instanced trees.
     
  39. ryno_coder

    ryno_coder

    Joined:
    Nov 5, 2012
    Posts:
    18
    Hello,

    I bought Advanced Foliage Shader v4, is it possible to get v3 if I send you my invoice number? I haven't made the switch to Unity 5 yet.
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    should not be a problem in unity 5 as you can add multiple colliders. in unity 4 only on objects not placed within the terrain engine.
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    yes. please send me your invoice no. and contact data as pm.
     
  42. ryno_coder

    ryno_coder

    Joined:
    Nov 5, 2012
    Posts:
    18
    OK, thanks for your help. I sent you my info.
     
  43. wheels

    wheels

    Joined:
    Jan 20, 2013
    Posts:
    29
    Hey Lars, congrats on the v4 release. curious, will you support a speedtree version of your shader that may add some of the benefits of your system such as transluecency, specular, raindrops, and draw call optimization benefits on speedtree models while allowing for speedtree wind, collison, and ao? i think it could be great in a future version and would give speedtree users a reason to buy your system.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    hi wheels,
    thank you. well, i will have a look into the speedtree shaders sometime.
    but when it comes to draw call optimizations: forget about speedtree wind. that most likely will not work: just have a look at the huge amount od data taht is passed – per tree!
     
  45. Coltrain

    Coltrain

    Joined:
    Mar 4, 2015
    Posts:
    6
    Hi Lars,

    Really enjoying the new v4. I wanted to second the call for speedtree support as well. Their modeler is so convenient and has some features that are difficult in the unity tree creator like roots, etc. Do you have any other tree modelers that you recommend if users are interested in doing something more complex than is possible with the Unity tree creator? I'm coming from a 3DS Max pipeline mostly.
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    Baldinoboy likes this.
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    hi there,
    i have just uploaded the fix for the depth normal shader/ssao.
    i hope it will be available within the next days.
    cheers,
    lars
     
    seansteezy likes this.
  48. kaamos

    kaamos

    Joined:
    Aug 6, 2013
    Posts:
    48
    Hi, I'm having some frustrations with the billboards for the optimized AFS shaders. They're fully black, even when using the stock tree meshes you provided with the package. AFS setup is correct as far as I can see (I went as far as to even copy the one from the tree demo and of course customize it for my own scene). I should point out that the billboards are correctly lit in all your demos. I'm using forward lighting, DX9, gamma color space, terrain composer, relief terrain pack and real time lighting only, unity 5.
     
    Last edited: Apr 10, 2015
  49. Project-Mysh

    Project-Mysh

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

    If I edit your "Foliage Shader V4" and disable cull ("Cull off") to use it with singlesided geometry as your defferred version, what problems could I have?

    Thanks in advance for your response.
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,430
    terrain composer most likely causes the problem as it writes "wrong" tree colors.
    try to get rid of that by editing the "AfsBillboardTree v4.shader"
    find line:
    o.color.rgb *= lerp( ( _AfsAmbientBillboardLight.rgb ), fixed3(1,1,1), v.color.a );
    and comment it.

    does that help?
     
    kaamos likes this.
unityunity