Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    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:
    5,318
    try it...
     
  2. kaamos

    kaamos

    Joined:
    Aug 6, 2013
    Posts:
    48
    You are officially my favorite person of the day. Thanks so much, it works perfectly now :) Enjoy your weekend!
     
  3. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,319
    I noticed when playing with image effects that the adaptive tonemapping has issues with the afs tree creator shader. When walking up to a tree the screen will go completely black and not recover as if it was exposed to crazy high brightness. Not sure if it is something wrong with my textures or the afs shaders but it does not do this with the normal tree creator shaders.

    Thanks
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    i can not confirm this.
    some more info please.. ;-)
     
  5. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,319
    Not sure what details to give. I can throw a quick webplayer or video to show the problem. The only other time I have experienced this was when there was something wrong with one of the trees normal textures. Had crazy strong specular showing incorrectly and it would make the screen go completely black. The normals seem to be fine though. No specular problems. Will get an example together.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    that would be great!
     
  7. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,319
    Forgot to check. It only does this in DX11 mode. Will get the scene here in a minute if my internet allows.
     
  8. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,319
    Here is a webplayer: Tone Mapping bug (28mb)

    As soon as you move up to the tree the screen will most likely black out. You can press "F" to disable tone mapping and go back to normal. Press again to see the problem again. This happens the worst with the Kapok(large) tree. The ivy root seems to set the problem off.
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    hi baldinoboy,
    i had a look at the webplayer: great tree!
    but i did not see anything weird apart from the shadows fading in a little bit late... but i am on os x -> open gl.
    anyway: as tone mapping simply takes the final rendered image i can not imagine how a shader would break it...
     
  10. ThunderTruck

    ThunderTruck

    Joined:
    Sep 25, 2013
    Posts:
    61
    hi baldinoboy,
    I had often this issue in DX11 with Tonemapping (unrelated to AFS). This happens to me when I use 'Adaptive Reinhard' with square texure size > 128
     
  11. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,319
    Thanks. I do not think it is directly AFS causing this but my textures. Just with AFS different specular my textures do this.

    When this happened I was using 256. Strange issue.

    I personally dislike the built in tone mapping techniques. There are some good tone mapping setups out there but no adaptive ones.

    Will play with the textures and update if I find the problem.
     
  12. AaronZurawski

    AaronZurawski

    Joined:
    Feb 21, 2013
    Posts:
    4
    This fixed the grass issue for us, thank you!
     
  13. Peter Pankras

    Peter Pankras

    Joined:
    Oct 31, 2013
    Posts:
    5
    I have this exact same problem. How can I fix this? I don;t fully understand what you did to get this working.
    Grass totally disappears at some angles.. really annoying.
     
  14. larsbertram1

    larsbertram1

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

    unfortunately you will ahve to edit the shader as described in the mentioned post – or wait until unity has approved the update which i have uploaded 5 days ago.
    i am sorry about the inconvenience but your problem should be fixed very soon.

    lars
     
  15. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    84
    I've had these same issues. The adaptive tonemaper is just broken in dx11 mode. I plan to write my own eventually but its in a long line of a billion other things at the moment.
     
  16. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    I just want to confirm that the touch bending is working well under Unity 5?
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    it works.
     
  18. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @larsbertram1, sweet! Thanks for the quick reply! A definite buy from me then!

    Curious about the performance of the touch bending feature. I know this depends on many things, but generally, how many objects with touch bending is it possible to have before running into serious performance problem?
    Is a few hundreds to 1 thousand out of the questions, or absolutely possible?
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    probably not – at least not out of the box.
    1000 game objects will kill performance, no matter if those use touch bending or not.
    you will have to use a pooling system or streaming solution i guess.

    lars
     
  20. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    Yeah, I juste realized my thousand number, actually doesn't make much sens.
    I suppose I would need around 200 to 400 max.
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    still: pooling or streaming would be recommended i guess: 400 game objects: that is simply a lot.
     
  22. Deleted User

    Deleted User

    Guest

    Hey Lars,
    I've recently bought your afs on the asset store and it is really great!
    Now I have only one problem. I want to convert a tree creator tree with the afs foliage tool into a flattened tree.
    After converting it the tree doesn't appear. Do you know why this happens? treeproblem.jpg
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    sorry, but i would need some more information...
     
  24. Deleted User

    Deleted User

    Guest

    I chose one tree creater tree and created a prefab of it. Then I applied your afs foliage tool on it, saved the mesh once and coverted it to a flattened tree, as you can see in the picture below. But after some calculation the tree disappears and I don't know why. Actually I followed all your instructions which are given in the documentation.
    Hope this helps more to solve my problem... treeproblem.jpg treeproblem2.jpg
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    5how does the generated mesh look like?
    you can preview it in the inspector or switch to shaded wireframe.
     
  26. Deleted User

    Deleted User

    Guest

    the first mesh that will be created when I press save mesh before I can convert the tree looks like this and the second one which will be created after I have pressed the convert button doesn't show the mesh.

    Unbenannt.jpg
     
    Last edited by a moderator: Apr 21, 2015
  27. yezzer

    yezzer

    Joined:
    Oct 30, 2009
    Posts:
    143
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    i am not working on any speedtree support right now, sorry.
    but of course you can always convert your speedtree models to afs: you would have to live with less enhanced wind animations but would get much better lighting... which i think counts more especially if it comes to ground covering plants like fern on which touch bending makes most sense.

    lars
     
  29. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    335
    I have the same issue! After pressing "convert tree" (both: simple tree and foliageshader) the tree disappears?!
    Using Unity 5.0.1f1 and AFS 4.0
     
  30. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    335
    Just wanted to note that using "afs align to camera" feature and set the "angle limit" to 90 helps a lot to reduce the issues with the oculus and billboard alignment! Thereby billboard alignment looks better and is less visible with the Oculus Rift!
     
  31. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,319
    For me Unity crashes and the tree disappears. It is easy to get the tree though. Just drag out the modified model that you saved and set the number of materials and apply them. Works for me.
     
  32. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    335
    Thanks Baldinoboy! Unfortunatly this does not work for me or I am doing something wrong?! Materials are already applied in my case, if I drag in the first saved mesh the tree is visible in wireframe at least...
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    hi there,
    i have to admit, that the script in the current package does not work (as i commented the needed lines – for what reason soever...). so either send me a pm with invoice number and email or wait until the next update.
    sorry for the inconvenience.
    lars
     
  34. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    60
    Does it work with SpeedTree?
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    it works along with speedtree.
    speedtree has its own format, its own shaders.
    but you could convert speedtree models to work with afs in case you would like to have touch bending.

    lars
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    hi there,
    the first patch now is officially available—solving the grass issue on dx11 and any problems related to the depth normal shader like built in ssao.

    lars
     
  37. Owen_Gusson

    Owen_Gusson

    Joined:
    May 26, 2014
    Posts:
    11
    Hi - I bought AFS a while back, and used it with no troubles. Now I am working a project and wish to use it again, but I can't get it to import. I get the following error:

    Error while importing package: Package has unknown format
    UnityEditor.AssetStoreContext:OpenPackage(String)

    I'm using Unity Pro 4.6.4f1 on Windows 7. I'm not having any problems importing any other assets. I tried re-downloading multiple times, importing from the asset store, importing manually.. nothing has worked yet! Has anyone seen this, or does anyone know what issue might be?

    Thanks!
     
  38. astrand130

    astrand130

    Joined:
    Nov 9, 2014
    Posts:
    21
    The most recent version of AFS is made for Unity 5. AFS 4 is not compattible with Unity 4. If you are using Unity 4 you might want to PRIVATELY contact lars with your invoice number and ask him about sending you the AFS 3 package.
     
  39. Owen_Gusson

    Owen_Gusson

    Joined:
    May 26, 2014
    Posts:
    11
    Ah, ok that explains it! I missed that somehow. Thank you very much for the info, I'll send him a private message.
     
  40. astrand130

    astrand130

    Joined:
    Nov 9, 2014
    Posts:
    21
    Hello,
    This video has been up for quite a while and I know you have been recently focused on your terrain shader. but do some more details or progress on the upcoming grass touch bending feature? I have been watching the thread but the video went up on your Youtube channel without any appearance on the forums.

    Grass Touch Bending:
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    no further details on this at the moment… sorry.
     
  42. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Where can I find video tutorials about how to apply these shaders to trees built inside Unity?
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    you will have to read the docs...
     
  44. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    124
    i just bought this and tring to find how to add trees too. tried to follow docs but cant seem to get it right. i got grass working but when i try to chance shaders for trees im not able to.
     
  45. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Yes, I think this should help:

    [see documentation '04 Tree and Billboard Shaders']
    - Create 2 new materials and using the "AfsTreeCreatorBarkOptimized" / "AfsTreeCreatorBarkDeferredOptimized" respectively the "AfsTreeCreatorLeavesOptimized" shader.
    - Find and assign the textures of your tree which are generated by the tree creator.
    - Find the prefab of your tree, click on the root node and replace "Optimized Bark Material" and "Optimized Leaves Material" with the new materials.
     
  46. artistpetemac

    artistpetemac

    Joined:
    Sep 8, 2014
    Posts:
    19
    Hi Lars,

    I'm using v4 in Unity 5.0.1. We've been having trouble with aliasing little white pixels in the tree branches when they are about 30 meters from the camera, (not the bill-boarded trees). I wonder if you have any suggestions for things to try?

    Also, in experimenting with different textures to try to eliminate these problems I discovered that your documentation is out of date. I reverse-engineered the texture generation script by writing labels like “shadow_alpha” into each channel of each of my source textures. I found some baffling things:

    A. In normal_specular.png, used in the optimized materials, the Red channel is a solid dark grey color. This does effect specularity, but it doesn't seem to come from any of the source textures used in the set-up materials. It also doesn't match the specular color defined in the setup material (which defaults to 50% grey), it's darker than that. Where does that color come from? Is it used as the specular value?

    B. In normal_specular.png, the blue channel gets the branch pixels from the alpha channel of the shadow texture of the setup material. Why? Is it used for anything? It does seem to be faintly visible in the branches.

    C. shadow.png appears to have it's RGB channels all taken from the alpha channel of the diffuse textures used in the setup materials. This is very baffling since there is a shadow texture input in the setup materials, but it only appears to effect the blue channel of the normal_specular.png, and doesn't contribute at all to the shadow.png.

    D. In translucency_gloss.png the Red and Green channels are black. Are they used for anything? I'm guessing no.​

    Any help or clarification would be greatly appreciated. I'm at a complete loss about how to eliminate these little white pixels.

    -Pete
     
  47. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    124
    Take Receive Shadows off and it should work.
     
    artistpetemac likes this.
  48. kilju

    kilju

    Joined:
    Nov 4, 2013
    Posts:
    124
    yea i got it working now but if i try to play with trees options it suddently changes shaders back to default
    any idea how to fix this?

    btw does flattened tree work in latest version? because if i try it my tree just disappears
     
    Last edited: May 17, 2015
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,318
    not a really satisfying solution i think.
    which rendering path do you use? and do you have a screen shoot?

    i am not responsible for the texture combining/processing at it is all done by the built in tree creator.
    nevertheless here you will find some answers.

    yes.
    it is not used.
    this texture is not used by the afs tree creator shaders
    only blue and alpha are used.

    lars
     
    artistpetemac likes this.
  50. artistpetemac

    artistpetemac

    Joined:
    Sep 8, 2014
    Posts:
    19
    Thanks for the tip, unfortunately receive shadows was already off. I tried it both ways.