Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Assets [WIP] Stylized Grass Shader (Universal RP)

Discussion in 'Works In Progress - Archive' started by StaggartCreations, Sep 7, 2019.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    I'm working towards a release version of this shader. Currently rewriting it without Shader Graph for maximum efficiency and control. Minimum compatible version is currently set at Unity 2019.3. It is specifically built for the Universal Render Pipeline.





    Store page draft:

    Key features
    • Lush wind animations
    • Per object and per vertex color and wind variation, breaks up visual repetition
    • Bending and flattening through trails, objects or particle effects
    • Color blending with terrain surface (supports tiled setups and mesh terrains)
    • Includes several grass models and textures designed for mass placement.
    • Full Vegetation Studio (Pro) integration

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

    Compatibility
    This shader is designed for the Universal Render Pipeline (7.0.0+) and is not compatible with the built-in or HD render pipeline.

    For PC/MAC/Consoles. Mobile, WebGL and VR are not supported.

    Limitations
    • Not a grass placement/population tool (docs include tips)
    • Does not work with Unity terrain's vegetation system (outdated)
    • Not suitable for static batching (breaks per-object randomization)
    • Color blending feature requires a texture to be baked so has limited compatibility with huge or runtime generated landscapes.
     
    Last edited: Sep 20, 2019
    BIGTIMEMASTER, Slaghton and antoripa like this.
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Added a wind gusting effect that locally increases the wind strength and adds a light color tint. Next to terrain color blending, which allows for seamless blending with the terrain surface. There are parameters to control each of these effects.

     
    Squize, Slaghton, eaque and 1 other person like this.
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Reworked all the grass bending features, this can done through meshes, trails or particle effects. I'll be sure to include a demo scene which showcases this.

    Unlike my previous iteration, trails now also bend the grass forwards. And benders hovering over the grass no longer affect it, until they enter the grass. This means you can jump without the grass bending underneath you anyway.

     
    Last edited: Sep 22, 2019
    zmaxz likes this.
  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Added a translucency feature, this simulates light diffusing as it passes through the grass blades. It's also being masked in shadows

    It may sound complex, but it is a rather simple shader operation with a lot of visual gain!

     
    Peter77, zmaxz and Acissathar like this.
  5. zmaxz

    zmaxz

    Joined:
    Sep 26, 2012
    Posts:
    143
    When will this asset be released to the store ?
     
  6. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    I'm aiming to submit it by the end of October (+review process generally takes 4 weeks). The shader features are all there, except for specularity. The documentation is mostly in place, but I still need to tidy up all the scripts/workflow and polish the UI.
     
    RafaelMartin, Acissathar and zmaxz like this.
  7. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    133
    Thanks for the updates @StaggartCreations, I wasn't aware that you already had a thread for this. I have a question about the grass bending/collision, will this be possible through Visual Studio Pro? I know he has his own touch react system but I'd much rather work with your setup.
     
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Thank you for your interest. The package has it's own system to translate objects such as meshes, trails or particles to grass bending. So it won't make use of Vegetation Studio's touch-bend system.
     
    eaque and Noogy like this.
  9. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    Alright, I'm a buyer as soon as it is ready!

    Good job!
     
    StaggartCreations likes this.
  10. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    Will it come with another shader for the rest of the foliage and trees? I would love ot be able to use both your FAE's asset and this grass on our upcoming release.
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    This package will only focus specifically on grass, it's also usable with flowers and plants but the bending has to be subtle, especially for meshes such a ferns. FAE shaders will be converted to URP after I get this out of the door.

    I've had a bit of a data loss disaster so unfortunately my progress was pushed back. But the final stretch includes the bending script components, documentation and demo scene.
     
    Noogy likes this.
  12. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    Thanks you for the fast reply. I will make sure I can convert entirely to URP and if that the case I will do the switch!
     
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Had a few setbacks with Unity bugs, having to track down issues and build workarounds. I suppose this is to be expected since URP is fresh out of the box. There is also a bug present with TrailRenderers that causes Unity to crash, yay. Meshes on the other hand, work perfectly.

    Added features:
    • Bend area masking. Smoothly decrease the bend strength for benders at the edge of the bending area (This is a box that follows the camera or player)
    • Support for Vegetation Studio Instanced Indirect
    • Support for Nature Renderer wind
    • SRP Batching compatibility
    The shader now also has two lighting modes (Simple/Advanced). This is akin to using the Simple Lit or Lit URP materials and supports the same features. This is useful when you're doing a PBR or non-PBR project.

    Focusing on creating a decent looking showcase scene now, with accompanying screenshots and video. In the future I'll be adding Shader Graph nodes, allowing you to create a custom grass shader in a jiffy.
     
    Noogy and mick129 like this.
  14. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    133
    Thanks for the update, @StaggartCreations! Anticipating the package, my game has felt very empty since I lost vegetation in the transition to URP.
     
  15. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    this looks nice, but i don't think grass should bend into ground by simply something small like objects/creatures just walked over it, try to include a script or something to allow only heavy objects to bend grass only.
     
  16. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Thanks for the feedback! The Grass Bender script has a strength and height offset slider, next to flatten and pushing strength parameters. These can be set per individual object, so should provide ample control over how objects affect the grass. For demonstration purposes, a little exaggeration is needed ;)
     
    eaque likes this.
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,297
    Last edited: Jan 5, 2020
    eaque and mick129 like this.