Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[Released] Stylized Grass Shader (URP)

Discussion in 'Assets and Asset Store' started by StaggartCreations, Jan 5, 2020.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023

    A shader focused on delivering stunning visual and tactile grass for the Universal Render Pipeline (7.2.0+).

    Key features
    • Lush wind animations
    • Per object and per vertex color variation, breaks up visual repetition
    • Bending and flattening through trails, objects or particle effects
    • Translucency rendering
    • Color blending with terrain surface (supports tiled setups)
    • Includes several grass models and textures designed for mass placement.
    • Compatible with all URP rendering features
    • Physically-based or simple shading mode
    • Full Vegetation Studio (Pro) integration
    • Nature Renderer support

    Performance
    SRP Batching compatible
    • GPU Instancing and Instanced Indirect ready, for use with Vegetation Studio (Pro) or custom renderers.
    • Expertly crafted hand-written shader, for optimal efficiency.

    Compatibility
    This shader is designed for the Universal Render Pipeline and is not compatible with the built-in, LW or HD render pipeline.

    Compatible up to Unity 2020.1 for PC/MAC/Consoles. Mobile and WebGL are not supported.

    Limitations
    • Not a grass placement/population tool (documentation includes tips)
    • Does not work with Unity terrain's grass system (outdated)
    • Static batching breaks per-object randomization
    • Color blending feature requires a texture to be baked so has limited compatibility with huge (+4km) landscapes.

    Note: flowers, rocks and trees not included
     
    Last edited: Feb 14, 2020
    phil_lira, osss, Mauri and 2 others like this.
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    This thread is intended as a platform for questions or asset support. Posted ahead so I can include the link in the documentation.

    Actual package will go live in a few days :)
     
    Neviah likes this.
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,558
    Looks amazing! Will check it out in a few days when its live
     
    StaggartCreations likes this.
  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Lars-Steenhoff and KeithBrown like this.
  5. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    I've publicized my Trello board: https://trello.com/b/LhyoTXga/stylized-grass-shader

    Short term:
    • Layer system for benders (controls which benders draw on top)
    • Shader Graph nodes (allows usage of many of the features in a custom shader)
      • Wind animation
      • Hue variation
      • Bending
      • Translucency
      • Color map sampling
    • Color map rendering from mesh terrains (probably already works, but wasn't tested)
    • Mask wind tint in shadows (it represents a sun light sheen, so this is better suited)
    • Custom color map texture (eg, terrain lightmap or exported from external terrain tools)
    Long term:
    • Scale grass based on terrain textures (creating the necessary data is rather complex, at least in a fast way)
    • LOD crossfading (code is already there, but crossfading seems bugged in the URP at the moment)
     
  6. ForRiver4Game

    ForRiver4Game

    Joined:
    Nov 22, 2017
    Posts:
    3
    will be support mobile in furture?
     
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    It's currently not advertised as supported since it hasn't been tested on Android/iOS, but it could work. But mobile support is outside of the scope for the time being.
     
  8. ForRiver4Game

    ForRiver4Game

    Joined:
    Nov 22, 2017
    Posts:
    3
    when i import the asset, using the Universal Render Pipeline, should i enabled SRP Batching ?
     
  9. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Not necessarily, the shader supports SRP Batching in case you choose to use it for your project entirely. It's mostly beneficial if you use many different materials but with the same shader.
     
  10. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    133
    Been waiting for this for some time, very excited to try it!
    It looks absolutely fantastic.

    Is Vegetation Studio needed to get good performance or will it work well without it?
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Thank you!

    Vegetation Studio isn't necessarily required, but a GPU Instancing system will yield the best performance at large scales. This could be Vegetation Studio, Nature Renderer, GPU Instancer, or any custom systems. The documentation has a section which outlines several methods for placing/rendering grass: http://staggart.xyz/unity/stylized-grass-shader/sgs-docs/?section=placing-grass
     
  12. aheartfulofgames

    aheartfulofgames

    Joined:
    May 19, 2014
    Posts:
    32
    Hi,

    we are using this asset in our current project and we are very happy with it. However, there is some feedback that might increase usability and compatibility with Nature Renderer in some scenarios.

    Mostly, when using the shader as a grass replacement shader in Nature Renderer, the textures the grass was painted with in the Unity Terrain is not used (the texture in the replacement material is used). This makes unworkable the workflow of painting grass using the Unity Terrain system and overriding it with Nature Renderer. Right now NR's override is slower than using grass detail meshes, so it's not a big deal until NR improves non-mesh grass performance (we are using grass detail meshes) but having the shader work as a grass override shader would be beneficial long term, we think.
     
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Thanks for the tip! I checked out NR's "Billboard Grass Material" and it appears that the billboard mesh that's generated isn't going to work with the shader. Namely because there are no vertex colors, and the normals aren't pointing up. These are vital for the shading and animations to look correct.

    I don't know if Nature Renderer is creating these meshes, or the Unity terrain is. In case of the latter that's unfortunately a show stopper, as nothing could be changed about that. But I'll reach out to the author to touch base :)
     
    Lars-Steenhoff likes this.
  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Submitted version 1.0.1

    Added:
    - Grass Renderer component now has a WindZone field. When enabled, ambient and gust strength are influenced by its "Main" value

    Changed:
    - Wind tint is now masked by shadows
    - Translucency effect now fades out when Directional Light approaches to the horizon
    - Shader UI will show warnings about reflection settings when incompatible scene lighting settings are used

    Fixed:
    - Tiling/Offset values for normal map had no effect
    - Color map rendering from mesh terrains can now automatically calculate the correct render area size

    Next update will focus on adding Shader Graph nodes, and the sorting layer option for grass benders. I'll be traveling next week, so I'll only be able to get back to any messages once I'm back.
     
    Lars-Steenhoff likes this.
  15. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    72
    Hey @StaggartCreations, sorry for the delay but I finally put up a review (5 stars of course). I'm been extremely happy with the asset and am excited for any additional features (layered benders being the most).

    I was really happy to see separate flatten/push options, and the distance fading is GREATLY appreciated! Thanks again for such a well-thought out package!
     
    Last edited: Jan 26, 2020
    Lars-Steenhoff likes this.
  16. Visual-Design-Cafe

    Visual-Design-Cafe

    Joined:
    May 23, 2015
    Posts:
    404
    Nature Renderer is creating the meshes for those! Your grass looks great and I'd be more than happy to make an integration for Nature Renderer so that the meshes are created correctly for your grass shader. :) Could you send me a PM or email (support@visualdesigncafe.com) with details on what data your shader requires?
     
    Lars-Steenhoff likes this.
  17. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    72
    Hi, I'm actually using my own custom meshes with the shader, and the only adjustment was to make sure all normals faced straight up.
     
  18. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Thank you for your candid review, it is very much appreciated!
    That's a relief! Happy to hear you're willing to add an integration, I'll be in touch and send you the package with the necessary details.
     
  19. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Since URP 7.2.0 was released some of the behavior around shadow cascades was changed. Currently, the grass will show a dark line at the cascade edges. I'll need to investigate how to correct this.

    I'm a little strapped for time due to GDC coming up, but I'm aiming to update the package by the end of the month.
     
  20. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    640
    Is that cascade thing a reported bug? I'm getting that as well with 7.2.0.
     
  21. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Not that I'm aware of, it should only affect custom shaders. Turns out coordinates for the shadows now have to be calculated per-pixel when shadow cascades are used. Previously this could be done on a per-vertex basis.

    PS: Fix is now live on the asset store
     
    transat likes this.
  22. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    133
    Just upgraded to the latest version on the asset store and got this error in the Console:
    (Unity 2019.3.0f6)

    Assets\Stylized Grass Shader\Scripts\DrawGrassBenders.cs(20,21): error CS0246: The type or namespace name 'ProfilingSampler' could not be found (are you missing a using directive or an assembly reference?)

    Upgrading to 2019.3.1f1 now to see if that makes any difference.
     
  23. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    The ProfilingSampler class is something that was introduced in the URP 7.2.0, which is now the minimum required version.

    You can update the UniversalRP package through the Package Manager window which will clear the error. If you do not see version 7.2.0, you can click the arrow left of the package which will show all available versions.
     
    LukasIrzl likes this.
  24. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    133
    Ah I see, thanks!

    I can't make 7.2.0 show up in the package manager, but I'll do some research to find out why that is the case.
     
  25. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    It may be hidden for some reason, it should appear in Unity 2019.3.0f6
    upload_2020-2-15_13-52-51.png

    In any event, you can edit your projects manifest.json file and replace
    Code (CSharp):
    1. "com.unity.render-pipelines.universal": "7.1.8",
    with
    Code (CSharp):
    1. "com.unity.render-pipelines.universal": "7.2.0",
     
  26. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    133
    Thanks for the help, I realized my manifest was using a custom staging server with Unity for some reason. Removed that line in the manifest and it recognized 7.2.0.
     
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    I seem to have made a mistake in last update, the Stylized Grass Renderer component will show an error about the URP not being installed, even when that's the case. If this blocking anyone's progress, you can change line 60 in the StylizedGrassRendererInspector.cs file from #if URP to #if !URP. Version 1.0.3 has already been submitted with this fix and will hopefully be approved soon.

    With this version, translucency rendering has also been improved.
    upload_2020-2-15_14-54-58.png

    The sun light color is now applied through overlay blending, rather than directly. A white directional light on green grass results in a yellow-ish tint, as expected.
     
  28. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    133
    Plugin works great now, but just wanted to let you know that the AlienGrass and GrassTall prefabs are missing their materials.
     

    Attached Files:

  29. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Apparently updates aren't reviewed by the asset store team until next week, if anyone wishes to use the updated version, DM me with your invoice number and send a download link.

    Changelog for v1.0.3

    Changed:
    - Dialog will now pop up when a URP version older than 7.2.0 is installed, with the option to update it
    - Translucency color is now mixed with grass color through overlay blending, instead of directly using the sun color.
    A white directional light on green grass results in a yellow-ish tint, as expected.

    Fixed:
    - Renderer component incorrectly displaying an error regarding URP installation
    - Added missing materials for Alien and Tall grass prefabs
    - Grass bending render area being flipped (Occurs since URP 7.2.0)
    - Error on MacOS when using OpenGL regarding unsupported render texture format

    v1.0.4 will add a sorting layer option for grass benders along with support for grass benders using a particle system in world-space simulation.
     
  30. ShivaGum

    ShivaGum

    Joined:
    Oct 14, 2019
    Posts:
    2
    Hey @StaggartCreations, I'm having some issues.
    As the asset is imported, I get this message.

    However, I already have URP installed.

    I run Unity 2019.3.05f

    I think I missing most of the asset capabilities due to this problem.

    I already tried to click OK in the pop up message but the new installation produces errors.
     
  31. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    The dialog pops up if a version older than URP 7.2.0 is installed, this is the minimum supported version and is available starting from Unity 2019.3.0f6. In a future update (pending review) the dialog also mentions this version, for clarity. Updating to 2019.3.0f6 and URP 7.2.0 will unlock all functionality ;)
     
    ShivaGum likes this.
  32. ShivaGum

    ShivaGum

    Joined:
    Oct 14, 2019
    Posts:
    2
    Now it works perfectly! Thanks. Loved the asset. Gave you 5/5.
    Just one more thing. Is there any way to erase the bottom hard edges of the grass? Either by fading the base or by melting it with the color of the ground.
    Just like this.


    Besides, is there any way to terrain paint grass (with unity tool) tangential to inclined surfaces?
     
    Last edited: Feb 24, 2020
  33. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Awesome, appreciate the review!

    Alpha fading is technically not possible, as grass would not longer receive/cast shadows and would suffer from sorting issues and overdraw.

    Though the grass can blend with the underlying surface through the color map feature, you can find the details here. Currently there is no control over the blending distance. But I'll add a "height" parameter so only the base of the grass can blend with the terrain color.

    The Unity terrain vegetation system doesn't support aligning grass to the terrain, which is a sore miss.
     
    ShivaGum likes this.
  34. MedoMelo

    MedoMelo

    Joined:
    Jul 5, 2019
    Posts:
    38
    Hello there, quick questions,

    - Between Nature Renderer and Vegetation Studio, which one has the best performance? I did some messy tests and vegetation studio has more fps but, as they work slightly differently I'm not sure if I’m right with my test.

    - Also I have some issue to make the grass bend using Vegetation Studio or Nature Renderer. I put the grass renderer script and made a basic sphere mesh bending following your documentation. Is this feature only available through game object? I know you’re currently working on Nature Renderer compatibility update, will it include bending?

    - Last but not least, where can I find the cute and humble rocks you have in your screenshots :)?


    Thanks for answer, have a good day!
     
    Last edited: Mar 8, 2020
  35. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    I never ran the numbers, but both systems are built on the same principles: cell-based instanced rendering. They're built by different people, so one is arguably faster than the other in the same scenario. VS does have a leg up with its instanced indirect rendering, which allows more than 1023 items to be rendered in one batch.

    The bending is performed no matter what method you use for rendering the grass, so will work with both systems. Though this only occurs in the render area, as represented by the white box, any grass benders outside of it will not take effect. You can use the "Follow target" field on the Stylized Grass Renderer component to have the area follow your player or game camera so that bending always applies to the area you're looking at.

    As for the rocks, they're something I made several years ago, I have little attachment to them, so you can grab them here if you like: https://1drv.ms/u/s!AlkpXXlKu-02jrE2zzXDOf8bA7fEuQ?e=dXAw8h :)
     
    Last edited: Mar 9, 2020
  36. MedoMelo

    MedoMelo

    Joined:
    Jul 5, 2019
    Posts:
    38
    I appreciate how fast you answered!

    Got it for VS, for now I will use it but sure both tools are excellent.

    For the bending, I should have forgotten a step because I got the sphere inside the white box. I'm going to double check and read the documentation again thanks.

    (link not working btw)
     
  37. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    If you can't get it to work, feel free to shoot me a message.

    Updated the link, apparently public access had expired :)
     
  38. maarcinn

    maarcinn

    Joined:
    Aug 13, 2013
    Posts:
    9
    Hi,

    @StaggartCreations
    I started using the stylized grass shader in my project. I'm happy with it so far, but I have one problem.
    When I render Color Map from my terrain to get nice grass blending and my terrain is moved somewhere to the side (not in (0,0,0) ), the color map is beaing applied incorrectly. If I understand correctly, the color map is being projected in the center of the world and then it's tiled.
    Is there any way to make it work with terrain object moved?

    Quick example below:
    upload_2020-3-25_11-10-26.png
     
  39. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    The coordinates are being calculated and saved whenever the color map is rendered. If you have the terrain afterwards, it has to be re-rendered to take the new position into account. Moving it around at runtime is not supported.

    Though if you mean it render incorrectly is the terrain is not centered then that's something I'll have to correct!
     
  40. chalogr

    chalogr

    Joined:
    Aug 24, 2016
    Posts:
    5
    Hello. I purchased this asset and works great. However, unity decided to change cascades, as mentioned earlier, and my project's shadows are broken. I'm waiting for a patch because I have no idea how to patch Unity myself. Do you happen to have the earlier version for 7.1.8? I have 2000+ hours on this project and would really appreciate it if you could help me out as this is the only asset that requires the URP 7.2.0 to work, and I've been trying to find a way to solve the cascades but I just can't.
     
  41. maarcinn

    maarcinn

    Joined:
    Aug 13, 2013
    Posts:
    9
    Thanks for the answer. Yep, I had this problem even if I moved my terrain before rendering Color Map :/ Rendered map looks correct, but then it's being projected on the grass in the center of the scene, not in the center of the terrain.
     
  42. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Shadow cascades shouldn't break when updating to URP 7.2.0 since all the URP shaders are updated to support this. Custom shaders (outside of Shader Graph) need to be modified to support this, the required changes are outlined here.

    If you want to stay on 7.1.8 that's perfectly fine as well! You'll actually need version 1.0.0 of the grass shader for this, if you could DM me your invoice number, I'll forward a download link.

    I see, this should be a relatively easy fix. The package is being updated soon, so I'll be sure to include this contingency. Thanks for pointing it out, would probably have gone unnoticed otherwise!
     
    maarcinn likes this.
  43. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Submitted v1.0.4. Change log:

    URP version requirement: 7.2.0+

    Added:
    - Sorting layer to Grass Bender component. Higher layers are drawn over lower layers. Can be used to control which benders should overwrite other benders.
    - Particle trail prefab, as an alternative to using a grass bender with a trail renderer.
    - Color map height parameter, allows the color map to only take effect at the root of a grass mesh

    Changed:
    - Grass benders using a particle system in World simulation space are now supported
    - Grass benders outside of the render area are no longer processed

    Fixed:
    - URP installation dialog not having any effect due to changes in the Package Manager
    - Color map not rendering correctly if terrains were moved away from the world origin
    - (Preemptive fix) Grass bending render area being flipped in URP 8.0.1+ (Apparently was a mistake in 7.2.0)
     
    maarcinn likes this.
  44. chalogr

    chalogr

    Joined:
    Aug 24, 2016
    Posts:
    5
    StaggartCreations likes this.
  45. squallfgang

    squallfgang

    Joined:
    Sep 13, 2016
    Posts:
    9
    Hey there great Grass so far,
    I have two problems:
    1. when I want to use the ColormapRenderer as described here1 there is no colormap available and also the new button is not here. How do I create one?

    2. when I have shadows on the shader activated it looks like theres flickering shadows appearing and disappearing all over the field. Its very annoying. It is destroying the calm visal appearing. is there something I can do about it? I think it has something to do about the grassobjects putting shadows on their neighbours.



    *1 http://staggart.xyz/unity/stylized-grass-shader/sgs-docs/?section=blending-with-terrain-colors
     
    Last edited: Apr 3, 2020
  46. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Already replied to your email ;) I'll submit an update tomorrow that fixes your first point.

    2: Is this using Nature Renderer by any chance? There's an issue when Distance Fading is enabled when using NR. I've discussed this with the author, but it apparently comes down to a bug in the URP. I recall seeing a related fix for this on GitHub, but I couldn't find it just now. For now, the only workaround is to disable the Distance Fading feature.
     
  47. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    Submitted version 1.0.5. Changelog:

    Minimum required URP version: 7.2.0. URP 7.3.1 compatibility verified.

    Note: Color maps have to be re-rendered in order to update their information to a new format!


    Changed:
    - Color map textures are now compressed, resulting in substantial memory saving.

    Fixed:
    - Errors thrown on the ColorMapRenderer component when no ColorMap asset was assigned
    - Bending render area being flipped in URP 7.3.1 (Make up your mind, Unity!)
     
  48. PyroStudios

    PyroStudios

    Joined:
    Sep 23, 2012
    Posts:
    225
    Is there any way to get this working with URP 7.1.8 ?? There is a shadow bug in 7.2.0 so this grass asset looks great, but everything else in my project is broken. So I can't use this asset until every other asset is updated.

    In the future can assets like this stick to "verified" packages only? Unity is breaking too much so being on the cutting edge isn't a viable solution for devs.

    Sadly there's no point is this asset looking amazing, if it can't be used in 95% of projects.
     
  49. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,023
    I understand your stance completely. SRP versions and asset store package has been a recurring pain point for some time now, and unfortunately there's no "right" way of approaching this. Everyone does what they think is best, and this causes fragmentation. So I'll always be marking the minimum supported version on the store page and changelog.

    URP 7.2.0 was an important version, since it introduced support for custom post processing, though broke the use of shadow cascades. This was fixed, and therefore made 7.2.0 the minimum required version. Honestly don't know what I'll do when Deferred rendering comes in 2020.2. Either can't support it at all, or forced to make the minimum required version 2020.2 ¯\_(ツ)_/¯

    To use 7.1.8 you'll need an older version of the package. If you DM me your invoice number, I'll send you a download link. Fortunately, by now I've figured out how to do version-specific shader code, so in the future this asset will support a wider range of versions, until no longer possible.
     
  50. PyroStudios

    PyroStudios

    Joined:
    Sep 23, 2012
    Posts:
    225
    Thank you @StaggartCreations !! I just re-read my previous post and I hope it didn't sound like I was coming down on this asset or you. I actually love the grass shader (that's why I was mostly upset with the whole URP situation). I will send you my invoice because I'll be happy with the older package until the pipeline stuff settles down a bit.
     
unityunity