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. Dismiss Notice

Advanced foliage shader [released]

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

  1. negativecap

    negativecap

    Joined:
    Jan 27, 2013
    Posts:
    99
    It basically works, but the shader's aren't assigned correctly, the bump maps are too weak, I don't think translucency is working and, at least for me, I'm getting some poor (noticeably worse than tree creator shaders) billboard and fading/popping when using AFS with the trees... It probably has something else to do with my setup, I can't get billboard shadows to work either.
     
  2. Cowboykilla

    Cowboykilla

    Joined:
    May 17, 2013
    Posts:
    5
    First off, I feel like an idiot for asking this: This shader will work with NON-pro version of unity correct? Just wont have real-time shadows?
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hi there,
    that sounds pretty strange – and the tree shaders just should work.
    make sure you have created new materials, assigned all needed textures, chosen the right shader and added those materials to your trees.
    it works püerfectely for me (tested with spruces, mountain pines and white oaks).

    lars
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hi there,
    the shaders work with all versions of unity. and even when using the free version of unity you will get real times shadows (only hard shadows, only from one directional light: that is the limitation made by unity free).

    lars
     
  5. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,521
    Hey lars. Feel weird asking but I am very curious. What more are you planning to do with this pack? It has already quadrupled in features since release. Not sure what other awesomeness you are planning.
     
  6. larsbertram1

    larsbertram1

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

    it might be lighting that a will have another look into…
    well, i have been working on that in fact.

    lars
     
  7. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,521
    Cool. Keep up the great work.
     
  8. krillmcrawl0

    krillmcrawl0

    Joined:
    Jan 13, 2014
    Posts:
    35
    I got the replacement working, looks really good on my custom terrain. Maybe this is not related to your tool but I ask anyway:
    Do you have any idea on how to disable the visibility of the terrain but keep trees visible?
    The terrain receives shadows and renders below my custom terrain, it is unnecessary and dragging the performance down.

    Kristian
     
  9. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Lars, this is EPIC! Pitty i don't have $20 cash to spend...
     
  10. larsbertram1

    larsbertram1

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

    you would have to use a custom shader which renders: nothing.

    lars
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    what a petty!
     
  12. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    Lars --

    I just bought this asset so I could figure out how you're doing things. Quite nice solutions! The main thing I was interested in is how you fix the billboard camera perspective problem and you have done quite a nice job with it!

    One thing I noticed however is that the billboard fading seems to ignore billboard camera perspective calculations, instead relying on the old camera-facing billboards as the fade-to target. Am I seeing this correctly?

    Is there something you could do, or I could do, to fix this?

    Thank you, as always.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hi sgoodrow,

    thanks for your kind words.

    but what do you mean with:
    "the billboard fading seems to ignore billboard camera perspective calculations"

    billboard should always be rendered using the new billboard shader.
    may be you have some issues activating the shader using the script?
    are you are using unity3?
    or your main camera is not tagged as main camera?

    lars
     
  14. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    I am using Unity 4.3 and my camera is correct, yes. The billboards render properly when there is no tree prototype blending going on (if I set the fade length to zero, for example, then all billboards have no tree prototype blending and they render with the proper angle). If a tree is being blended between the prototype and the billboard, the angle of the billboard that its being blended with is not using the camera alignment?

    I have some terrain modifications on my end as well, so it could be a incompatibility on my end, but I'd like confirmation from you that you don't see this happening.

    To reproduce it, try setting the billboard start distance to something very short like 10 and the fade length similarly short, also 10. The stand nearby so that you can see the some trees in a blended state, and look up.

    Edit: Something to note is that I am using trees at least 2-3 times taller than those in your demos.
     
    Last edited: Feb 14, 2014
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    the script will set the fade length to 0.0 or 0.001 – otherwise the whole thing will not work at all.

    and i have just opened demo scene: 06 tree shaders, lowered the "billboard start" to 10 and looked around:
    it looks awful but everything works correctly as far as i can say.

    lars
     
  16. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    So you've rewritten the fading system, or removed it completely? I created a new project to import your system into and am having a hard time getting the billboard distance/fade variables to work. Out of the box, they seem to work fine, but if I modify either of the two pine trees trunk lengths, and refresh the prototypes on the trees, the billboarding parameters stop working (sometimes)?

    I am in a position where I don't want to use your entire system, its overkill for what I need, so I am just trying to understand how you implemented certain things.
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    usually the "blending" is done in the shaders for the mesh trees: when they come in they are distorted to fit the upright oriented standard billbords. then they fade towards their real shape. during this transition they do not cast nor receive real time shadows.
    we don not want any of that behaviour. so we have to stop them from being "distorted" --> fade lenght = 0.0001 (0.0 might kill you frame rate from certain perspectives).

    the new mesh tree shaders handle all the rest.

    that’s it.

    lars
     
  18. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    Ah i see. Ok, that helps clear things up a lot. Thank you.

    Do all instances of a tree prefab need to be the original scale? When I alter the "Pine1 - original using afs shaders" scale from the normal (0.5, 0.5, 0.5) to (3, 3, 3), and set the billboard distance to something low again, the tree angles off to the side?
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    as far as i know unity's terrain engine will just ignore any scale settings made to the tree prefabs.
    and the 0.5 settings of the pine tree are indeed ignored: just place a prefab next to a tree placed within the terrain engine.

    so there is no need to further discuss this topic i think.
    nevertheless: even upscaled prefabs (which will have the scale of 1 on the terrain) behave correctly.

    but setting your billboard start to somewhat like 10 meters will simply make the whole new fading obsolete because it is not possible to fade at 10 m.

    lars
     
  20. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    You're certainly correct about the trees being rescaled to (1, 1, 1) on the terrain.

    I apologize if my questions seem pedantic. I am just trying to learn, I promise. Currently, I am just having problems getting the billboards for the pine trees to behave. With a new project and new scene, the whole system is fine, but if I modify the tree creator settings for either pine prefab, the billboards look very low res and don't fade anymore. Is there a step I am missing to re-render the high resolution billboards, or reset the tree mesh system, or something?

    Edit: I just saw your usage notes. Sorry, your documentation is overbearing. It says that after creating the tree in the tree creator, you have to manually change the shaders from the built-in optimized shaders to your optimized shaders. Is there no way to automate this process?

    Yes there is. You overwrite the builtin shader. Got it.

    Sorry lars, I should have read more before asking here. You have really done some tremendous work, I can't applaud you enough for it. I know you've spent a ton of work on the package itself. Might I suggest spending some time simplifying your documentation and working out the grammar? I understand english may not be your native language, but I think you'd save yourself a lot of work by cleaning up your documentation.
     
    Last edited: Feb 14, 2014
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848


    that works only for unity 3.x but not in unity 4.x, sorry.
    so you will have to create and assign materials manually.

    lars
     
  22. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Lars,

    I am creating an underwater based game for iPhone, iPad. What I need it just a simple diffuse shader for bending the billboard vegetation I created. Does your package contain something like that? that I can use for iPhone with just a simple diffuse and the vertex animation? Please let me know as soon as possible.

    Regards,
    Carlos
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hi carlos,

    iphone and i pad still do not like alpha cut out shaders as far as i know (and all shaders of the package are…).
    so i would recommend that you have a look in my free mobile foliage shader package that comes with an alpha blend grass shader.

    you may of course use the combine children afs script from the package to speed up rendering or use the free geometry brush to place your plants.

    lars
     
  24. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Lars,

    Based on the amazing package that you have here, I can see that you a specialist in shaders, so I was wondering if you could make me a shader that has just a texture, transparency and a swaying vertex animation on it. If you do, how much would you charge and how long would it takes you. I don't use the unity terrain of course.

    Regards,
    Carlos
     
  25. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Lars,

    I found the shader that I needed in your package. Thanks so much!

    Regards,
    Carlos
     
  26. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Hey lars,

    What is causing this outlining of billboards in dark scenes? This does not happen during daytime.

    Using your trees (scott's pines and Mountain Pines). Happens with your shaders, with unity shaders, with marmoset shaders, with everything and I cannot fix it :( .

    $Unity 2014-02-20 17-34-46-01.jpg

    copy paste the image url to see the the full image.
     
    Last edited: Feb 20, 2014
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    billboards are rendered using a transparent shader.
    and the billboard textures are rendered against a dark gray background. so may be its a problem of the alpha mask.
    you might try to get around this by raising the _cutout value.
    but you could also add a little bit more light to your scene to make it less noticeable.
    personally i think your scene is a bit too dark anyway.

    lars
     
  28. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Its not that dark in engine. For some reason Fraps takes really dark images for me. Raising the cutout value doesn't do anything.

    If I raise the lighting it also doesn't help until you get to day time levels.
    Here is the same problem with the lighting higher (are game is set at night so it needs to be dark)
    $Unity 2014-02-24 12-14-51-80.jpg

    I found someone who claims to have fixed the problem ( http://answers.unity3d.com/questions/336217/terrain-tree-billboard-have-bright-outline-against.html ) but their solution doesn't work for some reason.

    "We figured out the problem was with the alpha-blending part of the shader, and it was extremely easy to fix. We just downloaded the built-in terrain billboard shader and added the following line of code: `AlphaTest Greater 0.9` after the blending mode definition `Blend SrcAlpha OneMinusSrcAlpha`"

    I copy and paste AlphaTest Greater 0.9 after SrcAlpha OneMinusSrcAlpha in your shader and nothing happens.
     
    Last edited: Feb 24, 2014
  29. Pelasgus

    Pelasgus

    Joined:
    Feb 10, 2014
    Posts:
    4
    Hello Lars,

    I love working with this shader, it's definitely the best foliage rendering I've seed in Unity. I think it really brings the possibilities of the engine into new territory!

    I have a couple questions. Some of the the shaders use vertex alpha for some extra shading/AO, right? I use Blender to model, it can do vertex colors easily, but is there a way to do vertex alpha in Blender?

    Thanks for any thoughts!
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    not as far as i know, sorry.
    but i do not use blender, so i might be wrong.

    lars
     
  31. Project-Mysh

    Project-Mysh

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

    I'm having some problems with fade billboards: The original camp demo trees fade correctly, but when i use your Advanced foliage shader there is no fade at all, it jumps directly to billboard. I tested Demo1 included in the package and its happening the same. This only happens to me with the last version.

    Im doing something worng?

    Last version of unity + deffered rendering.
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848

    from what you have written i hardly can say anything about your problem.
    to make the billboard fading work:
    - assign the correct shaders to your tree prefabs
    - update your trees
    - check the "Fade Length" in the setup foliage shader inspector (not the terrain settings).

    please have a closer look at the documentation.
    it should simply work ;-)

    lars
     
  33. TimBorquez

    TimBorquez

    Joined:
    Mar 18, 2013
    Posts:
    81
    sorry I'm really new to this, I'm trying to get my grass to sway like the demo

    I painted my grass with the geometry brush and the parent of all the grass billboards has CombinedChildrenAFS. but isn't moving, I must be missing something. . .
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    hi tim,
    have you added the "setupfoliageshader" script to the scene and tweaked the wind settings? foliage does not receive wind from wind zne or the terrain settings but only the "setupfoliageshader" script.
    do your grass meshes do have proper vertex colors (those control the bending)?

    lars
     
  35. TimBorquez

    TimBorquez

    Joined:
    Mar 18, 2013
    Posts:
    81

    oops thanks, the shader for my grass was wrong
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    oh, i did not take that possibility into account ;-)
    i hope you enjoy it,

    lars
     
  37. TimBorquez

    TimBorquez

    Joined:
    Mar 18, 2013
    Posts:
    81
    one more question, when i load my scene from a different one my grass is completely black, im not sure which setting would fix this
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    load your scene from "a different one" - what one?
    lars
     
  39. TimBorquez

    TimBorquez

    Joined:
    Mar 18, 2013
    Posts:
    81
    well i have my grass on one scene and when i play the game in the editor on that scene the grass looks fine, but if i go to my title screen and load my level the grass is black, the alpha still works but the color is totally black
     
  40. Project-Mysh

    Project-Mysh

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

    There is some way to implement your touch blending function in another shader, like marmoset shaders? I was trying to implement it but im not familiar with shader language. Or for example if i want to use touch blending with a toony shader effect ( like the legend of zelda wind waker ) etc...
     
  41. juliobds

    juliobds

    Joined:
    Dec 27, 2011
    Posts:
    25
    Hi Lars,

    3 things:

    1. Bought this package earlier today, nice job on it.

    2. The link provided for the .unitypackage in the first post is broken. (The link about the tool to place objects anywhere)

    3. I need to place trees at runtime on top of some objects I have. What I need the most is having these trees have billboards when farther away from them. Is it possible to have a tree prefab turn into its billboard when "not connected" to a terrain? I know it's already possible to have various LODs for a single tree but ultimately I wanted to have them turn into billboards and have them be batched (using Unity Pro here BTW).

    If the third point isn't possible I would be very grateful if you could provide the package in the second point as that could help me a lot to find a workaround for my problem.

    Cheers.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
    @juliobds
    1. fine.
    2. which package do you mean?
    3. placing trees at runtime is not supported out of the box.
    and trees which are not connected with the the terrain won’t turn into billboards.
    so you will have to add your trees to a terrain to benefit from billboarding.
    but i am not sure if this can be done at runtime without any hickups as you usually have to flush the terrain data to make things come visible.

    batching trees usually is not possible – and unity does not really recommend it in its docs as batching a lot different objects will eat up your memory:

    https://docs.unity3d.com/Documentation/Manual/DrawCallBatching.html

    but you can have a look at an old post of mine:
    http://forum.unity3d.com/threads/138929-batching-trees-%96-and-speed-up-rendering

    lars
     
  43. larsbertram1

    larsbertram1

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

    when lux has reached its release version (http://forum.unity3d.com/threads/221985-Lux-%96-an-open-source-physically-based-shading-framework)
    i will add physically based shading and/or image based lighting to the advanced foliage shaders.
    other shaders like toon shaders will not be supported: where should i start, where should i stop?
    sorry, but if you need a very special shader to support touch bending you will have to ask a shader programmer to adopt it.

    lars
     
  44. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Waaaah, you are building your own physically based shaders!!! If I had known I would not have purchased marmoset T.T. What price will it have? I'll have to buy it to have ADF physically based?
     
  45. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,785
    Lux is free...
     
  46. juliobds

    juliobds

    Joined:
    Dec 27, 2011
    Posts:
    25
    The free "Geometry Brush AFS" tool

    You say:

    Make sure you get the free "Geometry Brush AFS" tool: a very nice and handy tool that will help you to manually place any game object onto any terrain or geometry – originally posted by Matt McDonald, Owner, Chief Creative Officer and President of Heavy Water, www.heavyh2o.com, but optimized for the use with the advanced terrain shaders.
    https://dl.dropboxusercontent.com/u/...1.unitypackage


    But the link provided seems to be dead.

    Also thanks for the extra link you provided I'll try some things out and do some tests to see how I can get the best and faster results.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,848
  48. juliobds

    juliobds

    Joined:
    Dec 27, 2011
    Posts:
    25
  49. hellaandrew

    hellaandrew

    Joined:
    Mar 31, 2010
    Posts:
    33

    Hello to all,

    Regarding this problem.. we figured out what was going on. The problem is that all the trees that we were using were located inside of an Ambient-Occlusion folder. All of our trees were in there originally to work with Unity's Nature shaders, but we didn't bother moving them out when we started to use your shaders.

    After much testing, we found out that the Ambient-Occlusion folder was the culprit! So for all who are using this shader, please keep this in mind and to avoid using a folder with "Ambient-Occlusion" in the name!

    And to the creator - great work!! Looks awesome :)
     
  50. larsbertram1

    larsbertram1

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

    tanks for both: making people aware of not placing their objects in the "outdated" Ambient-Occlusion folder and your kind words.

    lars