Generating LOD (Level of Detail) meshes for game engines rapidly and reliably.
A mesh you want to LOD
First of all, what's a LOD?
LOD (Level Of Detail) is a game optimization technique that reduces the complexity of a 3D mesh as it moves farther away from the player. This method, often used alongside culling and other optimization strategies, can also apply to shaders, textures, and more. Typically, it involves employing a secondary mesh that substitutes the original with a lower-resolution version at a certain distance, thus eliminating excessive detail. While the initial mesh can be auto-generated, manual adjustments are often necessary for optimal results.
Using MayaLT to create automatic LODs
Maya features a convenient built-in tool for generating automatic LODs, which can be based on camera distance or a percentage of the total polygon count. To access this tool, navigate to “Edit” > “Hierarchy” > “LOD” (Level of Detail) > “Generate LOD Meshes”. For customized options beyond the defaults, simply click the box adjacent to the last button. This tool streamlines the process of creating LOD meshes within Maya.
These are the settings we've employed for our latest project, details of which will be shared with you soon! In most cases (in fact, the majority of the time), this will serve as a starting point, and you can then refine the automatically generated mesh to enhance its quality.
To begin, duplicate the mesh that you intend to create LOD for, and then hide it. This is akin to duplicating the background layer and working on a regular layer in Photoshop, ensuring that you retain the original material in case any issues arise.
Afterwards, utilize the tool to generate the required number of LODs.
Next, extract the meshes from the LOD group by unparenting them. This allows you to inspect and address any potential issues individually.
Apply the material of the original mesh to the LODded one. This will help you assess how closely the LOD mesh matches the original mesh's appearance.
Once that's done, refer to the troubleshooting steps below to address the issues you've identified.
When you're satisfied with the outcome, rename all components following your preferred naming convention and proceed to export.
Imperfect AutoLODs: As mentioned earlier, automated tools are not flawless. It's our responsibility to rectify errors generated by the computer. Curved or cylindrical surfaces, in particular, often require additional attention from human intervention since they are frequently challenging to achieve accurately on the initial attempt.
UVs became distorted: automated LOD processes generally preserve UVs to a certain extent, but when manual adjustments are necessary for enhancement (and they likely will be), you'll have to ensure the UVs are rectified to align with those of the original mesh. This is particularly crucial when employing actions like "Target Welds", "Merges", and similar operations.
Popping: when a mesh that has undergone LOD transition significantly deviates from the original, a phenomenon known as "pop" or popping can occur. Our task is to ensure that this transition appears as seamless and fluid as possible by incorporating additional LOD levels. The objective is to strike a balance between optimization and aesthetically pleasing LODs, so that players don't immediately perceive the shift to the low-poly model.
Using LODs in Unity 2019
Unity features an integrated LOD system. To ensure its proper functioning, you need to arrange the hierarchy correctly. Follow these steps:
Import your mesh and its LODs to the scene.
Generate a new empty GameObject.
Place the original mesh and its associated LODs within the empty GameObject.
Select the parent GameObject.
In the “Inspector Panel”, click on "Add Component."
Search for "LOD Group" and add it.
By setting up the hierarchy in this manner, you're preparing the LOD system to manage the different levels of detail for your mesh.
Upon adding the "LOD Group" component, you will encounter four slots designated for different LOD levels. You can modify these slots as needed:
To add more slots, right-click on a slot and select "Insert Before."
To remove a slot, right-click on it and choose "Delete."
These slots allow you to define and manage the various levels of detail for your mesh within the Unity LOD system.
You can proceed to assign a previously prepared mesh to each LOD level by following these steps:
Click on the desired LOD slot to select it.
Click on the large square "Add" button.
Choose the mesh you've prepared from the list of available options.
This process enables you to associate the appropriate meshes with each LOD level within the Unity LOD system.
Furthermore, you can fine-tune the transition between LODs based on distance by dragging the separation bar between the LOD slots from left to right. This adjustment controls when each LOD level will be switched to as the camera distance changes. Additionally, you can use the camera icon to simulate and preview the LOD transitions in real-time, replicating how they would occur as the player approaches or moves away from the mesh.
Like any tool, if you solely rely on the automatically generated results without any adjustments, the outcome might not be optimal. By taking the time to fine-tune and tailor the LODs to your specific requirements, you can achieve significantly better results. This concept is analogous to using preset smart materials versus comprehending material layering and employing smart materials to streamline your texturing process in applications like Substance Painter or Quixel.
The true advantage lies in the synergy between the automated process and the human intervention. This combination results in a faster mesh creation process compared to manual creation while delivering superior results due to the user's refinements and fixes.