When creating forests on a terrain, excess geometry can bog down the system. Learn about how to use LODs to make your scenes faster.
- [George] Hi, I'm George Maestri. A couple of weeks ago, I showed you how to use Unity's new Terrain Tools. Now these are still a preview package, but they've got a lot of powerful tools, which is why I showed it to you. So now we're going to take level of detail and trees, and add them to a Terrain Tools landscape. Now, before we get started, you need to go into the Package Manager and make sure you have Terrain Tools loaded. If you want, you can also download the asset samples and install those. So I'm going to go into my scene, and I already have a terrain created, but let's go ahead and add some trees. Now, if I go to my Assets/Assets folder, you can see I actually have two trees here. I have one called Scotch Pine, and one called Scotch Pine Level of Detail. So let me show you how each one of these works with creating trees. So if I select my terrain, you can basically hop over to this tab here, which allows you to create and paint trees. Now, the first thing we need to do is basically tell it which tree to use. Now, this is basically just geometry. So what we're doing is we're painting geometry onto our terrain. Doesn't necessarily have to be trees, you could also paint rocks or other types of objects onto the scene. But we are going to use trees, so let's go ahead and do Edit Trees, and we can Add a Tree. So in this case, I'm going to scroll down until I find Scotch Pine. I'm going to select the initial Scotch Pine, and go ahead and click Add. Now what this does is it allows me to paint those trees on the landscape, and you can see here I've got a brush size, and I've got a tree density control, and so if I want, I can left-click and just drop in some trees. Now, one of the problems you're going to find is that as you get closer and further away from these, these will start to cull, and you can see that doesn't really look natural. And so when you work with trees, you have to be very careful about the geometry that you're using. Now, these trees would be fine if all I did was walk through the forest like this. Now, if I were to basically go into a high level view where I've got a lot of distance, then that culling is going to not work. So I'm going to go ahead and reselect my landscape, and then I'm just going to go Edit Trees, and I'm going to remove those trees. Now let's add in the new trees using Level of Detail. So I'm going to go ahead and go Edit Trees, Add Tree, and then let's scroll down to Scotch Pine. There it is, and we want Scotch Pine Level of Detail, Add, and now when I paint, you can see that as it gets further away, it starts to cull a little bit more realistically. So if I paint in a bunch of trees here, let's go ahead and turn down that density a little bit. You can see that as I paint those trees, I get a much more realistic look, because the farther away trees are not culling. Now, if we want to control culling, we have to do basically one more thing. I'm going to go ahead and drag this one tree into the scene, and then I can actually change the level of detail here on that specific tree, and then I'm going to left-click and drag this back into my project window. And I'm going to create what's called a prefab variant. This is called Scotch Pine Level of Detail Variant, or if we want, we can rename it Scotch Pine Level of Detail, let's just call that B. So now I can delete the original from the scene, go back to my terrain, and let's go ahead and select that. And this time, I'm going to remove these trees, and let's go ahead and add in a different tree. We're going to add in that Scotch Pine Level of Detail B, click Add, and now the culling will be different. It really just depends on the object itself. So let's go ahead and just add in a few. So as I'm closer, I get these, but you can see that the ones that are further away, it culls a little bit more quickly. You can see how that culls more quickly. And if I want, I can take a look at this Scotch Pine B, and I have my Level of Detail here, and if I want, I can change it. So if I want to, I can drop it down a little bit and I have a little bit more control. And that's because what I've done is I've created a prefab variant. So I've dragged the prefab into the scene, added the Level of Detail controls, and then just brought it back into my project window. And so that copy now has this component on it, and we can work with Level of Detail a little bit more specifically. So hopefully this gives you some insight into how to create trees for terrain, as well as how to control your Level of Detail.
Note: Because this is an ongoing series, viewers will not receive a certificate of completion.