Stylized Grass Shader
7.Blending with terrain colors
The grass has the ability to seamlessly blend in with the underlying terrain’s color. This can also be seen in many AAA games nowadays.
- If you are using a terrain shader which differs from standard shading (eg toon/flat shading) the color blending cannot be accurate. Both the grass and the default terrain shader share the same lighting model, which is part of which makes the blending possible.
- It works best when the terrain materials don’t have a lot of high-frequency details.
- Glossiness of terrain materials (eg wet stone or puddles) cannot be blended into the grass, since these effects depend on the viewing angle.
- Only one color map can be active at a time, and affects all grass materials globally.
- Because a texture is required to be baked, the maximum viable terrain size is 4x4km, requiring an 8K color map (yielding 2 texels per unit).
The following steps can be followed to set this up:
- Select a GameObject (or create an empty one) and go to Add Component -> Stylized Grass -> Color Map Renderer
- Assign your terrain GameObjects (these can also be mesh terrain tiles)
- Set the size of the render area. Or choose to calculate it based on the total terrain size.
- Click the Render button
In order for the color map to apply at runtime, this
Color Map Renderer component must be present. Alternatively, you can save the color map asset and assign it to an active
Stylized Grass Renderer component.