3D Asset Workflow: LODs

From Frozenbyte Wiki
Jump to: navigation, search
3D Asset Workflow

Summary

  • What are LODs?
    • LOD = Level of Detail
    • LODs are an important performance optimization feature, where 3D models are dynamically swapped to lower quality ones based on their distance to the gameplay camera
  • Making manual LODs is included to the 3D Asset Workflow to make the models as usable and efficient as possible, even at great distances
  • We use two LOD levels in our Editor
    • First LOD level = 35m away by default (approx. 66% polygons left of the original)
    • Second LOD level = 55m away by default (approx. 33% polygons left of the original)
Making LODs for Trine 4 cover.PNG

LOD Workflow Steps

  1. After the models are done and assembled, it's time to make the LODs
  2. Use an in-house script to create the LODs automatically, which is not listed in this public page
  3. Fix all the most drastic issues by hand
    • The automation will most likely mess up your model's UV islands a bit
    • Most of the UV stretching etc isn't really visible especially at LOD level 2, so no need to fix everything - be sensible

The LOD Script Settings in Modo

Script Default Settings

LOD level Distance Percentage
LOD0 35m 66%
LOD1 55m 33%

Freeze Transforms: Off
Update Normals: Off

LOD Generator Inputs

Ah LOD generator screenshot.png
  1. Text inputs are:
    • Left: Distance from camera in meters. The distance is where the labelled LOD level begins from
    • Right: LOD level's percentage of polygons compared to the original mesh
  2. Freeze Transforms When on, freezes item transforms and recalculates normals. It is intended for cases where there are item level transforms active, e.g. legacy meshes. These transforms will not otherwise translate to the LOD meshes, so they will be misaligned/-rotated/-scaled etc. This setting affects the original mesh
  3. Update Normals When on, the script will update vertex normals to minimise shading errors. This isn't needed in most cases, so it's off by default. There are some cases where it's especially best left off, like when creating LODs for plants/foliage with custom vertex normals. This might also break normals in newer Modo versions, as it runs the vertMap.updateNormals command which adds a Vertex Normal map under Lists.
  4. Generate LODs all generates LODs, names them and places them in the layer hierarchy, leaving the original intact. Doesn't touch anything under 100 tris. The script will ignore certain types of meshes:
    • Meshes excluded from import ('_' in the name)
    • Billboard meshes ('billboard' in the name)
    • Collision meshes ('_collision_' in the name)
    • Broken parts ('_broken_part_' in the name)
    • Meshes meant for background use only ('_bg_' in the name)
    • Meshes that already have LODs
  5. Generate LODs selected generates LODs only for the selected meshes. Ignores the above name blacklist, so you can use this on meshes regardless of their naming. Only exception being that you can't make LODs for LODs.
  6. Delete LODs all Deletes all existing LODs (any meshes that have '_lodlevel_' anywhere in their name)
  7. Delete LODs selected Deletes the LODs only from the selected meshes.
    (Known issue: Selecting a mesh, then a parented LOD mesh, and the running delete selected will cause the script to crash. To avoid this, select the LOD mesh first, or not at all since it isn't required for the script to work)
  • An example of item level transforms in the mesh. If there is anything other than 0 or 100% in the text fields, remember to turn on 'Freeze Transforms'
Item level transforms.PNG

Using the Automatic LOD Script

  • Run the script
  • After the script has run, make sure all the LOD meshes look good enough
  • The script uses existing Modo tools to get the job done, so it can be slow at times
    • Especially large files with lots of meshes can take a while to complete, so be aware of that

Settings

  • When creating LODs, it's best to stick to the script defaults
  • You can change the percentages to get better results, but distances are best left alone, or at least near the defaults, so the LOD distances stay consistent
  • If there is a reason to change distances, then it's good to know that the game camera distance from play area is around 10-13m

Troubleshooting

  • Some parts of the UVs might get messed up on higher LOD levels due to the way the tool works, but check in-game if it's noticeable enough to warrant fixing
  • If there are issues on how the LOD models look like, you can delete the problem LODs (both meshes), tweak the settings and run the script again
    • If that doesn't cut it, you can fix/make them by hand, or copy in a higher LOD level
  • An example of a broken LOD - Easy fix in this case would be to copy/paste the unbroken parts from the previous LOD level
Broken LOD example.jpg

Making LODs by Hand

  • To create manual LODs by hand, you need to parent two mesh layers to the original mesh, and name them correctly
  • The naming system is [mesh name]_lodlevel_[distance from camera]
    • So for example LODs for a mesh called 'generic_asset' that change after 20 and 50 meters would be named generic_asset_lodlevel_20 and generic_asset_lodlevel_50
  • To actually create the meshes, you can use Modo's mesh reduction tool to lower the amount of polygons, but that method is already handled by the script above
  • When it comes to LODs, the silhouette is the most important
    • Lower detail levels can be jaggy, but as long as the general shape stays the same, it's going to be fine
  • To get the best quality LODs, you can
    • Remove edgeloops that don't affect the silhouette
    • Collapse edges
    • Simplify shapes
    • Remove unseen faces, etc

Manual LOD Naming and Mesh Hierarchy:

LOD mesh hierarchy.PNG

Example
[Original mesh]
↳ [Original mesh]_lodlevel_[distance]
↳ [Original mesh]_lodlevel_[distance]


Dealing with Billboard and Background Meshes

  • When it comes to assets like billboards or background meshes, whether you are making the LODs by hand or with the script, remember to turn off LOD generation (GenerateLod tickbox) in the model resource when bringing your assets to editor
  • Billboards and background meshes serve the same purpose as LODs, but without a full detail mesh, so it would be redundant to have LODs be generated for them as well
  • Turning off automatic LOD generation is detailed in LOD settings

LOD Adjusting in Editor

  • All LODs can be turned on or off from Renderer Options -> LOD, and the LOD settings can be adjusted from the modelresource
  • Level artists need to keep a good eye on the LOD quality in their levels, since the automatic LODs can be quite harsh at times at default settings, even deleting some objects at times, like vegetation and foliage
  • Remember to toggle the LODs on and off every now and then

LOD Settings in Editor

  • LOD settings can be tweaked in the Editor from model resource settings
  • Easiest way to find the modelresource you're looking for, is to right click the model in the scene or type tree, and selecting Locate type model resource
  • You can also directly search for it in the resource window.
Modelresource LOD settings.png

LOD settings

AllowManualLod
When on, the model will use manual LOD if present. If no manual LOD is present, it will default to automatic (After toggling this off asset will not update until saving resources and also updating the fbx model with fbx dialog.)
GenerateLod
When on, the model will use automatic LODs, if manual ones aren't present (After toggling this off asset will not update until saving resources and also updating the fbx model with fbx dialog.)
LodLevelTrianglePercentages
Values for what percentage of the original triangle count the automatic LODs will keep
LodLevelAllowedErrors
Error metric to use when choosing edges to collapse. Not meaningfully defined, but you can try lowering if collapsing produces problems. Setting it too low will prevent collapser to find any edges to collapse, and intended triangle percentage won't be reached.
LodDistancesManual
LOD distances for the automatic LODs. Can be changed on the fly, but remember to save resources afterwards
LodDistancesFbx
LOD distances defined in the FBX file for manual LODs. Can't be edited and only show how the manual LODs are configured
LodDistanceFbxOverrides
Overrides the values set in the FBX for manual LODs. Can be used to tweak the manual LOD distances. Add or remove overrides with the '+' and '-' buttons