In LOD We Trust – Static Mesh LODs

This post will give you a simple run-down of some of the static mesh LOD features provided by Lumberyard, which Third Kind Games will be using in our new title: The D.R.G. Initiative.
A lot of this blog post is pulled from the Amazon documentation and collated together for ease of reference. There will be a future post detailing skinned mesh LODs.

Static Mesh LOD

Level of detail (LOD) techniques are used to increase performance and reduce draw calls by displaying progressively lower detailed objects the further they are from the camera. Generally, each LOD should have its vertices reduced 50% from the previous level and a reduction in the number of materials used. Lower LODs should also have multiple textures combined into one texture to further reduce draw calls.

DRG takes place in a huge arena with numerous large and complex objects in it. Some of these objects are made from tens of thousands of triangles, which, if we tried to render all of the time would slow the action down to a miserable chug. Adding LODs to these objects will automatically swap out the meshes for lower triangle count versions when the camera is above a certain distance away from them. The distance at which the meshes will swap is predominantly controlled by two variables; the Max View Distance and LOD Distance Ratio, more on these later.

New Tokyo is an enormous map!

Static Mesh Guidelines

  • The Base mesh (LOD 0) has no prefix/suffix. Every successive LOD should be a separate object that is linked/parented to the base mesh with the suffix _lod1, _lod2, etc.
  • For clarity, you can also add more information the name of the LOD node, i.e. _lod1_sphere or _lod2_justforfun. The engine only takes the first 5 characters into account.
  • You will want to reduce the number of material IDs as much as possible; this will decrease the amount of draw calls your LOD produces. Ideally, the last LOD should only have one render material ID assigned. The r_Stats 6 CVar will allow you to view how many draw calls your objects are producing.
  • Each successive LOD step should save 50% of triangles. (i.e. 1200 -> 600 -> 300 triangles) or have the number of rendering materials reduced. A warning message will be displayed during export if the triangle reduction is above 66%.
  • Currently, up to 6 LOD’s are supported. This number is hard-coded and may change in the future. The e_LodMin/Max CVars will allow control over which LODs are used on a global scale. Objects can have LOD’s for every sub node. LOD’s must be linked/parented to the nodes they should substitute during rendering.

Debugging LODs

There are a couple of CVars which will help you check that your LODs are being used,  I will just list out the ones we at Third Kind Games use.

e_DebugDraw = 1 – Will cause the name of the used cgf file to render to the screen, along with polycount, and the used LOD.

Using e_DebugDraw = 1
r_Stats = 6 – Displays the draw call count for each object instance in the scene. The numbers above each object are broken into total draw calls, zpass, general, transparent, shadows, and misc.

Using r_stats = 6

If you’re feeling like doing a bit of programming, it is pretty straightforward to improve on the functionality that Lumberyard provides and add custom rendering to show information about objects with no LODs at all, or to only call out objects with a triangle count of higher than a specified value.

Material LODs

This text has been lifted with a conversation on the Lumberyard forums with one of their talented tech artists.
Setting up Material “LODs” is as simple as having additional sub-materials that are assigned specifically to the appropriate LOD mesh. For example, I have a material group named “Tree_Mats”, and within this material group are 5 sub-materials. The first 3 sub-materials are specific to LOD0 (the highest poly model), and then the other 2 sub-materials are for the LOD1 mesh. I would just assign the sub-materials that are specific to the appropriate LOD mesh. So when LOD0 is active it uses the first 3 sub-materials I assigned to it, and when LOD1 is active it will only use the other 2 sub-materials that are assigned.

LOD Distance Ratio

This ratio is what affects the distance at which LOD transitions will start happening. The higher the value the quicker you will move through the LODs as the camera moves away. By using this combined with the max view distance set on the object you can control how and what you will see at different distances. These are set on the static mesh component and the best way to get a feel for them is to set up an object with a couple of LODs, turn on e_DebugDraw = 1, and experiment with the values.

Set the LOD Distance Ratio here

Further Reading

Exporting a Level of Detail (LOD)

Wikipedia

Leave a Reply