Stylized Grass Shader 1.3.0 upgrade guide

Version 1.3.0

Support for Unity 2019 and URP 7 have been retired as of now. No backwards compatibility has been removed, but these versions are no longer supported or developed for.

This version update mainly revolves around refactoring the grass bending feature, in terms of performance efficiency. This was first developed in late 2019, based on little to no information about how the Universal Render Pipeline works. Come 3 years, and a lot of research later, it became clear there were more efficient ways to go about it.

New features:

  • Reworked grass meshes and textures for improved shape and density
  • Added normal maps for all grass textures
  • Options for near+far camera fading (though dithering)
  • Masking Sphere component. Fades out the grass towards a single point, with a given radius.

Improvements:

  • Reduced CPU overhead: 0.01ms, as opposed to 0.12ms for one particle system.
  • Rendering now benefits from native frustum- and occlusion culling
  • Trail Renderers no longer hammer the CPU (previously up to 1ms).
  • The Alpha Blending option on Grass Bender components no longer breaks the height-checking capabilities (eg. a mesh floating over the grass, yet still pushing it down)
  • Grass Bending geometry will now render using the SRP Batcher (if enabled)

Other changes:

  • Reworked Material UI to support Material Variants (introduced in Unity 2022.1). This will unfortunately reset some material parameters to their default values, a necessary evil.
  • Support for dynamic wind speeds
  • Added normal maps for all the included grass textures
  • Improved grass meshes. Doing away with the traditional cross-shape

Upgrading

Project preparation

Unity packages will only track changes to existing files, or the addition of new ones. They however can’t delete or move files.

Importing

Before importing version 1.3.0 from the Package Manager, first delete the following folders:

  • Stylized Grass Shader/Scripts
  • Stylized Grass Shader/Shaders/Resources

Failing to do so will cause new scripts to be imported in the wrong folder, and creates a duplicate assembly definitions. You’d see the following errors:

If you forgot this step, you can still delete these folders. Just be sure to reimport the asset from the Package Manager afterwards.

Should you still see the 3rd error: right-click on the Stylized Grass Shader/Shaders folder and choose “re-import”.

Setup

The processing of grass bending now happens through a render feature. If you have a Stylized Grass Renderer component set up in your scene, a error message will inform you that this render feature hasn’t been set up yet.

Simply click the “Add” button to automatically add the required render feature to the default renderer.

Alternatively, add the “Grass Bending Feature” render feature manually.

Breaking changes

As is the case with any piece of software, some times bandages have to be ripped off in order to facilitate improvements or new features.

Grass Benders may turn invisible

Previously, it was possible to use a Renderer (Mesh Renderer, Particle System, Trail/Line Renderer) for both normal rendering as well as grass bending. For instance, the sphere mesh in the demo scene, that represents the player.

Now, a Renderer used for grass bending must stand on its own.

Using the Grass Bender component will cause the renderer to turn invisible to normal rendering…

Material properties being reset

The material UI was partially reworked to support the new Material Variants feature introduced in Unity 2022.1. The changes required mean the following parameters will be reset to their default values, and will affect the appearance of existing grass materials.

It may be required to re-tune any custom grass materials you have created:

  • Normal parameters
  • Distance fading parameters (including the toggle)
  • Environment reflections toggle

For Vegetation Studio Pro prefabs, it will be required to refresh them!