This article reveals some important LOD techniques used to hit framerate when working with dense foliage in VR. Difficult even under normal circumstances, creating forests or jungles in VR means we really have to step up our game!
Sadly there isn’t a single easy answer to hit that magic 60 or 90 fps. In fact, it requires a combination of techniques, and these techniques tend to change based on what the scene requires. Where should we start? In our previous section, we covered the basics of creating foliage in VR. No we’re going to focus specifically on LODs.
Aggressive LODs for Foliage in VR
LODs, or level of detail, are the first step. LODs are different versions of an asset that decrease in complexity as the asset gets farther away from the rendering camera in-game, simplifying the workload on our GPU.
In environment art, LODs are key for making the most of your resources. Swapping to lower detail models whenever possible will help maintain the frame rates that VR requires. And that doesn’t just mean polycount – but we’ll get to that in a second. Just keep in mind – your foliage LODs must be as streamlined as possible!
From LODs to billboards
LODs themselves require quite a bit of setup. Let’s break down each individual LOD, from the example below.
LOD 0 is your highest detail mesh. These appear closest to the player. That also means that everything else in the scene is behind these models, making overdraw a huge problem. Overdraw is almost always your biggest problem with performance and foliage in VR!
To solve this, we did something unexpected – we actually created a high-resolution mesh that matches the shape of the alpha texture. Naturally, this increases polycount by a lot, but we reduce overdraw significantly!
LOD 0 also includes a vertex shader that creates leaf movement to simulate wind in the environment – an expensive but important detail!
LOD 1 uses the same base mesh as LOD 0, with alpha, but it has a different material. That’s right – LODs can have different materials! This material is largely the same as LOD 0, but with the vertex leaf movement shader removed. Also adjusted is the Opacity Mask Clip Value – the value here is lower than the number on LOD 0. That means that Unreal calculates the transparency of the object less accurately, which speeds up performance.
The Dither Opacity Mask should also be ON. This makes the transparency look uglier, but it reduces overdraw.
These are little tricks, for sure – but they add up! The texture and geometry are unchanged of LOD 1 are the same as LOD 0, but the material is definitely different!
LOD 2 is when we really start poly optimization. There’s less curvature in the leaves and a lot more straight edges – things that don’t look very leaf-like. However, we still keep a lot of the cut outs that reduce overdraw!
Don’t be shy when cutting polys- as long as the mesh retains a generally similar shape to LOD 0, you’re safe. Remember, these are viewed from far away!
We also adjust our Opacity Mask Clip Value – we reduce it below the value of LOD 1.
LOD 3 gets a bit more extreme. We remove both the alpha texture, we aggressively reduce polycount. As you can see, the example gets a little abstract here – there are big gaps and shapes are really blocky. That’s ok, this is only visible from far away! As long as the silhouette is remotely close, we’ll be fine! And, once again, we reduce the Opacity Mask Clip Value.
LOD 4 is the absolute biggest change. It’s just a billboard! This is a t-shaped plane and an entirely different texture altogether. It bears only a passing resemblance to the other trees – but at a distance, viewed through a thick jungle, the player will never notice!
These come in handy when an object is far away from the camera but still somewhat visible. When you want to conserve processing power but don’t want the model disappearing while in view of the player, billboarding is the way to go.
Overdraw and Alpha
Today’s LODs are a lot more complicated than the simple poly-reductions of yesteryear. And with foliage in VR, we run into the extra problem of overdraw.
Overdraw is complicated enough to warrant its own post – but essentially what happens when an engine draws one transparency object, then draws another transparency object on top of that. The same pixels are being drawn multiple times – once for every transparent object. In a jungle or forest, with all the transparent leaves, you can see how this could be a performance nightmare.
This hopefully gives insight as to how the LODs were defined. Silhouette objects are meshes like LOD 0 from the example above. They’re assets with meshes that have been cropped to minimize blank texture space. This is to minimize alpha space, because it’s expensive to render. And since these trees are closest to the player, there is a much higher chance for overdraw.
While the silhouette shader is best for highest LODs, it’s ok to break out alpha shaders for lower LODs. They will cover less area than a high LOD model would require, so the overdraw from alpha will be less costly.
In the lowest LODs, avoid using alpha at all. If your low LODs or billboards are blocky as a result, that’s ok. Better to have some awkward geometry off in the distance than have your whole game slow down to render that pretty tree in the distance!
Keep an eye on LOD attributes
Most of what we talked about so far have been manual ways of managing LODs, alphas, and overdraw. However, Unreal offers further control via adjustable reduction settings for each LOD!
You can change texture resolution, silhouette accuracy, and pixel error. These attributes decide how accurate Unreal renders distance LODs.
In this screen, you can see that the Pixel Error value gets higher with each subsequent LOD. Not only that, but the Silhouette, Texture, and Shading parameters are also adjustable, progressing from high, to low, to lowest, and then off entirely. Little tricks like this help get us those last few FPS!
Trees without foliage in VR
Now, we’re talking about foliage in VR, so why would I mention trees without foliage? What’s the point of that? It may seem counterintuitive, but it is an easy way to add visual complexity without crushing our performance!
As we know, trees are expensive to render, and their most pricey elements are the leaves. Leaves often require either transparency or a high polycount for results that resembles a convincing tree. But if the target environment is a dense, lush forest, you can’t get away with just a few trees spread far apart.
Which brings me to the solution of trees without foliage! That’s just a tree trunk and some branches. These foliage-free trees do three different things:
First, they fill-in areas between the leaf-having trees that create the jungle canopy, but don’t add expensive overdraw with unnecessary foliage and alpha regions. Placing some trunks next to full trees creates the illusion of a densely packed forest without piling geometry on top of each other.
In this screenshot you can barely tell that we’ve used trees without foliage. Of the trees in this image, only 2 or 3 of them is creating the canopy with their leaves, while the rest are just trunks.
Second, they occlude assets that are overdrawn. You can cull more background foliage if the foreground is packed with a wall of tree trunks. The area still feels big, but the camera doesn’t have to render far away.
Thirdly, they reduce polycount by replacing highly detailed trees with lower poly trunk meshes. Ultimately, trees without foliage are a low-cost way to improve the illusion of a dense forest.
Roughness is what dictates how rough or smooth an object is. We’re blowing your mind right now, we know. But generally, roughness is an attribute we use in our materials.
However, roughness is also expensive to render. So when possible, just remove roughness altogether.
We know you’re thinking, “how can I make stuff look good without roughness in my materials?!” But VR demands sacrifice! You’ve got to learn to work within its limitations.
LODS – not just polygons any more
As you can tell, creating LODs isn’t a simple matter of poly-reduction. Evaluate every aspect of the mesh to improve performance. It certainly is a pretty dense concept because there’s a lot of elements to keep track of.
But think of it this way – if you can build foliage in VR, building non-VR trees will be super easy!