Search Unity

Advanced foliage shader [released]

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

  1. artistpetemac

    artistpetemac

    Joined:
    Sep 8, 2014
    Posts:
    19
    upload_2015-5-17_14-41-4.png
    Thanks for the the explanation of the texture compositing.
    Here is a screenshot.
    We are using forward rendering.
    -Pete
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    it looks as if it only appears on the bark material. it might be that it is the specular reflection. so please check your spec color and gloss texture.
     
  3. Jenkaro

    Jenkaro

    Joined:
    Nov 12, 2014
    Posts:
    5
    Hi Lars, AFS v.4 work with Unity 4.6 ?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    nope, you would have to use v3.
    once you have purchased v4 you could send me your invoice number and i would send you v3.

    lars
     
  5. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Hi. It doesn't work with speed tree?
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    speedtree has got its own everything.
    you could convert speedtrees to be compatible with afs though.

    lars
     
    ksam2 likes this.
  7. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Thanks but how?
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    simply convert the speedtree mesh using the foliage tool.
     
    ksam2 likes this.
  9. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Does it will reduce quality?
     
  10. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    My tree get disappear when I use foliage tool :(
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    you can not convert speedtrees as "trees".
    you will have to use the tool to set them up using the regular foliage shaders.
    speedtrees bending will be removed completely.
     
    ksam2 likes this.
  12. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Sorry but I didn't understand what you said. when I use "Save mesh" button in foliage tool the tree will be disappear
     
    Last edited: May 21, 2015
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    you must not use "convert tree" as this function assumes a tree creator tree as input and not a speedtree (and is broken in the current package...).
    you have to use "set bending".
    for more information please have a look at the folaige tool documentation.

    lars
     
  14. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    I didn't use "convert tree". As you said I just select foliage tool script and then click on "Save mesh" button then my tree was disappeared.
     
  15. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    138
    When using the "AFS/Grass Shader v4" in Unity 5 (DX11), the grass goes black in play mode, wind works, any ideas on how to fix?

    Got latest version (4.01) of AFS.
     
    Last edited: May 27, 2015
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    in the demo scene or a custom one?
     
  17. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    138
    It was custom, all demos worked, found the problem; had Optimize Mesh ticked on model file, thanks for quick reply.
     
  18. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    138
    Found another issue, it seems parts of the grass, both my custom one and the demos relies on ambient light but is darker than the other part even when change ambient levels, I've tried the "noambient" flag in the shader code and then the other (darker) part just goes solid black, is there any way to have it balanced?

     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415

    it looks as if you were not in playmode so ground normals are not baked ti the mesh.
    grass lighting will most likely only work in playmode or after combining the instances statically.

    lars
     
  20. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    138
    That was in play mode, in non-play mode it looks normal.
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    well, then some more information right from the beginning would be nice…
    and if that is in playmode something must have gone totally wrong: the grass model shows up different normals on different faces which should not be the case if you used the "combine children" script.
    is it assigned to the grass’ parent object and set up correctly?
    do you get any error s in the console?

    lars
     
  22. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    138
    Just tried the combine children script and it works now, thanks, although it looks like it has a 65000 limit.

    Thanks for your help, sorry if I was a little difficult.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    you were not difficult but reading the docs really helps ;-)
     
    hopeful likes this.
  24. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    138
    Seems my custom one only worked because I had them set to static, otherwise they are black, however I did see some messages in the log about leaks or something.
     
  25. astrand130

    astrand130

    Joined:
    Nov 9, 2014
    Posts:
    21
    Hello,
    I have been using AFS4 for a while but there is still something I can't wrap my head around. I have made multiple grass detail textures and Combined maps and would like to use them on the same terrain. but when I go to the Setup Advanced Foliage Shader script there is only one area to define the Combined Normal/Translucency/Smoothness map variable. If possible how do I assign the corresponding maps to each one of my grass detail textures?

    Thank you for your time.
     
  26. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,331
    The terrain system uses one texture sheet for all detail textures. So you have to combine all your detail diffuse and 'AFS' textures into one texture sheet like the one in the example files. This is a good practice anyway as it allows a lot more control when making the plants and saves performance. The annoying part if they are already done is going into each plants and reworking the UVs.
     
  27. astrand130

    astrand130

    Joined:
    Nov 9, 2014
    Posts:
    21
    Ya, I was originally considering using meshes for the grass geometry but Unity doesnt really have a good way of aligning them to the terrain normal (I think I remember there being a solution in AFS for this but I cant seem to find it) so I had to use Unity's procedural grass billboards and plane geometry which looks terrible but better than floating plants. There is no way to atlas grass detail textures, so I guess I will have to find a way to make it work with detail meshes instead then. (Edit: reworking UVs isn't really a hastle for me since I use blender I'm constantly going back and redoing the UVs but it's not actually that tedious since most of the unwrap tools are automated.)
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    @astrand130
    - use detail meshes so you can create a texture atlas and map the uvs accordingly.
    - you may raise the pivot of your meshes a bit so grass does not float (at least not at moderat slopes).
    - grass aligned according to the ground’s normal is an option in the "geometry brush". it only works for manually placed grass meshes.
     
  29. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    521
    Just one question: does this asset allow SpeedTrees in Unity 5 to cast shadows when using baked GI and baked only directional light (using deferred rendering path) ?
     
    Last edited: Jun 3, 2015
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    afs is not related to speedtree.
    but btw.: baked shadow usually do not rely on shaders assigned to the objects. i would think it is more about the lighmapper not seeing the objects…
     
  31. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    521
    It seems there's currently a limitation in Unity 5 concerning this:
    Any trick to getting terrain trees to cast shadows on lightmap?
    And with Mixed mode on my directional light I got awful results as tree shadows cast on terrain but not grasses (speedtree grasses) below these trees.

    For that reason I wanted to know if AFS can help to solve this as I really need my trees to cast shadows from trees, even if that shadows are realtime for trees.
    So the answer is yes ?
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    if you use speedtree grass and speedtree trees i do not know how afs could help...
     
  33. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    Hi there, I'm having an issue using afs with the grass on my terrain. The grass is only visible when facing a certain direction, if the player moves 180 degrees around for instance, the grass becomes invisible.

    anyone know how to fix?
     
  34. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    Sorry if this has been asked before, but can the bending / moving aspects of the shaders be used or implemented into other shaders? I'm using a toon shader for most of the models in my game, although I'd probably use some kind of shadeless material on the grass to save framerate though.
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    make sure you have got the latest version from the asset store.
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    theoretically bending could be used with other shaders. bending is done in the vertex shader. so you could write any fragment shader including lighting you want.
     
  37. Jaqal

    Jaqal

    Joined:
    Jul 3, 2014
    Posts:
    288
    Hey lars I have been using AFS for quite some time now and have recently upgraded to unity 5. It is working as good as ever but I noticed that if I am not using the proper maps now my plants are quite shiny. Before I simply used a diffuse and normal map and it looked fine. My question is do you have a tutorial or reference for combining the spec\trans\normal maps. I use gimp and can do basic editing but I cannot figure out how to make and combine these into one proper texture. Thanks.
     
  38. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,331
    I asked on the GIMP forums a while back and got a good response.

    http://gimpforums.com/thread-how-do-you-move-rgb-chanels-from-one-image-to-another

    So what I have been doing is decomposing the normal map. In the decomposed texture I delete the blue and rename the red layer alpha and keep it at the bottom. Then move the gloss texture in and name it blue. Then move the translucency texture over and name that layer red. Then line them up Red-Green-Blue. Recompose the image. Make sure the channels are correct. Red to red and so on. You do not want to compose the alpha yet. Just RGB.

    So in the new composed image it should have that "afs texture look". All we have to do now is move the Alpha(previous normal map red channel) from the decomposed texture over to the new texture. Then move it into the channels layer box underneath the channels so when you sav it as a psd it will apply the alpha. Make sure it is not visible and affecting the image. Delete the dropped alpha texture from the normal layers so it is just the afs texture. Then export as psd.

    Sorry for using wrong names for things and any mistakes. Not on my computer. Will correct anything and explain things better later.
     
    Last edited: Jun 18, 2015
  39. Jaqal

    Jaqal

    Joined:
    Jul 3, 2014
    Posts:
    288
    Thanks man. I am not all that great at texturing. I can make basic albedo and normal maps but I'm still learning the rest. When I get home I'll give this a shot. I'm not sure how to decompose the texture but im sure I can find out. Dont worry about the mistakes I'm on my phone as well!
     
  40. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Hey Lars,

    I have an issue using 5.1.0p1 where the Tree Creator complains about the tree using multiple leaf shaders (Although I double-checked the material, which is set to Nature/Afs Tree Creator Leaves. All the texture slots have been set up and the material looks correct in the preview) and I need to select which shader to use. Your shader does show up in the prompt, but clicking apply does nothing.

    I also have the problem, where clicking the refresh button made the tree disappear completely. All the parametres in the Tree Creator are there, but nothing is shown in the preview or in the scene (Although in the scene, selecting the branches for example, does show the Tree Creator's purple lines and "edit" points). I got a bunch of the following errors as well:

    I'm using Linear Color Space and Deferred rendering. Looking forward to your response.

    -Daniel
     
  41. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,331
    Hey Jaqal, woke up and figured I should make a more proper tutorial for this.

    AFS Texture Tutorial

    Hope this helps more.
     
    Last edited: Jun 18, 2015
    ElectroMantis likes this.
  42. Jaqal

    Jaqal

    Joined:
    Jul 3, 2014
    Posts:
    288
    Dude you just made my day. Thank you so much!
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    @daniel,

    haven’t checked 5.1.0p1 so far. but i guess it should work anyway as the changelog only mentions: "
    • (699779) - TreeEditor: Fixed incorrect labels and tooltips."
    so please check your materials once again.
    or start with a simple tree.

    lars
     
  44. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    I tried creating a new tree and it seems the Tree Creator is still horribly broken. They fixed the labels, but that only seems to work for existing trees. Creating a new tree doesn't work (It creates the tree, but I have no options for the trunk, only the root node) and gives me the following error message:

    My materials look weird in the inspector actually, like the model it's wrapped to in the preview is completely warped (http://i.imgur.com/sV2gZDe.png). This happens for all the AFS shaders and all the standard Nature shaders (Though not the AFS/Grass Shader v4, the Nature/Tree Soft Occlusion Bark or the Nature/Tree Soft Occlusion Leaves shaders).
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    @Avonaeon: what shall i say? i am not responsible for the tree creator not for material preview window, sorry.
    i think you should file a bug report.

    lars
     
  46. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Oh sorry if it came across as implying it was your fault, I know it isn't! :) It was just for the purposes of being thorough, so you knew what was going on.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    no problem.
    and btw.: i do not have any problems creating a new tree using unity 5.1.1. some icons are missing, but that is all.
     
  48. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Alright, so I updated to 5.1.1 and it helped, to an extent.

    I still have the issue where I can't seem to apply the Nature/Afs Tree Creator Leaves shader to existing trees, though it works fine when I create a new tree, so I might try and go that route. The bark works fine, as it's using the Afs shader in the Optimized Bark Material correctly, but the leaves don't seem to want to update (When I get this prompt http://i.imgur.com/ewZlITc.png).

    I don't know if this is AFS or still Unity's problem (Because as I mentioned, the Tree Creator is still broken to an extent), but I thought I'd let you know in case it's something related to AFS.

    Anyway, thanks for the responses!
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,415
    hmm, i do not have any problems assigning the afs tree creator leaves shader – even to existing trees.
    please make sure you always use the Nature/Afs Tree Creator Leaves" shader on your base materials/meshes and NOT the "Nature/Afs Tree Creator Leaves Optimized".

    lars
     
  50. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    I have another question. How do I run the GrassMeshPostProcessor AFS? I can't seem to figure out how to treat my model which has the suffix _AfsGM.

    Nevermind. I made an editor script that does it :)
     
    Last edited: Jun 24, 2015