User Tools

Site Tools


gamedev:treecanopylod

Level Of Detail (LOD) functionality in a game engine adjusts the complexity of a resource (e.g. a mesh model or an image) automatically, based on how far away from the camera that resource is. This can save on memory and load of computation to render a given scene, without sacrificing the quality of the rendered output.

This page explains one of many ways that Level Of Detail (LOD) functionality within the Drag[en]gine works.

Trees in games have always been challenging. These natural structures are very complex and diverse. Modelling a proper tree with dense foliage requires a large amount of triangles. There are tricks to wrap twigs or entire branches with textures and while these do help in close up views it is hard to make them convincing. This requires usually higher polygon counts which in turn hits performance a lot on distance and with lots of trees. Another solution is to use billboards for far away trees. These have though their own set of restrictions and problems.

The Tree Canopy LOD technique presented here can be used to apply geometrical LODing of trees with dense foliage and it can be further assisted by billboarding if required.

Tree at LOD-0

Tree at LOD-0. This close the canopy requires a lot of geometrical detail to look convincing. This tree here has 17'576 triangles.

LODing the trunk and branches mesh is the easy part. The main challenge is the foliage.

To get any useful performance increase the number of triangles in the foliage has to be reduced to 25-50% of the base count of an “average” tree model.

Removing this many triangles is not going to look good at the transition point between the higher and lower Level of Detail models, because the density of the canopy changes a lot making it glaringly obvious that something was “switched” on a model.

To make this switch smoother, instead of just removing triangles, a set of special Canopy LOD meshes are added as “LOD Meshes”. The idea is to compensate the loss in foliage density due to removing lots of smaller branches with some low polygon meshes in the canopy faking dense foliage at the distance.

For this a new texture is used containing a seamless representation of branches running haphazardly across the texture. This is a masked transparent texture used only by the LOD meshes. Hence it is present also in the base mesh but not used there. 3 to 4 such low polygon meshes are created stacked inside each other and hidden in the canopy. The meshes are created to capture to some extend the shape of vertices inside the canopy. At the outside a layer of real geometry foliage is left untouched as we only want to replace the core of the canopy with a “ghost”.

In the image below some of these density faking meshes are shown separated to better get an idea.

Tree canopy density imposter meshes

Tree canopy density imposter meshes. An outer layer of foliage is kept. In the canopy core tons of real geometry have been replaced with density meshes. At LOD-1 this tree has now only 5'834 triangles or 33% of the base mesh. The outer layer shows well why removing foliage alone is a problem.

The savings range from 25% to 35% of the original triangle count. This is a saving of around 10'000 triangles for each tree at LOD-1. On an alley with 10 trees at each side this is already a saving of 200'000 triangles. Obviously heavier LODing can be done for LOD-2 since at this distance more or less only the outline shape of the tree remains. The image below shows a comparison of the LOD-0 version of 5 variations of a tree with the LOD-1 version. The difference is barely visible but the saving in triangles is tremendous. Still, up close the trees show up at full quality. Furthermore the LOD-1 mesh is selected already at a couple of meters away due to the density meshes matching the lost vertices inside the canopy quite well.

Comparison of Tree at LOD-0 and LOD-1 using Tree Canopy LOD

Comparison of Tree at LOD-0 and LOD-1 using Tree Canopy LOD. Visual difference is neglectable but the saving is tremendous. Without the density meshes the canopy would be very transparent and holed creating huge visual difference.

You could leave a comment if you were logged in.
gamedev/treecanopylod.txt · Last modified: 2020/05/10 09:03 by thanos