Optimizing vegetation assets with reduction and billboard pipeline

Forest with lots of trees

Written by Jesper Tingvall, Product Expert, Simplygon

Disclaimer: The code in this post is written using version 10.4.199.0 of Simplygon and Unity 2022.3.37f1. If you encounter this post at a later stage, some of the API calls might have changed. However, the core concepts should still remain valid.

Introduction

In this blog we will look at how to optimize vegetation assets with a combination of reduction and billboard cloud pipelines. We will also cover some texture import settings in Unity.

Prerequisites

This example will use the Simplygon integration in Unity and HDRP render pipeline, but the same concepts can be applied to all other integrations.

Problem to solve

We have a Unity game that is using the HDRP render pipeline. In it we have huge forests suffering from performance issues. We want to solve this by adding level of details to the trees. Without optimization we get very bad performance in this scene, in some cases single digit frames per second.

Solution

We are going to use Simplygon to generate level of detail models for the vegetation assets. These will then be used with a LODGroup to ensure the vegetation uses less detail models when far away.

Generate close LOD models with reduction

To generate the models close to camera we can use the triangle reducer. Vegetation assets are quite hard to optimize with triangle reduction, the reason for this is because the foliage is not very connected and chaotic. So a small change in the topology will introduce a huge geometric error. So what that means is that if we are using max deviation or on screen size as reduction targets vegetation assets tend to not be as reduced as other assets with the same targets. So we need to be more aggressive with them.

We will create two close LOD models, one at screen size 200 and the second at screen size 50. In this case we are using screen size as a quality settings and not in a strict sense as "pixels of errors" as we done in other blogs. The pipelines are cascaded, the input from the first pipeline is used to generate the next one.

Reduction settings

Here is the result. LOD0 is on the left side, LOD1 in the middle and LOD2 to the right. It is very hard to see any difference between the models.

3 tree models

Generate last LOD model with reduction

For the last LOD level we want a very low poly model. To get this we use a triangle count of 400 as our reduction target.

reduction settings

The resulting model does not look that good compared to our original model. While we would expect some loss of detail, the main issue is that we are loosing density.

Original
Reduced to 400 triangles

Generate last LOD with billboard cloud

Instead of using reduction for the last LOD model we are going to use the billboard cloud for foliage pipeline.

  • With Billboard Density we can control how detailed our impostor should be.
  • When working with assets that has lots of overlapping transparent geometry, like most vegetation assets, we always suggest to set the mapping image's Maximum Layers to 10. If this is set to low then we will miss some parts of the model, possibly introducing holes in the impostor where it should be none.
  • We do not use cascading for our billboard cloud impostor, it is directly generated from LOD0.

Billboard settings

Here is the result.

Original
Billboard cloud

Material and texture settings

After processing there are two setting we need to set on the resulting albedo texture:

To get correct alpha on mip maps we need to enable Preserve coverage. If we do not enable this then the lower mip maps will be too transparent, making the tree disappear when it is viewed from far away.

Texture import settings for base map

We also enable Alpha is transparency. Without this enabled we get a slightly incorrect color along the alpha borders of our texture.

Alpha is  transparency

To get the correct color shading on our tree we set some of the impostor's material properties to same values as LOD0's materials. In our case the Material Type was translucent and used a FoliageDiffusionProfile. In many cases we would want another kind of shader, a more lightweight one for rendering our impostor, but that is outside the scope of this blog.

Material settings

LODGroup

To switch between the different models we are going to use a LODGroup. We add one to the vegetation prefab and assign LOD 0 as original model, LOD1 and LOD2 as the reduced LODs and lastly LOD3 as our billboard impostor. We will use Cross Fade to make it more tricky to spot the LOD transition.

LOD group

Result

Let us have a look at our scene with the optimized assets in place. Our performance is much better. Can you spot the LOD transitions?

Here is the statistics for our generated LOD models. For LOD3 we can compare reduction to billboard, we get much lower triangle count for our billboard one and it looks better. This highlight the importance of using the correct tools for vegetation at distance.

LOD Triangles
LOD0 15 k
LOD1 11 k
LOD2 5 k
LOD3 (reduction) 400
LOD3 (billboard) 117
⇐ Back to all posts

Request 30-days free evaluation license

*
*
*
*
Industry
*

Request 30-days free evaluation license

*
*
*
*
Industry
*