LOD Generator
Use the LOD Generator to create levels of detail (LODs) for assets during or after import. Automate LOD workflows in your Unity project as with the Rule Engine.
An LOD is an optimized version of a mesh that is rendered at a specific distance, for performance optimization purposes. The further the viewer is from the model, the less details need to be rendered.
This gif shows a model going from a few million triangles and many separated Renderers and materials (LOD0) to a decimated one million Renderer with UV repacked and one baked material assigned (LOD1) to two triangles and one complex octahedral impostor shader (LOD2).
LODs can be generated at import time using Pixyz Plugin importer or at edit time on existing assets (not necessarily imported with this package).
Note
LODGenerator is not compatible with point cloud. Pixyz Plugin has a specific LOD workflow for point cloud at import time. Check this page for more information.
Among other optimization techniques such as triangle count reduction, Pixyz Plugin supports material baking which is the process of combining multiple materials into one low-resolution material applied on an automatically packed UV mesh.
Import mode
LODs can be generated at import time (after the rule engine is executed) in the LODs section of the importer. By default, no LODs are generated. Add some by clicking on the "+" button, then choose global parameters and strategies for each of them.
After import, an LODGenerator component will be added to the root GameObject. Use this component to regenerate LODs with different values without re-importing the file.
Edit mode
LODs can also be generated after import or on assets not imported with Pixyz Plugin. To do so, simply add an LODGenerator component on a GameObject. This GameObject can have a Renderer directly attached to it or Renderers in its sub-hierarchy.
Then, change the global parameters and strategies.
Parameters
Global parameters
Save assets: not available in import mode because assets are by default saved inside the imported prefab. In edit mode set where to save the generated assets (meshes, materials, textures). If disable assets will be serialized in the scene.
Filter cutout objects: use it to exclude from proxy mesh generation GameObjects with cutout materials applied. Avoid proxy mesh to be generated on transparent areas.
Compress textures: compress generated textures (by baking or impostor generation). Compressed textures use less memory and are faster to render.
Baking offset: offset the baking "cage" (in Unity unit). It can give better results by avoiding transparency to be baked on LOD mesh in case of a large geometric error between source and LOD.
Baking up-sampling: factor to indicate to the process to bake at a higher resolution than the desired output and then downsize the output textures. Super useful to avoid noise, especially on low-res textures (512x512). The higher the factor the longer it will take to process but the better will be the result.
Here is an example of baking up-sampling usage with a 512x512 output texture:
No up-sampling | 4x up-sampling |
---|---|
Strategies
Decimation
Decimate source meshes to generate low triangle count meshes and choose to merge them or not:
- Ratio: triangle count ratio compared to source (LOD0)
- Remove occluded triangles: choose whether to remove occluded/internal triangles (e.g the interior of a house)
- Merging strategy:
- No: keep every renderer separated. Can be useful for close lookup LOD and dynamic GameObjects.
- Merge: merge Meshes together resulting in one mesh with multiple sub-meshes (1 per material). Interesting for lowering draw calls in case input hierarchy does not contain a lot of instances.
- Merge and bake: merge Meshes together and bake materials resulting in one automatically UV-repacked mesh and one material assigned. Choose the output baked material textures resolution. Result will only produce one draw call.
Use case
Decimation is perfect to simplify meshes but retain a significant amount of the original detail. Here are some specific cases where Decimation would be advantageous:
- Close-up LODs: when objects need to be seen up close and still require detail.
- Dynamic GameObjects: for game elements that need to remain independent due to possible interactions or animations (e.g., player characters, breakable objects).
ProxyMesh
Retopologize source meshes into one single mesh with packed UVs and one baked material assigned:
- Ratio: triangle count ratio compared to source (LOD0). Could be lower depending on the chosen voxel density.
- Remove occluded triangles: adds another post process to delete more occluded triangles than the proxy mesh generation already does. Can be useful with half opened input.
- Voxel density: controls the granularity of the voxel-based remeshing. The higher the density the closer to the source meshes it will be but the more time it will take to compute.
- Resolution: controls the output textures resolution. Remember to add up-sampling if output is too noisy.
Use case
ProxyMesh works well for generating simplified, low-poly versions of complex meshes for medium-distance rendering such as buildings in the background of a cityscape. It is especially usefull in the context of a kit-bashed scene.
Kit-bashing is a common practice in game development where developers combine various existing assets to create new, unique objects or environments. While it’s an efficient way to generate diverse content quickly, the resulting game objects can often become quite complex with high polygon and mesh counts, especially if they are composed of detailed assets.
Because the ProxyMesh algorithm will reconstruct a mesh around the input meshes, triangles won't fill the small gaps between kit-bashed GameObjects, resulting in a continous mesh. Details such as normals will be baked in the output material and will fake the original geometries perfectly from mid-distance.
Impostor
Generate far distance LODs using the Octahedral Impostor strategy. Check the impostor page for more information about impostors and input parameters.
Use case
Impostors work very well for rendering static-objects that will be seen from multiple viewpoints at a distance such as trees, buildings or static vehicles.