Search Unity

ats Mobile Foliage [released]

Discussion in 'Assets and Asset Store' started by larsbertram1, May 20, 2012.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    Released!

    get it: http://u3d.as/content/forst/ats-mobile-foliage/2XM
    test it.
    discuss it.


    tutorial made by arunderan (aka tiles) showing how to apply the vertex colors using blender:
    http://www.youtube.com/watch?v=0Z_Pu225lGg



    $tm4_test.jpg

    The shaders shipping with this package bring nicely bending trees, foliage and grass even to mobile devices.

    See the shaders in action: http://bit.ly/MhRKpI.

    Main features
    * primary and secondary bending plus edge fluttering controlled by vertex colors
    * baked in ambient occlusion using vertex alpha
    * lightmapping support
    * support of batching, occlusion culling and the use of LODs
    * both alpha blending and alpha testing are supported - depending on your target platform
    * 3 demo scenes and models are included showing how to set up trees, smaller foliage like fern and grass.
    * the shaders are not designed to work with the built in terrain engine but support the free placement of your models and work fine with custom terrains like those created with t4m.

    * and may be less important: they come for free






    first tests done by lars steenhoff give following results:
    * 60 visible mesh trees + simple ground + custom skybox
    * 13.2 tris / 24.4 verts

    iPhone 3gs -->
    55 fps Alpha blending
    45 fps Alpha test

    iPad 1 -->
    30 fps Alpha blending
    20 fps Alpha test

    another test done by Azert2k
    * 30 visible mesh trees + simple ground + custom skybox

    Onda v610w (1Ghz, ICS) -->
    35/47fps Alpha blending
    58/63fps Alpha test

    iPhone 4 -->
    More than 30 Alpha blending
    22/26fps AlphaTest
     
    Last edited: Aug 9, 2012
  2. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    Lars, you're a boss! Thanks! :)
     
  3. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Hummel Hummel
    ;)

    Vielen Dank!
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Thanks for making this available, I will try to make some new trees with this technique.
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
  6. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    FREE?!




    Too awesome ! Thanks mate!
     
    Last edited: May 22, 2012
  7. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    looking more from u as free .hats off
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    thanks guys,
    but how are your experiences with the shaders?

    lars
     
  9. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    Hi Lars,

    Just downed the shader, and wanted to do some tests with some Billboards, but I get some weird effects.:

    When Using the atsGrass-Unlit-Wind shader; the Grass gets projected a couple of inches behind the plane itself, wich in turn causes weird movement when rotating..



    Is the Grass shader even intended for Billboards? Im assuming it was, since the foliage section in the Unity Terrain are also billboards, but I could be wrong all together..
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    well, this might happen because there are 3 independent animations on your grass model: scripted billboard rotation, the shader based wind animation and an animation component.

    i have never tested the shader together with the billboard function of t4m as i do not like billboarding at all. but having a closer look at your screenshoot i am wondering if you have applied any vertex colors to your grass model: if applied correctely (vertex alpha = 0 at the bottom vertices and vertex alpha > 0 at the upper ones) you should not get any displacement on the lower vertices. but as your screenshot shows the whole models gets displaced.

    following these steps might solve the problem:
    * check your vertex colors or test billboarding with the grass model included in the package
    * delete the animation component as you do not need it and it might cause the problem

    btw.: your grass model looks much too complex: it seems to have about 25 vertices whereas only 4 would be enough. just use a simple quad.

    lars
     
    Last edited: May 24, 2012
  11. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    Hi Lars,

    thanks for the reply. I booted up Unity today, removed the animation component for that billboard, and added a GrassA prefab in my scene. This instanty solved the problem; even on my old billboard; No more offset between mesh and texture :)

    But, no I encounter something else: I attached the SetupAtsMoibleVegetationShaders to the GrassA gameobject. That object and wind works perfectly now. The bottom of my own billboards however don't seem to be attached to the terrain, rather the entire plant moves across the terrain back and forth, for about a meter. No stretching or warping is noticable, just the whole plane moving back and forth. Any idea what causes this?

    I'm really starting to think this, and the texture offset issue, is because of the way my vertex colors are setup, and that is probably due to me not quite understanding what you mean :) If I read your post correctly, I can use the alpha map of the grass texture to assign "Bendiness" / displacement on different parts of the texture? I'll get right on it!

    BTW: I'm doing these tests on a homemade billboard, not T4M at the moment. And thanks for pointing out those planse had too many vertices; that was exactly one of those things that would have slipped through the cracks :)
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi thomas,

    you just have to attach the "SetupAtsMoibleVegetationShaders" once in your scene – not to any game object that should use wind – just in case you thought so.

    next thing – floating billboards: i am pretty sure that you did not apply vertex color correctely. as far as the grass shader is concerned the bending is controlled by the vertex color alpha value of your mesh. it has nothing to do with the alpha value of your texture.
    you have to edit vertex colors in your 3d app (blender, max, modo, maya all support vertex painting) and apply vertex color alpha = 0 to the lower vertices and let’s say vertex color alpha = 0.5 to the upper vertices.

    you might want to have a look in the manual of the advanced foliage shader where bending and the setup of your models is described a bit more detailed. keep in mind that the way described in this manual works for another shader using vertex color blue to set up the bending. you will have to apply vertex color alpha values instead.



    Read the docs.http://bit.ly/JkLwD1
     
  13. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    Ahhh ok, thanks for the explanation and link.. Haven't dealt with Vertex Colors before, so I'll start working with it today..
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    unfortunately the grass shader does not ignore projectors but it should...
    so when using blob shadows please change line 10 of the grass shader to:

    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "LightMode"="ForwardBase"}

    an update is on its way.

    lars
     
  15. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,755
    Is there a reason why it's 3.5 only? I'm still on 3.4 and I can't download it sadly.
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the new prefab system makes it impossible to use with 3.4 – sorry about that.

    lars
     
  17. SJAM

    SJAM

    Joined:
    Jan 11, 2009
    Posts:
    729
    Fantastic :)

    So, I made a try on my new phone : HTC One X (Tegra 3), Constant 60fps with AlphaTest shader and 47fps with AlphaBlend.

    The situation is reversed between iOS/Android :
    Android devices works better with the AlphaTest Shader, but iOS doesn't like it and prefer the AlphaBlend Shader.

    HOX ScreenShot (Unity Android basic, so no static batched for me, certainly better on Pro version)


    You can find this beautiful work integrated in the interface of the next version of T4M (Thank Lars for its authorization)
     
    Last edited: May 26, 2012
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I'm trying to use these shaders with trees from an earlier project, made for Unity's Terrain (two materials, one for leaves, one for trunk). It looks pretty darn good, but when I rotate the camera, the leaves shift color a bit--from darker to lighter green. Do I need to have the 3D artist revise the models in Maya so they'll work well with this shader, or can I do something in Unity to fix it?
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi gecko,

    color shifting is a pretty common behavior… it is caused by the fact that the shader expects lightmaps. so you will get this shifting unless you bake lightmaps for the trees. do so like described in the documentation: switch the shaders on all trees / materials to the default cut out diffuse, bake the lightmaps (and make sure that you have chosen an appropriate lightmap size for all trees / materials so they will all be rendered into one single lightmap) then switch back to the alpha tested or alpha blended shaders.

    doing so should stop color shifting.

    just let me know if you encounter any problems.


    lars
     
  20. Yippie

    Yippie

    Joined:
    May 4, 2009
    Posts:
    227
    will use this for my game, thank you
    and pu..lease make more :p
     
  21. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,755
    I downloaded on 3.5 then copied the shaders and scripts into my 3.4 project.

    Your package is quite awesome. Here's some impressions/feedback.

    1) You had an alphastest cutoff even on the alphablend shaders. Generally they had a bit more fat than they should. not much of a problem though.

    2) You have these frequences hardcoded in the shader : 1.975, 0.793, 0.375, 0.193. While they look fine, I ended up tweaking them (I went for subtle movement and the high frequency movement was too much). Maybe those should be exposed and be tweak-able from the user, if you want to make this more customizable and user-friendly. (not that editing the shader directly was that hard).

    EDIT:

    3) Forgot to add! Didn't like that the movement of the vertices and the "fake AO" both use the RGB of the vertex map. The movement should take its data from the alpha from the vertex map. I ended up editing the shader and removing the vertex "AO" completely (since the texture already looked how I wanted it to look).
     
    Last edited: May 31, 2012
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi acidarrow,

    would you mind to share your "optimized" shader versions?

    lars
     
  23. larsbertram1

    larsbertram1

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

    thomasQ reported problems with the alpha testing shaders in unity 3.5.2f2: no cutoff at all…
    can anybody confirm that?

    lars
     
  24. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    Actually, it's reverse. I only have alpha cutoff with the alpha tested shader, not with the others :confused:
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i have just upgraded to 3.5.2f2 – and everything works the way it is expected to work – at least in the editot. but i do not own any iphone or android license…

    may be you just reload the package from the asset store into a new project and test it again.

    lars
     
  26. larsbertram1

    larsbertram1

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

    any further reports on performance? or does anybody have any problems like those reported by thomasq?
    please just share your experiences with the community.

    lars
     
  27. PizzaGuy213

    PizzaGuy213

    Joined:
    Nov 23, 2010
    Posts:
    305
    It's been a bit of a busy weekend here, but I'll see if I can test it on another windows (got 2 installed) tonight!

    I don't know nothing about shader coding, but I was thinking, if the test on the other Windows fails as well, could it be Hardware / driver related somehow? If so, I've got a GTX570 MSI hooked up..

    If the test I'll do tonight fails as well, I'll try and run a test on a different machine tomorrow, just to narrow down what's causing it :)
     
  28. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I am using this shader on trees in a scene which also has a T4M terrain -- but the trees were not planted within T4M. I can't figure out how to adjust the wind. I adjusted it in T4M, but that doesn't work (which didn't surprise me much). So I added a GO with the "setupAtsMobileVegetationShaders" script, but that doesn't seem to have any effect either. What am I missing?

    thanks
    Dave
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    what kind of trees do you use? those shipping with the package? they should work correctly – right out of the box when you attach and enable the "setupAtsMobileVegetationShaders" script…
    in case you use your own trees i really can’t think of anything other but missing or better wrong vertex colors in your model.

    btw: do you have problems like those described by ThomasQ: alpha blending shaders showing no alpha cut out?

    lars
     
  30. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Oh, that's probably it -- I'm using trees from the terrain engine. There's no way I can just shut off the wind?
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi gecko,

    unfortunately i am still not sure whether i get you right or not as your words are a little bit imprecise...

    what do you mean by "trees from the terrain engine"?
    A. trees made for use within the terrain engine using the soft occlusion shaders like those from the terrain asset?
    B. trees made with the built in tree creator?

    ---> A.1. placing a tree using the soft occlusion shaders as single game object will not give you any bending – no matter if you activate a windzone, use the t4m wind setup or a manually attached "setupAtsMobileVegetationShaders" script

    ---> A.2. placing those imported trees using the ats mobile vegetation shaders should not give you any bending too for the vertex colors which control the bending are not set according to the shaders’ requirements.

    ---> B.1. placing a tree made with the built in tree creator using the tree creator shaders should not give you any bending unless you activate a windzone (the built in)

    ---> B.2. placing a tree made with the built in tree creator using the tree creator shaders should not give you any bending too for the vertex colors which control the bending are not set according to the shaders’ requirements.

    your goal is to deactivate any bending on the trees?
    ---> just use other shaders like bumped diffuse and alpha cutout depending on which platform you are targeting, for the ats mobile vegetaition shaders were built just to support bending!

    you want bending on trees made with the built in tree creator using the ats mobile foliage shaders?
    ---> export your tree as .obj using the exporter script from the wiki/angry bots demo and edit the vertex colors in your 3d app according the shaders’ requirements (have a look at the video made by tiles showing how to piant the vertex colors using blender: http://forum.unity3d.com/threads/123282-T4M-Black-Edition/page17#post_945113

    please have in mind:
    * the shaders require tweaked models as far as vertex colors and geometry are concerned – so you can’t use them out of the box on any imported tree model.
    * the shaders have been made for use on mobile devices: no real time lighting but support for lightmapping.
    in case your target platform is pc, mac or webplayer just go with the built in shaders.

    lars
     
  32. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks, that's very very helpful. What I meant was that I'm using trees created to use in the unity terrain engine, so they have no vertex colors, and that must be causing the problem. I like the look of your shaders over other mobile-friendly shaders, so will add vertex colors to them. Thanks!
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you are welcome,


    lars
     
  34. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Hi Would you mind sharing your tweaks? I'm curious to the new wind setting you did, and the vertex mods.
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    bump.

    anymore feedback on the package – as it had been downloaded more than 300 times so far?
    any experience would be worth to share… like some more performance tests or whatever you think might be interestesting to others using the shaders.

    lars
     
  36. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    We have painted vertex colors on our tree models now, and they work great in a test scene. But in my main scene, they still don't work (they blow too much, ignoring the wind settings). I think that the problem is that I have a T4M terrain in that scene, with ats shader settings, but the trees are not planted with T4M, but placed independently. I have it with and without a separate wind script GO, but neither works. Is the T4M script overriding the other script, but not actually acting upon the trees since the trees are not part of T4M terrain?

    EDIT: I got the T4M update that lets me deactivate ats mobile shaders, but the wind script GO still doesn't have any effect on the wind in the trees.
     
    Last edited: Jun 25, 2012
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hoi gecko – of course it is useless to use both: to script from the package and the script from t4m for both scripts do the same: they use Shader.SetGlobalColor or Shader.SetGlobalFloat to pass the wind parameters to a global variable named excactly the same: "_Wind".
    so it depends on the order in which the scripts are executed which value will be passed to the shader finally.

    in case you have removed the provided script and deactivated tm4 mobile vegetation settings you will still have wind as the global var still exists. you will have to restart unity to reset/destroy it.
    better would be just to deactivate one of the scripts and then to go to the other one’s settings and set the wind.w = 0. bending should immediately stop on all models – at least it does for me.

    lars
     
    Last edited: Jun 25, 2012
  38. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks, Lars -- I finally realized that I had a second small T4M terrain in my scene that was causing trouble. Deactivating the mobile shader on that, and it all looks great now. Nice work on this!
     
  39. moctezumagames

    moctezumagames

    Joined:
    Jun 9, 2009
    Posts:
    395
    free :) Will download as soon as I update Unity.
     
  40. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Could you release a few more trees for this pack? Birch tree would be great, I already bought most of you packs now just need some mobile versions.
    Thanks
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi lars,
    i already thought about doing so – but unfortunately there is not that much feedback on the thread concerning performance.
    as i do not have an iphone nor any android device and do not own an iphone nor android license for unity i can not test it myself.
    and i am still pretty unsure about which way is the best to get fast rendering trees on ios devices:
    a) using alpha testing although it is very expensive to render?
    b) breaking up the models and then using alpha blending (enabling static batching in order to get a reasonable number of draw calls).

    lars
     
  42. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    @Lars Steenhoff - Here is a tree pack I created for mobile and it has a Birch tree in it lol....just was reading through the thread, saw your request and realized I had some mobile trees laying around.

    http://dl.dropbox.com/u/16956434/Tree_Pack.zip







     
  43. dactilardesign

    dactilardesign

    Joined:
    Jun 9, 2009
    Posts:
    68
    I am having big problems with 3D Max vertex alpha.
    When the material is applied, all vertex move too much, and importing - exporting one of the existing meshes, they get corrupted and moving like crazy.
    I am trying to find a sollution. I will keep you posted.
     
  44. dactilardesign

    dactilardesign

    Joined:
    Jun 9, 2009
    Posts:
    68
    really nice trees.

    update: I managed to vertex paint your meshes and make them work fine in Unity, I don't know yet why my existing meshes don't work :/
     
    Last edited: Aug 18, 2012
  45. usersen

    usersen

    Joined:
    Jul 9, 2012
    Posts:
    8
    Hi, first let me say that the shaders wrok great and thank you for making them available for free!
    I have been able to vertex color my meshes to bend properly with wind but I have not been able to get vertex alpha ao to show up with wind. The documentation mentions baking ambient occlusion into vertex alpha briefly but after trying for a while I not sure if this is supported? has anybody gotten the shaders to work with vertex alpha ao?
    It may have something to do with how I bake verts in maya, i am not sure, I am using unity 4.0.1f2
     
  46. larsbertram1

    larsbertram1

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

    ambient occlusion is supported and has to be stored in vertex color alpha.
    but usually it is pretty difficult to paint to vertex alpha in most 3d apps i know.

    lars
     
  47. usersen

    usersen

    Joined:
    Jul 9, 2012
    Posts:
    8
    Thanks lars. After messing with it for awhile it is indeed how i was trying to bake vertex alpha, the shaders work great!
    I just have to find some methed of of baking properly now
     
  48. douglasfigueira

    douglasfigueira

    Joined:
    Mar 5, 2013
    Posts:
    25
    Hi Lars, thank you for the shader... I am trying it now and it's working fine, despite two little problems:

    1 - Some animated objects in the scene without ATS shader disappears (See big trees in the picture)
    2 - The animation loop in ATS shader snaps in transition end/beginning.

    What am I doing wrong?


    Thanks for make this shader available for free! :)

    $shader.JPG
     
  49. larsbertram1

    larsbertram1

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

    i am not sure if you are in the right thread. are you talking about the mobile foliage shader?
    those were written to ONLY work on mobile devices. if you are targeting other plattform please chose other shaders.

    but let’s assume you are right, then i don not understand what’s going on...

    - what kind of shader do the big trees use? have you checked if they have any animation component added?
    - hmm, there is no "animation" in the shader. there is a little script animating the wind that is needed by the shader. do you mean that?

    lars
     
  50. douglasfigueira

    douglasfigueira

    Joined:
    Mar 5, 2013
    Posts:
    25
    Thank you for your response Lars...

    Yes, I am talking about mobile development and using your foliage shader.

    - The big trees use a simple diffuse shader, nothing special and have animation attached to it, but, since the shader is a common diffuse shader and not a ATS shader, I don't know why they are moving. If I uncheck "setupAtsMobileVegetationShaders", which is assigned to a GameObject, my trees come back normaly, but I loose the desired effect in my other detail, which have ATS shader attached for wind simulation.

    - Yes, what I mean is the vertex movement, which is the reason why I am using ATS shader, but at a certain point, the movement jumps suddenly, like a "snap". Snap is a usual term in animation field, although your shader doesn't do animation in fact, I am using "animation" just to figure out the vertex movement.

    Thank you again! :)