Version: 2021.3
风区(Wind Zones)
使用高度贴图

Grass and other details

A Terrain might have grass clumps and other small objects (such as rocks) covering its surface. Unity renders these objects using textured quads or full meshes, depending on the level of detail and performance you require.

Prior to 2021.2, grass and other details only worked in the built-in render pipeline and Universal Render Pipeline (URP). In 2021.2, Unity introduced instancing details that work with all render pipelines, including the High Definition Render Pipeline (HDRP).

Terrain with grass
Terrain with grass

Terrain details are available in several modes, where each mode has a different use during game development.

Mode 描述
Instanced mesh Unity recommends you use this mode because it’s best suited for most scenarios that require the placement of any number of arbitrary meshes on Terrain.

To add an instanced mesh, select Add Detail Mesh and enable the Use GPU Instancing option.
Vertex Lit mesh Doesn’t use GPU instancing for rendering. Instead, it combines all detail instances into one mesh, which results in simple shading and limitations to the number of instances you can achieve.

To add a Vertex Lit mesh, select Add Detail Mesh and set the Render Mode to Vertex Lit.
Grass mesh Works similar to the vertex list mesh, but Unity treats these meshes as grass so they always have up-facing normals and move in the wind.

To add a grass mesh, select Add Detail Mesh and set the Render Mode to Grass.
Grass Texture Lets you create grass quad meshes directly from Texture, which move in the wind. You don’t need to specify any custom meshes, and there’s also an option you can enable to make grass quads always face the camera for a billboard effect.

Select Add Grass Texture for this option.

Paint Details

To enable grass and detail painting, select the Paint Details button on the Terrain Inspector toolbar.

Terrain Inspector 中的 Paint Details 按钮
Terrain Inspector 中的 Paint Details 按钮

Initially, a Terrain has no grass or details available. In the Inspector, click the Edit Details button to display a menu with the Add Detail Mesh and Add Grass Texture options. Click either option to bring up a window that lets you choose Assets to add to the Terrain for painting.

Add Detail Mesh

Add Detail Mesh 窗口
Add Detail Mesh 窗口

Use the Detail Prefab field to select a Prefab from your Project. To create an authentic look, each mesh is affected by a random factor to determine the size and color. Unity uses the Perlin noise algorithm to generate such random factors.

The Min Width, Max Width, Min Height, and Max Height values specify the upper and lower scalings along the X and Y axes with which the meshes are randomly generated.

The Noise Seed setting sets the random number generator seed. Each seed value represents a unique generation. If you set the same seed for two types of details, the generated instances become identical. The Noise Spread value refers to the scaling of the noise pattern over the X-Z plane, with higher values indicating more variations within a given area.

The Hole Edge Padding (%) setting controls how far away detail objects are from the edge of the hole area. For more information, see DetailPrototype.holeEdgePadding.

Healthy Color and Dry Color settings control the color variation. Unity performs linear interpolation between the healthy and dry colors, and selects a color based on the size of the mesh. For example, the system considers bigger-sized meshes to be healthier, thus the linear interpolation results for such meshes lean more towards the Healthy Color tint. These color settings disappear when you select Use GPU Instancing because they have no effect on instanced meshes.

You can set the Render Mode to Vertex Lit or Grass.

Render Mode 描述
Vertex Lit Renders detail meshes as solid, vertex lit GameObjects in the scene, which don’t move in the wind.
Grass Renders detail meshes in the scene with simplified lighting similar to Grass Textures, and do move in the wind.

Use GPU Instancing

In addition, you can specify if you want to use GPU instancing to render your detail meshes. With GPU instancing, Unity uses the material and the shader specified on the prefab for rendering. This lets you perform more customization in the shader, and potentially use Shader Graph.

Unity still applies the Width and Height noise to each instance, but disables the Healthy Color/Dry Color noise. You can use your own color variation technique, along with many other randomizations, in the shader.

Under the hood, some of the Unity GPU instancing limitations do affect rendering. For example:

  • Your target platform needs to support GPU instancing.
  • Your shader must support GPU instancing. (Most shaders do support it.)
  • Objects are rendered in batches of 1,023 or fewer.
  • Instanced light probe lighting or lightmap lighting are not supported.

Unlike regular instancing where Unity dynamically builds up the instancing constant buffer every frame, instancing details have persistent constant buffers for better CPU and GPU performance when the target hardware allows for it, at the cost of moderately increased GPU memory usage.

If you select Use GPU Instancing, the Render Mode setting becomes grayed out and unavailable.

Add Grass Texture

Add Grass Texture 窗口
Add Grass Texture 窗口

The Add Grass Texture window

Detail Texture is the Texture that represents the grass. You can download Textures from the Asset Store, or create your own Textures. A Texture is a small image with alpha set to zero for the empty areas. Note that “Grass” is a generic term; it is possible for a Texture to represent flowers or man-made objects such as barbed wire coils.

The Min Width, Max Width, Min Height, Max Height, Noise Seed, Noise Spread, Hole Edge Padding (%), Healthy Color, and Dry Color settings work the same as they do for meshes, and are described in the Add Detail Mesh section above.

Finally, when you enable the Billboard option, the grass images rotate so that they always face the Camera. This is useful when you want to show a dense field of grass because clumps are two-dimensional, and not visible from the side. However, with sparse grass, the rotations of individual clumps might become apparent to the viewer, creating a strange effect.

Remove details

To remove a detail, select the detail to remove, click the Edit Details button, then select Remove. When you remove a detail, Unity clears the data that represents the Terrain area on which you scattered that detail.


  • 2021–11–24 页面已修订
  • Added information about instancing details
风区(Wind Zones)
使用高度贴图