Simon Barle gave a few tips on how to use trees in scenes and video games and what mistakes to avoid.
80lv: Simon, what are the technical requirements for trees in games today? How many polys should it be, how the textures should be done, how dense the foliage should be?
That’s a tough question, there are so many different parameters to work with. Maybe your game engine uses alpha to coverage, or is it using alpha testing? And on top of that, there are several different approaches on how to handle these type of rendering as well.
The general rule of thumb though is to keep the amount of overdraw as low as possible. One thing that many people tend to do is to use as few triangles as possible, which is how you traditionally approach a lot of other subjects when you are looking to optimize assets. However, when it comes to foliage triangles are (in most cases) actually preferred over having too many transparent pixel-drawing over each other. A bigger number of smaller foliage cards are actually cheaper to render.
The big cost coming from overdraw is basically if a pixel needs to be redrawn several times and you multiply that by how much of the screen is covered with it. You effectively end up redrawing that part of the frame several times which slows down
This doesn’t mean, however, that you can go bonkers with the triangles either, there are still some general guidelines to follow as with any asset. Drawing sub-pixel triangles is tricky as well, so you don’t want too many small foliage cards all over the screen for
a longer distance, for example, otherwise, you end up drawing the same triangles several times.
But I would say triangles over overdraw is a good way to think about it as long as you balance it.
A “good” thing about overdraw is that it depends on screen space, so the further you are away from it, the fewer pixels will overdraw.
Usually, your friendly local tech art person has some general rules of how many triangles can be on screen at on time.
As for textures, there are several good ways of doing it. Megascans has some great atlases to use if you are going for a realistic look. You can make high poly of the branches using any modeling software of your choice and bake it down to a flat texture.
I like to use a mixture of them both to utilize the best of the approaches.
I really like a clean and amped-up look you get from baking down a 3D mesh, but I also like the scanned data as it adds realism and accuracy to the mix. So I usually end up modeling my branches and leaves the way I want, use photos/scan data mapped on the branches and leaves, use vertex colors as masks or tints and bake everything down in Substance Designer to a flat texture sheet.
Using Greenery as a Glue in the Scenes
80lv: What is the way trees could be used during the production of smaller environments, where vegetation does not take center stage? How does one use vegetation as a good background building tool and way to elevate the scene?
For smaller environments, I would try to maximize the usage of my texture sheet. Pick a type of tree that has a generic leaf shape and could be used for shrubs and sprouts as well, so from the same texture set you can create a range of assets, some versions of trees, shrubs and sprouts. I would definitely allocate some space to the texture sheet to make a dead looking branch – that way you really add some natural feel into your environments as there are a lot of dead plants and trees mixed into it.
Vegetation can be a great “glue” for scenes that aren’t all about nature when some grass grows out of a crack in the curb or some weeds go along a wall or a fence – small details like that can make the scene feel alive. Trees can also be a great way to build depth. Clusters of trees overlapping at different distances can create “planes” and really sell the background of your image.
80lv: Let’s image you need to make the forest. How do you populate it with trees, avoid repetition and a fake look? What is a good way to approach it?
A good way to scatter trees would be to have a few large trees with unique trunks being used as “anchor” points in the scene, then around these you could scatter some variants of smaller sprouts in different sizes and some dead plants and smaller trees, depending on what type of forest you are aiming for. If it’s a very old forest, almost no spouts or smaller trees would be present around the bigger trees as very little sunlight makes it down to the forest floor. If it’s a more open, lighter forest, then there would be a lot of smaller foliage growing around the trees.
If you are working in Unreal Engine, for example, a quick and easy way is to place the larger trees either with a blueprint that spawns trees or by hand and then use the foliage painting tool to populate the scene with smaller foliage.
Avoiding repetition comes down to placement and having trunks that are unique and can be rotated to feel different, plus not letting the trees line up too much with each other as it will feel very man-made. The most important thing, in my opinion, is to capture the overall feel of a forest rather than spending time on all the small details. There should be a life cycle of trees and plants represented, small to large and a lot of dead plants and fallen branches.
Trees in Gameplay
80lv: What way is vegetation usually used in game scenes? Does it ever become a part of the gameplay? How would you start tweaking trees if they were part of the gameplay?
Usually, it’s used to block the player’s line of sight or to hide in some instances. You can also climb trees and such, plus some games use them as harvest-able resources. It’s very important to know the gameplay intent for the world before you start building the trees. If you are able to climb them, maybe you need to have a really high res feel of the trunk using detail maps. Maybe you need to fade out foliage cards to avoid unflattering angles as the player’s camera comes close.
If the trees can be destroyed, you need to think about having an inside of the tree where it can break, either with pre-built pieces or by some in-game fracturing method.
80lv: Finally, what are the main mistakes to avoid while using vegetation, both artistic and technical?
One of my pet peeves is when you don’t leave enough negative space or “air” in your textures. It makes your foliage cards look boxy and undefined and worst of all – it gives away that it’s a card! It’s really important to leave enough air between your leaves and branches so that the mipmapping doesn’t blur everything together into an opaque mess.
Another thing: don’t make the branches too short, or the trees look like small bonsai trees. You need to let them flow a bit and then branch out into a lot of smaller branches.