Feature Preview: Foliage

We keep improving Flax all the time. It’s time to introduce you to the new Foliage system that has been added to Flax and will be ready to use for the next major update. This will definitely improve open world games development and complete the recently added terrain system.

Without further ado let’s jump into the topic!

 

Foliage Rendering
High-quality and performant rendering in Flax

Details

The most important purpose of the foliage system is that it can easily scale and result in very solid performance. If your game needs huge open worlds full of trees, grass, and rock then you definitely need to use foliage system. It supports placing and rendering hundreds of thousands of foliage instances in the level with no performance drop. Ok, but how it works?

Foliage actor contains a list of predefined foliage instance types and a collection of foliage instances. Each foliage type defines the model asset to use for rendering, placement properties, and painting properties. Each foliage instance contains information about what type it uses and the actual placement transformation in the world. Both instances and types collections are encapsulated inside the foliage actor internally to improve performance.

Foliage Quad Tree
Foliage Quad Tree visualization

Implementation

Foliage internally uses Quad Tree structure to achieve great performance in scenes that use more than 200k instances. Quadtree clusters are generated on scene load or after modifications. Flax supports various tools to optimize the game content such as foliage density scaling, cull distance, LOD bias and minimum screen size per model LOD.

For small grass and rocks, it is recommended to use density scaling. By adjusting Foliage.GlobalDensityScale you can apply the global foliage density scale factor and reduce the amount of visible instances using the random pattern. Use it to tweak game performance for slower devices. Just take a look at the gif below to see how works dynamic foliage density scaling (it is super fast and can be done at runtime).

Foliage Density Scaling
Foliage Density Scaling

Foliage system comes up with dedicated C# API for accessing instances data and instance types information. You can modify all of the properties and spawn or remove instances during gameplay. Many games such as Real-Time Strategie genre titles generate the world dynamically so we also added API and tutorial for those who need to spawn foliage at runtime.

Finally, because the foliage system can be described as a huge booster for instanced meshes rendering you can use own geometry (other than foliage/rocks) such as dungeon walls or large city buildings. This can help with achieving better performance in your games.

Foliage Open World Performance
Large scale foliage rendering (250k instances)

Summary

That’s all for now. We hope you like the newest feature as we want to publish another exciting update soon. It will include a foliage system and many new features.

See you soon! Bye 🙂


Wojciech Figat

Lead Developer

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *