Stylized Grass Shader

by [email protected]

This is a paid asset, but now you can download Stylized Grass Shader Free.

Detail this asset from Unity Store: Original Link

Stylized Grass Shader v1.1.6 (Latest version)

Download Now

Stylized Grass Shader v1.1.5

Download Now

Stylized Grass Shader v1.1.4

Download Now

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

It is expected you already know what the Universal Render Pipeline entails, and have already converted your project to it.

Full compatibilty details are outlined here.

All content is authored for the linear color space.

Setup

If the Universal Render Pipeline isn’t installed, or outdated, you will be automatically prompted to do so.

Ensure your project is in fact using the Universal Render Pipeline. Go to Edit->Project Settings->Graphics to check if a pipeline asset has been assigned (it may be named differently)

Examples

The _Demo folder contains two demo scenes that showcase the shader in action. This is a good place to try and experiment with the different shader parameters.

The Prefabs folder contains several grass and bending prefabs which you can use right away.

This is arguably the most accessible method, and does not require any third-party tools. However, it is important to understand that the grass/detail object system does not support meshes with custom shaders. It’s designed to use the built-in grass shader. To get around this, add a grass prefab as a “tree” instead. This way you can paint grass using the terrain tools.

If you’re using navmeshes then this method is not advised, since trees placed through the terrain system are automatically marked as navmesh obstacles. Meaning that navmesh agents won’t able to navigate through grass (placed as trees). Though, using Unity’s “Navmesh Components” system gets around this issue entirely.

The Unity vegetation system hasn’t been updated in a nearly a decade, and is no longer up to modern standards. It won’t deliver high performance when grass is placed in large amounts. For example, 20.000 grass instances on a 1x1km terrain in a test project took up ~25ms of CPU/GPU time, meaning a steady 60 fps framerate was no longer possible. Using this system, grass has to be placed sparingly.

In URP 7.5.1 and older, there’s a bug in that causes shadows flicker when using either the Distance Fading or Perspective Correction feature, in conjunction with the terrain vegetation system. This has meanwhile been fixed in URP 8.1.0+
Pros:

No need for 3rd party tools
Used by tools like MapMagic, Gaia and Vegetation Spawner
Cons:

Not optimized for dense grass or large amounts
Grass can’t align to terrain surface and will stick out on hills/slopes.
No options for random scale, rotation or density
Changes to materials won’t apply unless the “tree” prefab is refreshed
Placing grass as GameObjectsBy dragging a grass prefab into the scene you’ll have full control over it, just like any other object. It goes without saying that placing a piece grass one by one is not an option. For this reason you can use any prefab painting tool, such as PolyBrush.

Note that populating a scene with a large amount of individual GameObjects will increase CPU load, scene file size and loading times. So the amount of grass you can place is limited by how much performance legroom your project already has in this area. The shader uses GPU Instancing, so drawcalls in any case will fortunately be limited: one for depth, lighting and one per shadow cascade.

This method is definitely not recommended for large terrains, spanning open fields of dense grass.

Pros:

Prefab painters usually apply random scale/rotations.
Easy to manage to like any other GameObject
Material changes are directly visible
Meshes can be used with Occlusion Culling
Cons:

Has to be manually placed or painted
Requires CPU resources for maintaining the individual GameObjects
Nature RendererNature Renderer uses the terrain’s tree and details data, but renders everything using its own system. It allows you to use the terrain vegetation system as you would normally, but get all the modern rendering methods required for high amounts of vegetation (GPU instancing, cell-based and frustrum culling). As a result, this would work with other systems that spawn grass on terrain such as Gaia or Map Magic.

The grass shader is compatible with its “Procedural Instancing” technology. See the third party integrations page for more details.

Pros:

No change in workflow (grass prefabs can be used with the terrain detail system)
Renders large amounts of grass at relatively fast speed
Material changes are directly visible
Aligns grass to terrain surface
Stylized Grass supports its wind controller and “Procedural Instancing” system.

Related Posts

Leave a Comment