User Tools

Site Tools


gamedev:treecanopylod

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
gamedev:treecanopylod [2019/05/24 23:43] – ↷ Links adapted because of a move operation dragonlordgamedev:treecanopylod [2020/05/10 09:03] (current) thanos
Line 4: Line 4:
 </WRAP> </WRAP>
  
-LODing in the Drag[en]gine allows for some special LODing tricks. This page explains one of them. Trees in games are always a problem. These natural structures are very complex and diverse. To model a proper tree with dense foilage you need lot of triangles. Tricks exist to **wrap twigs or entire branches** with textures. While these do help at close up it is hard to make them convincing. This requires usually higher polygon count which in turn hits performance a lot on distance and with a lot of trees. Another solution are **billboards** at the distance. These have though their own set of restrictions and problems. The Tree Canopy LOD technique takes a stab at geometrical LODing of trees with dense foilage. The billboard trick can still be used together.+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 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. 
 <WRAP center 100%> <WRAP center 100%>
 <WRAP center box 520px> <WRAP center box 520px>
Line 12: Line 19:
 </WRAP> </WRAP>
  
-LODing the trunk and branches where made out of actual geometry is the easy part of the problem. The main problem are the foliage. To get a reduction worth saving performance the number of triangles in the foliage has to be dropped to 25-50% of the base count. Removing this many triangles is not going to look good because the density of the canopy changes a lot making it glaringly obvious upon switching LOD meshes. To counter this in the game a trick is used. Instead of just removing triangles like mad a special Canopy LOD meshes are added in the 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 nilly willy across the texture. This is a **[[gamedev:textureproperties:transparency|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 an imposter. In the image below some of these density faking meshes are shown separated to better get an idea.+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 trianglesset 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 **[[gamedev:textureproperties:transparency|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.
 <WRAP center 100%> <WRAP center 100%>
 <WRAP center box 520px> <WRAP center box 520px>
Line 20: Line 38:
 </WRAP> </WRAP>
  
-The savings range from 25% to 35% of the original triangle count. This is a saving of around 10'000 triangles for each tree when it hits LOD-1. On an alley with 10 trees at each side this is already a saving of 200'000 triangles. Not to be sneezed at for resulting in little visual impact. Obviously more heavy LODing can be done for LOD-2 since at this distance more or less only the shape of the tree remains. The imae 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 tremendously. Still at 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.+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. Stillup 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.
 <WRAP center 100%> <WRAP center 100%>
 <WRAP center box 760px> <WRAP center box 760px>
gamedev/treecanopylod.txt · Last modified: 2020/05/10 09:03 by thanos