Add trees to the terrain
Add trees with the Paint Trees tool.
阅读时间5 分钟最后更新于 24 天前
Use the Paint Trees tool to place trees on the terrain and customize their painting. You can paint trees with a brush or mass place trees across the entire terrain tile.
As an example, use the free Unity Terrain - HDRP Demo Scene, which has six SpeedTree models. You can also create trees with the Tree Editor (for the Built-In Render Pipeline).
The Paint Trees tool
To access tree painting:
- In the Hierarchy window, select the terrain.
- In the terrain’s window, from theInspector
?
toolbar, select Paint Trees.Terrain?
Select trees
To add trees to the terrain, add a tree prototype to the Paint Tree tool:
- Select Edit Trees > Add Tree.
- Select a tree.
The Add Tree window has different options based on the tree you're adding:
-
Bend Factor: Adjust the tree's responsiveness to the wind in the scene. Trees from the SpeedTree Modeler don't have a Bend Factor; only Tree Editor trees do. Refer to Animate trees with Wind Zones for more information.
-
NavMesh LOD Index: SpeedTree uses level of detail (LOD) groups. The Unity Editor manages the transitions between groups, but if you're placing trees that are never going to be near the camera, or if you need to limit the display quality of trees without editing the model, you can select a specific LOD group. The options are:
- First: The highest LOD, for trees that are close to the player.
- Last: The lowest LOD, for trees that are far away from the player.
- Custom: To select a different level.
Refer to Tree level of detail (LOD) for more information. -
Cast Shadows: For Tree Editor trees. This is not editable; it lists the option selected in the tree's> Lighting > Cast Shadows setting.Mesh Renderer
?
Customize trees for painting
Customize tree placement and characteristics. Except for Brush Size and Tree Density, the settings apply to both mass placed trees and brush painted trees.
Property | Function |
|---|---|
| Brush Size | The size of the area each brush stroke covers with trees. |
| Tree Density | How far apart trees must be. This limits the number of trees a single brush stroke adds. Note that the limit is by brush stroke, not area, so repeated brush strokes in the same area create higher densities. Note also that the larger the brush, the farther apart the trees, even if the density is 100. |
| Tree Height | A range for tree height randomization. Use a wide range for a varied look, and a narrow range for a uniform look. To specify a value instead of a range, disable Random. The possible values are a scale of |
| Lock Width to Height | By default, a tree's width is locked to its height so that trees are always scaled uniformly. To specify a width, disable Lock Width to Height. |
| Tree Width | A range for tree width randomization. Use a wide range for a varied look, and a narrow range for a uniform look. To specify a value instead of a range, disable Random. The possible values are a scale of |
| Random Tree Rotation | If your tree has a level of detail (LOD) Group (for example, a tree imported from SpeedTree), use the Random Tree Rotation setting to help create the impression of a random, natural-looking forest. Disable this option if you want to place trees with a fixed rotation. |
| Color Variation | The amount of random shading applied to trees. This works only if the shader reads the |
| Tree Contribute Global Illumination | Non-editable; indicates whether the tree asset's Lighting > Contribute Global Illumination option is enabled. |
Mass place trees
You can place trees across the entire terrain tile in a single action. Refer to Customize trees for painting (above) for information about customizing trees before painting.
To place trees on an entire terrain tile:
- Select tree assets as explained above. Note that mass placing uses all the trees in the Trees list, not just the highlighted tree.
- Select Mass Place Trees. The Place Trees window opens.
- Enter the number of trees you want to place.
- To keep the trees you already have, check the Keep Existing Trees box. If you don't check this box, Unity removes all existing trees and replaces them with the new trees.
You can use the brush tools to add or remove trees that you mass placed.
Paint trees with a brush
You can paint trees onto the terrain with a brush.
To paint trees:
-
Select trees as explained above.
-
Refer to Customize trees for painting (above) for information about the brush settings and customizing trees for painting.
-
Paint trees on the terrain using the brush.
-
To remove:
- All trees from an area: hold Shift as you paint.
- Only the tree selected in the Trees list: hold Ctrl as you paint.
Edit trees
You can edit the tree's properties before you place it, or between painting strokes. For example, for SpeedTree trees, you can change the LOD group you use when painting different parts of the terrain.
To edit a tree:
- In the Trees list, select the tree you want to edit.
- Select Edit Trees > Edit Tree. The Edit Tree window opens. It has the same options as the Add Tree window.
Update imported trees
If you change an imported tree in a separate 3D modeling application, you need to refresh the tree in the Paint Tool to update its appearance on the terrain.
To update the trees, in the Terrain tile’s Inspector window, go to Paint Trees > Trees > Refresh.