Nils Arenz talked about his vegetation studies and explained how to produce highly realistic and diverse grass with UE4.
Nils Arenz talked about his vegetation studies and explained how to produce highly realistic and diverse grass with UE4.
Introduction
Hello, my name is Nils Arenz and I am a Junior 3D Environment Artist from Germany. Earlier this year I finished my study in the field of computer graphics and image processing. For my graduation thesis, I developed an application for simulating different avalanche types using the Nvidia PhysX library. The main field of my study was coding C++ and OpenGL, but I was always more interested in doing digital art with the knowledge I gained during my study. As often as possible I participated in game or film art projects at my university and improved my knowledge of the Unreal. After I graduated I had to make the choice: working as a programmer or following my dream and trying to become a 3D Environment Artist. I chose the last one and I am really happy with that decision!
My main fields of interests are designing the nature as detailed and complex as possible but doing this in a very efficient way. My background in coding 3D applications helps me a lot to optimize the designs because I know the math behind all the calculations. Projects I published recently are photoscanned ground landscape materials, photoscanned bark materials and a dynamic and interactive ivy. For the next half of the year, I will focus on creating dynamic wind animated and interactive vegetation.
Vegetation Creation Basics
In my opinion, this splits into five parts. First of all the visual quality has to be very high. A blade of grass or other vegetation parts are not just some green mesh parts. All the pictures of the vegetation I create are scanned in a portable studio out in the woods or at home for the best lighting setup.
Next, you need some kind of wind animation. You simply can’t walk through a forest and see all the vegetation static. That simply doesn’t feel right.
Third, you need some way to interact with the vegetation. If you walk by an ivy branch, the branch should have some interaction with your character.
Your vegetation should be as complex/unique as possible but efficient at the same time. It will not look good if you only use 5 different blades of grass for designing grass clusters. The more different kinds of leaves/blades of grass you have the better the result will look. Plus the more you optimize, the more people will be happy with your designs.
Building Grass
The most common way to implement grass is to arrange the blades of grass side by side in the albedo map and using a big plane to map this to an object. This planes will then be stacked inside each other at different angles. If you look at the grass from the top you will not see the grass blades under you. A better way is to put a smaller plane around each blade of grass and put these blades as a structure. Both ways have two big disadvantages: the quad overdraw and the shader complexity are very high. The only way to reduce them is to model each blade of grass individually so that the opacity of usage is as low as possible. This will also lower the quad overdraw. The downside of this method is that the vertex count is higher than other methods, but I benefited from it. For using the Unreal Engine Pivot Painter Tool 2.0 you need a finer mesh for the wind simulation. Further, the UE4 is using foliage instances what makes the vertex count not that important.
Diversifying Grass
Let me guide you through my workflow. Unlike flowers, you can cut grass and it will stay fresh for about one hour. As I live in the country I just go outside and collect a huge pile of grass. Mind that it’s important to choose a high diversity of different kinds of grass. Next, I bring the grass home and put it in a vase. For the best results later you need also to pick out variously looking blades of each kind of grass. You can see this in the picture below. Mind that it’s important to choose a high diversity of different kinds of grass. Next, I bring the grass home and put it in a vase. For the best results later you need also to pick out variously looking blades of each kind of grass.
For each kind of grass, I picked about 5-10 different unique blades. For the best performance, I packed all of them in one albedo map. In total, I came up with 84 different blades of grass in the texture. Each object got modeled, duplicated multiple times and then transformed into different shapes. So I came up with 150+ different looking blades of grass. The next step was creating grass clusters you can use as foliage brushes. For this asset, I made 82 grass brushes, that provide you with a high foliage variation. The clusters are made by 100-200 grass blades, what brings an average vertex of about 1200 per cluster. The brushes work as object instances, and the vertex count is not that important. Using Unreal Engine you have to add a free transformation in x, y and z axes for about +-20% of the size. This all provides a look that every part of the grass landscape looks completely different.
Due to the low shader complexity and low quad overdraw the performance compared to other grass foliages is higher, even with the higher vertex count. At the moment the LOD is made by the Unreal Engine. I am working on a new implementation, which lowers the vertex count by decreasing the height separations of each grass blade. For testing the performance I made a simple scene and put 30k foliage instances in it. I have GeForce 1070 GTX, the frames between 80 and 120. In the following videos, the performance can be seen pretty well.
Animation
The animation of the grass is the key feature of this asset. The most used animation for grass and foliage movement in the Unreal Engine is the Simple Grass Wind Node. The main function of it is bending the whole cluster. The downside is that the grass blades next to each other have closely the same animation, they bend in the same direction with the same strength. Nevertheless, I used this feature to create a wind rolling effect.
I was not happy with the look of this, so I did some research and discovered the Pivot Painter Tool 2.0. After weeks of trial and error, I managed to master the pipeline creation and control over all parameters. The Pivot Painter Tool put the wind animation on every single blade of grass of the cluster. All the calculations are done in the shader. These transformations of each object are made based on its pivot point. The higher the vertex count the more smooth the animation will be. If you only use a plane with 4 vertex points, the animation will bend the whole plane locked to the pivot point. Now all the objects move completely different but defined by parameters in the same way. Unreal already implemented all important parameters like wind strength, wind direction, bending strength, random wind direction change and a lot more.
Another important step was to vertex paint all the blades of grass individually. The animation will look better if the side leaves move more than the stem of grasses. The downside of this method is that you need an individual material instance for every cluster because you need to tell the material where the pivot points are and in what direction the pivot is pointing.
As you need a unique material instance all the wind parameters can be assigned individually as well. A tall grass cluster will be affected by wind more than cut short grass. Further, you can outsource parameters in a material collection, so you can change the wind direction and other values for all objects in your scene. With this method, you can build some kind of wind engine in your application. With a few clicks, you can now change wind direction, wind power, wind noise and a lot more parameters for your whole vegetation system, what will make your vegetation look super alive.
Future Plans
The grass package is a part of my upcoming foliage essentials pack. It will be a pack with all the plants, flowers, grass and much more stuff for filling your ground nicely. Of course, all elements will have the presented wind animation and optimization. I will split this pack into three parts and a bundle with everything. The first part is grass, which is the most important, it will be a big package. The grass project is already submitted and will be hitting the UE4 Marketplace in about 1-2 weeks from now. Further information will be published on the Unreal Marketplace Forum soon. The next pack will be wild meadow flowers and ground plants that don’t fit in the flower or grass sections. Thee two packs are half finished and will be submitted in about 2 weeks. After this, I planned to do a forest foliage pack, with forest fern, small bushes, small trees and other elements. Here the interaction between the vegetation/wind and the character will be key.