Unity terrains can be furnished with trees. Patches of trees can be painted onto a terrain in much the same way that heightmaps and textures are painted but the trees are solid 3D objects that grow from the surface. Unity uses optimisations (eg, billboarding for distant trees) to maintain good rendering performance, so you can have dense forests with thousands of trees and still keep an acceptable framerate.
The tree button on the toolbar enables tree painting.
Initially, the terrain will have no trees available but if you click the Edit Trees button and select Add Tree you will see a window to select a tree asset from your project.
Unity comes with several sample SpeedTree tree objects in the Standard Assets packages for prototyping purposes Assets > Import Package > Terrain Assets) but you can also create suitable objects with SpeedTree Modeler app, Unity Tree Creator tools or other 3D modelling apps.
If the selected tree object is created by the Tree Creator, the window will show Bend factor for adjusting the wind responsiveness. See the section on Making trees bend in the wind below.
With a tree selected, you can paint onto the landscape in the same way you paint textures or heightmaps. You can remove trees from an area by holding the shift key while you paint and remove just the currently selected tree type by holding down the control key. The familiar Brush Size option is available for tree painting but the Opacity property is replaced by Tree Density, which controls the average number of trees painted into a given unit of area.
There is a ranged slider for you to control the tree’s minimal height and maximal height. If you disable Random, you can specify a value for all tree’s height. By default a tree’s width is locked to height so that trees are always scaled uniformly. However you can disable Lock Width to Height option and specify the width separately.
There is also a control for Color Variation and Random Tree Rotation. The variation options help to create the impression of a random, natural-looking forest rather than an artificial plantation of identical trees.
The Mass Place Trees button is a very useful way to create an overall covering of trees without painting over the whole landscape. Following a mass placement, you can still use painting to add or remove trees to create denser or sparser areas.
From Unity 5, you can use SpeedTree Modeler from IDV, Inc. to create trees with advanced visual effects such as smooth LOD transition, fast billboarding and natural wind animation. Please refer to their site for detailed information. You can also freely import SpeedTree assets into your project folder from asset store packages or other third party sources.
See here for more information.
Unity has its own Tree creator that you can use to produce new tree assets but you can also use a standard 3D modelling app for the task. The tree mesh should have fewer than 2000 triangles (for performance reasons) and the anchor point should be right at the base of the tree where it emerges from the ground. The mesh should always have exactly two materials, one for the tree body and the other for the leaves.
Trees must use the Nature/Soft Occlusion Leaves and Nature/Soft Occlusion Bark shader. In order to use those shaders you also have to place the tree in a special folder that contains the name “Ambient-Occlusion”. When you place a model in such a folder and reimport it, Unity will calculate soft ambient occlusion in a way that is specifically designed for trees. The “Nature/Soft Occlusion” shaders rely on the folder naming convention and the tree won’t render correctly if you don’t follow it.
When you save a tree asset from the modelling app, you will need to click the Refresh button (shown in the inspector when the tree painting tool is selected) in order to see the updated trees on your terrain.
You can add a Capsule Collider to a new tree asset by instantiating it in the scene, adding the collider (menu: Component > Physics > Capsule Collider) and creating a new prefab for the modified tree object. When you add the tree to the terrain for painting, make sure you select the prefab with the collider rather than the original object. You should also enable Create Tree Colliders in the terrain’s Terrain Collider component inspector.
The first thing you will need to do is create a wind zone. You can do this by selecting from the menu: Game Object > 3D Object > Wind Zone.
At this point, you will need to make sure that your trees are set to bend. Select your Terrain, click the Place trees button in the Inspector and then select Edit Trees > Edit Tree. Setting the Bend Factor to 1 will cause the trees to adjust if you have not already done this.
You may notice that your trees are moving about quite violently. To fix this, you can change your bend value, but it is probably easier to set the values on the Wind Zone directly, keeping your tree bend factor set to 1. To keep the trees from fluttering around too much, adjust the wind turbulence down to around 0.1 to 0.3 and everything will become much smoother. If you don’t want the trees blowing all the way to one side, set the Wind Main value down to the same value as your turbulence.
2017–09–19 Page amended with limited editorial review
GameObject menu changed in Unity 4.6
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.