Search Unity

BendinGrass - Simple interactable grass

Discussion in 'Assets and Asset Store' started by Gufetto, Dec 9, 2017.

  1. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    UPDATE(04/04/2019): BendinGrass 2.1 is out on the store, with some improvements and bugfixes (changelog).


    BendinGrass is a package that allows default Unity's grass to interact with your game objects. It's good for characters, cars, wind, explosions and everything else that should react with the grass. This is useful to make your maps more interactive and give them a nicer look. It may also improve your gameplay, in some cases.
    You don't need to change your already existing terrains or painted details, just import the package and place the components you need.

    Note that at the moment BendinGrass is meant to be an improvement/extension for the Unity grass, so it basically will look the same. If you need a different looking grass, you should probably go for more complex systems.

    Demo
    WebGL: WebGL 2.0 Demo

    Compatibility
    It works on DX9+, GLES3 platforms. However, i do not recommend to use it on mobile, unless you are targeting very high end devices.
    I tested on PC, WebGL and Android.
    I couldn't test it on Metal, Vulkan or consoles, but I think it should work. I will edit if I get any test done.​



    Performances
    It really depends on your target device: powerful platforms easily supports hunderds of simultaneous benders.


    How does it work?
    Just place a GrassBender script on every object you want to interact with grass and edit its parameters, if needed.
    It has 2 modes: Vertex and Permanent mode.
    Vertex mode calculates the bending directly in the grass vertex shader, that means it's faster than the other mode, but won't leave any permanent data, so it is useful for wind.

    The Permanent mode uses a volume map that stores bending data for every cell. This map is then sampled in the shaders and used to displace the grass. This means your objects can permanently displace the grass (or you can just use it to have smoother grass bending animation).

    This video quickly shows different bending settings



    Notice how the grass displaced by the
    blue(low power permanent mode), looks softer compared to the gray one (vertex mode).

    It supports both directional and spherical bending, and you can add some animated noise inside your grass benders. Those parameters are especially good to create local wind volumes, for example an explosion or the wind inside a tunnel.
    Features
    Based on the requests, these are some of the new BendinGrass 2.0 features:
    • Get rid of 3D textures, using more performant 2D textures instead.
      • Now it doesn't require 3DRenderTextures support anymore.
      • It's a lot faster on big maps.
    • Changed the bendmap rendering method, mine should be a little bit more compatible, with very similair performances.
    • Support more platforms :
      Standalone (DX11+/OpenGL 4.5) :

      Consoles: I can't really test on anything, but I'm quite sure it works on DX11(or equivalent) consoles.
      WebGL 1.0: (edit: not limited anymore)
      WebGL 2.0:
      Android (GLES 2): currently not working properly
      Android (GLES 3):
      iOS: -
    • Other performance improvements on the bendingmap renderer.
      • Space partitioning for big maps -
      • Adding multiple draw calls, to support an unlimited amount of benders. -
    • Terrain mode:
      • You can now use an heightmap to optimize performance, in case you only use 1 terrain.
    • Space partitioning:
      • In case of big volumes and many grass benders, you can now use space partitioning to only update and simulate relevant parts of your level, saving some performances.
    • Dynamic volumes:
      • If you only want to simulate only the area around your player, you can now do it.
      • Use less memory and it's usually faster, but discards every bending data outside the volume.
    • Vertex benders (already present in the old version, but now improved):
      • These one are very high precision and does not leave any permanent data, they are expecially useful for wind and other noisy benders.
      • Vertex benders bypass the volume map rendering passes, so there is an hard limit of concurrent vertex benders computed (on older graphics APIs mostly).
      • Mixed mode (permanent + vertex).
    • Chained benders:
      • It may be useful sometimes to have benders that inherit some of their parameters from another one.


    On the Asset Store Page you can find some other screenshots and videos, and you can check the Documentation.
    Keep in mind this is a new asset, so it will contains bugs I wasn't able to find during my tests, also I will consider any (reasonable) suggestion you write in here.
    Let me know if you have any question, suggestion or bugs to report.
    I will prioritize bugfixes from now.

    Have a good day :)
     
    Last edited: Apr 5, 2019
    ManHunterITA and Lars-Steenhoff like this.
  2. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Its cool looking!

    Its written that is does not work on mobile?
    what restricts its use for mobile?

    If using metal with mac / ios / apple tv
    could it work?

    or is there something in the shader that prevents that?

    The asset store link is a bit broken, it has an extra http before.

    thanks for making this available
     
  3. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Thank you for the catch! It won't let me edit it for some reason, but I'll edit asap. To be honest I do not have experience on mobile, especially iOS, but technically it should work if your device supports CustomRenderTextures, introduced in Unity 2017. However I tried it on my 4 years old Android and performances were kinda bad. I'll do some research and let you know more about mobile.
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    mostly interested in recent devices iphone 7 and up
     
  5. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Sent you a PM
     
  6. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    339
    Hello,i have 3 questions about your plugin.

    1.will the large terrain hit performance problem?
    ex:10km*10km terrain.
    as i see in the video your test scene is very small.

    2.will the large terrain make the bending area too big?
    i guess the minium bending area will based on the size your rendertexture's pixel projected to terrain.
    or you just project the bending rendertexture to a small area of big terrain?

    3.if i target the highend android device like galaxy s7/8 ,will it work?

    thank you.
     
  7. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    1. Yes, performance will be a big problem on such a big simulation area. Computation time is good on relatively small grids, but it grows a lot as you increase the resolution. However I'm planning to add dynamic volume support, which will simulate only the area around your player and discard everything else.

    2. It depends on the grid resolution you use. Keep in mind that I use a 3D grid mapped on a 3D RenderTexture, for the update on the GPU. I'm using 3D volumes, instead of 2D textures projected on the terrain because I'm planning to release other shaders that are not bound to the terrain.

    3. Can't really tell for sure, but I think it won't work. It works on DX11/OpenGL 4.5 and your device has to support 3D RenderTextures. Honestly 3D render textures are just causing me compatibility problems on non DX11 platforms, I will have to use an alternative method, like packing the volume slices on a 2DTexture.

    So at the moment it is usable only on DX11 platforms like pc or console.

    Note that I'm talking about the high quality effect (the permanent one), not the cheap one, which is done directly into the vertex shader.
     
  8. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    339
    Thanks for explaining.
    It's a pity it's not good for large scene and mobiles.
    The dynamic volume sounds very promise i would keep waiting for it.
    Most grass touch bending system in assetstore are very heavy or use other way to render grass and trees.
    What you are making is really useful.
     
  9. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    I actually almost finished the 2D packed texture thing, to get rid of volume textures. I am actually very surprised by how much faster it is now.
    It's atleast 20x faster on my scenes.
    I tested it with 5 benders, on a 3000x100x3000 cube(with a decent resolution), which is now processed in 1 draw call (it was 80-100 on average before), and I was able to get 60 fps until I started to use 8k textures, which was just an overkill anyway.
    The only problem now is that I have no efficient way to render the benders into the bendingmap, so every bender increases the rendering time by a lot. I'll have to think about a good way to do this now, even tho is not a problem at all for small grids, it can easily become a bottleneck on big maps.

    Also, I got it to work on shader level 3.0 on Windows, but at the moment the shader does not compile when I build for Android, for some reason. I'll try to investigate more in the next days.
     
    Last edited: Dec 25, 2017
  10. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Does this works on webgl??
     
  11. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    The current release works only on DirectX 11/12 and OpenGL 4.5 (it need Shader Model 5.0, WebGL uses 3.0/3.5 from my tests), however I'm currently working on a big update, and hopefully it will support a lot more platforms. Will eventually add a table with supported platforms after that.
     
  12. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    After a lot of work I finally made it work on OpenGLES 2/3. Even tho it has to support a limited amount of grass benders.
    I had to write my own bendmap renderer, replacing the Unity's CustomRenderTexture. I still didn't test it well, but it seems to have basically the same performance as the old one.
    These are the platform I tested, I added in the OP too:
    OpenGLES2 (Shader level 3.0)
    WebGL 1.0 ✓
    Android ✓​
    OpenGLES3 (Shader level 3.5)
    WebGL 2.0 (Firefox/Chrome) ✓
    Android - As strange as it sounds, it does not work properly here. The bendmap only scene works fine, but when I try to build the app including the terrain, it just crashes with an error in the logcat not even related to unity. The same scene works on GLES2 tho. I will have to test it on a different phone.
     
  13. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Some news for people interested: I improved the volume bendingmap renderer, it now has no hard limit on the supported number of grass bender objects, because it is now able to batch them in multiple draw calls. Also, it now supports space partitioning, to improve performances on big levels. At the moment it updates a 5000x5000 flat terrain (at a decent resolution) with 70 characters in about 1ms, or a 1000x1000x1000 area in 2ms. I don't think I can improve much more on this side.

    The only "problem" now it is that the texture which contains the permanent data quickly becomes too large for big terrains (>2k). This is not a big problem on pc and consoles, but it surely is on mobile, so it's probably time to implement the dynamic volume I was talking in a previous post.

    Supporting an heightmap would be a good optimization too, as you will probably never use the space under your terrain(for example inside the mountains) or 5m+ above the terrain level. You can easily exclude the space you don't want for almost flat terrains, but you can't do it for a terrain with big mountains. Using the terrain heightmap would solve this. I'm also considering doing this.

    Hopefully after this I can polish things a little bit, create custom editors, update the docs, then release the new version.

    TL;DR : More benders supported, better performances in extreme situations, will do a couple more things and then release the new version.

    Also uploaded a preview WebGL demo of the new version.
     
  14. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    looks good, any chance of doing this for other grass packages? i'm using advance foliage system because unity grass creates spikes on the game, but AFS does not allow for touch bending. I'm sure it's a shader trick.
     
  15. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    I can't do it directly, because that would mean I have to release a modified version of their package, but I can include the instructions to implement it in every shader you want (it's probably 1 include and 1 function call in most of the cases).
     
  16. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
  17. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    You obviously still need the whole BendinGrass package, or the bending won't work. It comes with a .cginc file (which is currently used in my shaders), you can include it in any other shader you want, then use the function it provides to displace a vertex, it should be easy. After the new version release, I'm gonna deal with this, at the moment I have to solve more important issues first.
     
  18. kepesh

    kepesh

    Joined:
    Dec 29, 2017
    Posts:
    92
    This is looking promising. Any news on development?
    Does this work with TerrainComposer 2?`
     
  19. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    did you ever get to work on it?
     
  20. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    I was busy with other things lately, but the new version is basically ready, but I still have to write a new documentation, videos and examples. Hopefully I'll release it this month.

    Not sure how TerrainComposer 2 works, but if it uses unity grass shader it should work.

    Implementing it in other shaders requires some changes in their code.
    I obviously can't include other people's work in my package, but I will include instructions on how to implement BendinGrass on other shaders.
    As I already said, it is really easy to do, should be just 1 function call in the vertex shader in most of the cases.
     
  21. Quakeulf

    Quakeulf

    Joined:
    Mar 26, 2013
    Posts:
    40
    Let's say I have a 55 square kilometer terrain of which will sparsely use this to render shrubbery like the Mojave desert does for Creosote bushes. Would this work? I am planning on using it along with a shader that "masks" the draw distance of the objects.
     
  22. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Yes, the new version will probably work fine for you.

    I'm currently rewriting the documentation and cleaning the code a little bit. Then I'll have to do videos and examples. After that I can submit it to the asset store.
     
    Xoduz likes this.
  23. Xoduz

    Xoduz

    Joined:
    Apr 6, 2013
    Posts:
    135
    Sounds very promising :)
     
  24. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,294
    I have a feature wish and that is a that the grass can be setup so it will bend back after some seconds.
    To support you i will buy it today.

    Edit:
    Better would be that the grass will bend back after x,y seconds with random range to xy% with a random range.

    So for example after 3.5 to 4 seconds every grass will bend back between 65% and 85%.
    That would be great because you see the trace from a character true the grass and it looks natural while it bend back up and more random at the end.
     
    Last edited: Jun 15, 2018
  25. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Thank you for the suggestion. At the moment it is very close to what you described, except that you can't define the time in seconds, but it's more like an interpolation factor for the grass springness.
    About the "bend back" position, I think using a value range is just overkill, because it would need to store another volume map, that contains the target % for every grass chunk. Also there is noise anyway on the grass, so it would barely be noticeable. Currently there is just a fixed value.

    While I'm here:
    Since the last post, I worked on another suggested feature, which honestly it should have already been in the package: dynamic volume simulation.

    You can now simulate only the area around your player, discarding everything else that is outside. While it pratically doesn't change anything on small levels, it is an huge improvement in performance/precision for large levels. Yesterday I realized that one of the last changes kinda broke the WebGL (and I guess GLES2/3 in general) support, so I'm currently dealing with this.

    I also updated the OP with all the new features I added in the last months.
     
    Last edited: Jun 16, 2018
  26. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Quick update: after restoring the GLES support, I started to work on performance improvements and I reached a good result. Also found and fixed A LOT of minor bugs, mostly related to the latest features. Meanwhile I also introduced a new feature, that I think it will be useful to some of you: it is now possible to set one bender to inherit some of its parameters from another one.

    That said, I submitted the new version to the asset store yesterday, currently it's waiting for review. After the new version is out, I will stop to work on new features for a while, and just focus on bugfixes, so please submit bugs if you find any. I will update the OP when the update is ready.
     
  27. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    BendinGrass 2.0 is now on the Asset Store! Please let me know if you find bugs or need help.
     
    Xoduz likes this.
  28. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    119
    Hi! Great asset - does this work with Map Magic or GPU instancer do you know?
     
  29. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Hi, out of the box it only comes with support for the standard unity grass, for obvious reasons. However, you can easily implement it in other shaders, as long as you have access to the source code. There is a section inside the documentation for that, but i can also help you via discord or email if you need.
     
  30. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Hi,
    I've bought this asset, and it does not seem to work with Map Magic - can you confirm?
     
  31. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Hello! As I replied to the other guys who asked:
    It only support Unity grass by default. You have to manually implement it in other shaders, if you want it to work. I wrote instructions in the Documentation about that, it's quite an easy process.

    If you already tried that and it's still not working, then you can contact me (email/discord) and I will help you.
     
  32. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    212
    can you build a demo apk for mobile with open gl es 2 and 3?

    Thanks
     
  33. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    I just noticed that one of my latest updates broke support on gles2 again. I am considering dropping the support for it to be honest. At some point i feel like i'm just wasting my time trying to get it to work on old devices that would probably not be able to run it at decent framerates anyways.

    However, works fine on gles3, although the example scene is not meant to be mobile friendly and fps might be horrible, i just added some mobile controls: GLES3 build
     
    Last edited: Oct 19, 2018
    creat327 and lolclol like this.
  34. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Update: Version 2.1 should be out soon on the asset store. Thanks to all the people who provided feedback via email or discord!
    Not a very big update, but contains some improvements and bug fixes. I also set up a changelog page, just to keep track of the changes.
     
    ManHunterITA and Lars-Steenhoff like this.
  35. TreyH

    TreyH

    Joined:
    Feb 6, 2014
    Posts:
    16
    Does this work with the lightweight render pipeline?
     
  36. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    the problem with dropping opengl2 is that about 1/4 of devices still depend on it and it doesn't seem to be able to detect that on runtime. Like it would be nice if at runtime we were able to disable this package if it doesn't support it. But I don't see how.
     
  37. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Good question, never really got into the new rendering pipelines yet. The only thing that I suspect it might cause problems is the actual grass shader. The volume map generation should still work. At the moment I honestly wouldn't recommend to use it with the new pipelines (if you already bought it and it doesn't work let me know). I might want to give it a try soon.

    That's for sure a problem I need to address in the next update. I can't promise anything, but I will at least try to make it work on gles2 again. If I can't make it work I'm gonna disable the problematic parts on that specific API, so it won't give a shader compile error or crash the application.
     
  38. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Greetings,
    I am trying a few different grass shaders including this one, but like the others, this does not appear for me in my project in WebGL. I am building for WebGL2.0 but I can't seem to get it to work like you did in your WebGL-demo.

    What hidden or other specific build options or settings did you use to get it to work?
     
  39. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    since may waiting for an update for opengl 2 support... no news yet :(
     
  40. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Hello! I'm sorry it isn't working for your project :(

    Could you please provide more informations about the problem? What do you mean by "does not appear"? Is the grass not rendered at all? Or it's just static?

    Maybe it's a specific combination of features? What are you using in your scene? (terrain mode, moving volume, permanent/vertex mode, space partitioning, etc.)

    I don't quite remember if I used any specific setting for the WebGL demo, but it shouldn't really matter. I can remember though that my browser did not want to run with WebGL 2.0 unless i completely removed the WebGL 1.0 option from the API target list. I doubt this is your case, but might be worth a try.

    I just tried to build the demo scene again on WebGL 2.0, tried on Firefox and it works just fine.

    I'm sorry, i've been busy with another project since then and don't have much time to spend on an actual bendingrass update. I don't really wanna drop the ES2 support, so the goal is still to try and fix it.

    However, if you want, you can contact me in private, or via discord/email and i'm gonna help you disable it on problematic devices, which should be far easier and faster.

    Discord : https://discord.gg/WhHSPfy
    Email : rompipapera@gmail.com
     
  41. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Sorry for being unclear, but it was me not understanding the limitations of WebGL. Thanks for helping out. :3
     
    Gufetto likes this.
  42. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    After some months, I finally managed to submit a new update to the Asset Store. It is currently waiting for review, but it should be up soon.
    • Now includes an Universal Rendering Pipeline version.
    • Since I couldn't manager to make the whole thing work reliably on older devices, you can now disable specific graphic APIs.
    • Also an important TerrainData conversion tool, that was needed because some users were having problems using BendinGrass on already existing terrains on some Unity versions (and also useful to swap URP shaders).
    Other than that, it is mostly small improvements and fixes requested by the users.
     
    Lars-Steenhoff likes this.
  43. ansjuan

    ansjuan

    Joined:
    May 15, 2018
    Posts:
    21
    Hello, I have a question, would this work with mesh grass? I mean, grass consisting on actual meshes instead of billboards?
     
  44. Gufetto

    Gufetto

    Joined:
    Oct 19, 2015
    Posts:
    29
    Hello! Yes, it works with detail meshes.