You can paint Trees onto a TerrainThe landscape in your scene. A Terrain GameObject adds a large flat plane to your scene and you can use the Terrain’s Inspector window to create a detailed landscape. More info
See in Glossary in a way that is similar to painting heightmapsA greyscale Texture that stores height data for an object. Each pixel stores the height difference perpendicular to the face that pixel represents.
See in Glossary and Textures. However, Trees are solid 3D objectsA 3D GameObject such as a cube, terrain or ragdoll. More info
See in Glossary that grow from the surface. Unity uses optimizations like billboarding for distant Trees to maintain good rendering performance. This means that you can have dense forests with thousands of Trees, and still keep an acceptable frame rate.
The Paint Trees button on the toolbarA row of buttons and basic controls at the top of the Unity Editor that allows you to interact with the Editor in various ways (e.g. scaling, translation). More info
See in Glossary enables Tree painting:
Initially, the Terrain has no tree prototypes available. To start painting onto the Terrain, you need to add a tree prototype. Click the Edit Trees button, and select Add Tree. From here, you can select a Tree Asset from your Project, and add it as a Tree Prefab for use with the Brush:
To help prototyping, SpeedTree provides four SpeedTree models in the free SpeedTrees Package on the Asset StoreA growing library of free and commercial assets created by Unity and members of the community. Offers a wide variety of assets, from textures, models and animations to whole project examples, tutorials and Editor extensions. More info
See in Glossary. Alternatively, you can create your own Trees.
If the Tree PrefabAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. More info
See in Glossary that you are importing supports Bend Factor, the Add Tree window displays a Bend Factor property for adjusting wind responsiveness. Trees created with the SpeedTree Modeler don’t have a Bend Factor; only those created with Tree Editor do. See the section on Making Trees bend in the wind, below.
When you have configured your Settings (described below), you can paint Trees onto the Terrain in the same way you paint textures or heightmaps. To remove Trees from an area, hold the Shift key while you paint. To remove just the currently selected Tree type, hold down the Control key while you paint.
After you select which Tree to place, adjust its settings to customize Tree placement and characteristics.
Property | Function |
---|---|
Mass Place Trees | Create an overall covering of Trees without painting over the whole landscape. After mass placement, you can still use painting to add or remove Trees to create denser or sparser areas. |
Brush Size | Controls the size of the area that you can add Trees to. |
Tree Density | Tree Density controls the average number of Trees painted onto the area defined by Brush Size. |
Tree Height | Control the Tree’s minimal height and maximal height using a slider. Drag the slider to the left for short Trees, and right for tall Trees. If you uncheck Random, you can specify the exact scale for the height of all newly painted Trees within the range of 0.01 to 2. |
Lock Width to Height | By default, a Tree’s width is locked to its height so that Trees are always scaled uniformly. However, you can disable the Lock Width to Height option, and specify the width separately. |
Tree Width | If the Tree’s width is not locked to its height, you can control the Tree’s minimal width and maximal width using a slider. Drag the slider to the left for thin Trees, and right for wide Trees. If you uncheck Random, you can specify the exact scale for the width of all newly painted Trees within the range of 0.01 to 2. |
Random Tree Rotation | If you configure the Tree with an LOD Group, use the Random Tree Rotation setting to help create the impression of a random, natural-looking forest rather than an artificial plantation of identical Trees. Uncheck this option if you want to place Trees with fixed, identical rotations. |
Color Variation | The amount of random shading applied to Trees. This only works if your shaderA program that runs on the GPU. More info See in Glossary reads the _TreeInstanceColor property. For example, shaders for all trees you create with Tree Editor read the _TreeInstanceColor property. |
Tree Contribute Global Illumination | Enable this check box to indicate to Unity that the Tree influences Global IlluminationA group of techniques that model both direct and indirect lighting to provide realistic lighting results. See in Glossary computations. |
There are two ways to create new Tree models. Use the SpeedTree Modeler from IDV, Inc. to create Trees with advanced visual effects, such as smooth LOD transition, fast billboarding, and natural wind animation. For more detailed information, refer to the SpeedTree Modeler documentation. Alternatively, use the Tree Editor to create Tree Models.
Internally, the Terrain Engine distinguishes between the two types of models by determining whether an LOD GroupA component to manage level of detail (LOD) for GameObjects. More info
See in Glossary is present on the Tree Prefab’s root GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary. A SpeedTree Prefab has an LODGroup component, but a Tree Editor Prefab does not.
When creating Trees, position the anchor point at the base of the Tree where it emerges from the ground. Performance depends on the polygon count of your Tree model, so be sure to test on your platform, and create simpler Trees if necessary. Also, for Tree Editor Trees, each MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary always has exactly two materials: one for the Tree body and the other for the leaves.
Trees you create using Tree Editor must use the Nature/Soft Occlusion Leaves and Nature/Soft Occlusion Bark shader. To use those shaders, you have to place Trees in a specific folder named Ambient-Occlusion, otherwise the Trees don’t render correctly. When you place a model in this folder and re-import it, Unity calculates soft ambient occlusionA method to approximate how much ambient light (light not coming from a specific direction) can hit a point on a surface.
See in Glossary in a way that is specifically designed for Trees.
If you change an imported Tree Asset in a separate 3D modelling application, you need to click the Refresh button in the Editor to see the updated Trees on your Terrain:
Note: When you import and alter a SpeedTree model in a 3D modeling program, then re-export it (as an .fbx
or .obj
), you might lose the natural wind animation functionality that comes with SpeedTree models.
You can add a Capsule ColliderA capsule-shaped collider component that handles collisions for GameObjects like barrels and character limbs. More info
See in Glossary to a Tree Asset. First, click > next to the Tree Asset to open the Prefab.
Then, select Add Component > Physics > Capsule Collider to add the collider. To return to the Scene, click < next to the Prefab name.
You must also check Enable Tree Colliders in the Terrain ColliderA terrain-shaped collider component that handles collisions for collision surface with the same shape as the Terrain object it is attached to. More info
See in Glossary component.
Wind ZonesA GameObject that adds the effect of wind to your terrain. For instance, Trees within a wind zone will bend in a realistic animated fashion and the wind itself will move in pulses to create natural patterns of movement among the tree. More info
See in Glossary can bend Trees to simulate the direct effect of wind. This feature is only available for Trees that you place through the Terrain menu. To do this, select the Terrain, click the Paint Trees button in the Inspector, then select Edit Trees > Add Tree and select your Tree Prefab. If you did not create the Tree in Unity, set the Bend Factor to 1. Click on the Terrain to place the selected Tree.
Terrain-based Trees that have a Bend Factor react to Wind Zones by bending and swaying, according to the values of the Wind Zone’s Turbulence and Main properties. The Turbulence setting controls the fluttering of leaves. Reducing this value smooths the fluttering effect. The Main value controls the main force of the wind. To create a Wind Zone, select GameObject > 3D Object > Wind Zone.
If the Wind Zone’s Mode is Directional, then its position relative to the Tree does not matter. The Trees will sway in the direction of the Wind Zone. However, if your Wind Zone’s Mode is Spherical, then its Radius has to overlap the Tree’s radius. This results in multi-directional gusts of wind, with a falloff from the center towards the edge.
With the default settings, Trees such as the Broadleaf Prefab (which is provided in the Standard Assets Environment pack) sway in a smooth and realistic way. However, if you’re using your own Tree Prefab, you might need to adjust the Wind Zone property values. If your Tree Prefab trunk is bent all the way to one side, try reducing the Main value. Alternatively, if the branches of your Tree Prefab bend or stretch excessively, reduce the Turbulence value.
For Tree Editor Trees, Unity’s LOD system uses a 2D to 3D transition zone to seamlessly blend 2D billboards with 3D Tree models. This prevents any sudden popping of 2D and 3D Trees, which is vital in VR. Note that billboardA textured 2D object that rotates so that it always faces the Camera. More info
See in Glossary Trees don’t receive local lighting such as Point Lights and Spot Lights. They work with directional lights, but lighting on the billboards only updates when you rotate the CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary.
For SpeedTree Trees, see the LODThe Level Of Detail (LOD) technique is an optimization that reduces the number of triangles that Unity has to render for a GameObject when its distance from the Camera increases. More info
See in Glossary and LOD Group documentation for more information about configuring LOD components.
2020–02–19 Page amended
Added billboard limitations for Tree Editor Trees.