No edit summary
(V5.2 - Added new LODGroup-oriented workflow)
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:


object from your scene. It will automatically compute simplified version of your
object from your scene. It will automatically compute simplified version of your
[[File:AutoLOD screenshots.png|thumb|606x606px|The AutoLOD editor window under several states of customization]]
[[File:Image 2023-10-30 141342560.png|thumb|606x606px|The AutoLOD editor window under several states of customization]]
meshes using decimation.
meshes using decimation.


Line 10: Line 10:
== How to use ==
== How to use ==
AutoLOD consists in an editor window. You can open it via <code>Window->AutoLOD->MeshDecimator</code>.
AutoLOD consists in an editor window. You can open it via <code>Window->AutoLOD->MeshDecimator</code>.
 
[[File:How_to_open_the_window.png|center|frameless]]
[[File:How to open the window.png|frameless]]


Put the object(s) to be processed into the ”targets” area. Please note that a Renderer is required otherwise the object cannot be added.
Put the object(s) to be processed into the ”targets” area. Please note that a Renderer is required otherwise the object cannot be added.
 
[[File:AutoLOD_MAN2.png|center|frameless]]
[[File:AutoLOD MAN2.png|frameless]]


By default, the same presets will be applied to every renderer in the list.
By default, the same presets will be applied to every renderer in the list.
Line 22: Line 20:


You can also customize per-object settings by folding out targets in the list.
You can also customize per-object settings by folding out targets in the list.
 
[[File:Autolod_MAN3.png|center|frameless]]
[[File:Autolod MAN3.png|frameless]]


Both settings panels are identical, meaning that each object is fully customizable independantly from others or from the common settings.
Both settings panels are identical, meaning that each object is fully customizable independantly from others or from the common settings.
 
[[File:Autolod_MAN4.png|center|frameless]]
[[File:Autolod MAN4.png|frameless]]


The LODGroup Settings foldout let you control the LODGroup setup as it should be when created, but you can still change it manually when the process is over. You cannot interact with the LODGroup widget (which is NOT the actual widget, but just a representation), only the sliders LOD Levels, Seamless/Performant and Size Culling will influence it.
The LODGroup Settings foldout let you control the LODGroup setup as it should be when created, but you can still change it manually when the process is over. You cannot interact with the LODGroup widget (which is NOT the actual widget, but just a representation), only the sliders LOD Levels, Seamless/Performant and Size Culling will influence it.
[[File:Autolod_MAN5.png|center|frameless]]


[[File:Autolod MAN5.png|frameless]]
Since 4.0, decimated meshes will be saved to the assets, to the given path. If the path does not exist, the program will automatically create it for you.
 
You may want to save the decimated meshes to the assets. You just have to check the Save meshes to Assets toggle and enter a path. If the path does not exist, the program will automatically create it for you.


When you are ready, just click on the button <code>Generate LOD</code>
When you are ready, just click on the button <code>Generate LOD</code>
Line 40: Line 35:


* Minimalist interface and really easy to use
* Minimalist interface and really easy to use
* Exposes 2 backends to the users : a fast to be used for prototyping of dynamic usage, and a quality for higher quality outputs (since version 5.0)
* Works in both edit and play mode
* Works in both edit and play mode
* Works on prefabs instances (no need to unpack them)
* Works on prefabs instances (no need to unpack them)
* Generated objects can manually be saved as prefabs as long as the toggle <code>Save meshes to Assets</code> is checked with a valid path.
* You can change the default export path from <code>Edit->Preferences->AutoLOD Settings</code>
* Generates up to 8 LOD for a single object
* Generates up to 8 LOD for a single object
* Decimates UVs (from uv1 to uv4) and bone weights too.
* Decimates UVs (from uv1 to uv4) and bone weights too.
* Compatible with sub-meshes
* Compatible with sub-meshes
* Creates colliders for simplified meshes (if the source has one)
* Compatible with SkinnedMeshRenderers with bones and blendshapes support
* Can be used for simple distance culling too
* Can be used for simple distance culling too
* Fully compatible with any render pipeline
* Fully compatible with any render pipeline and any unity version since 2020.3 LTS.
 
== Backends ==
Since AutoLOD 5.0, you can now choose which backend you want to use between the fast or high quality. Both backends implement Fast quadric mesh simplification but the high quality preserves better UVs and preserve borders.
[[File:AutoLOD Backends.png|alt=Demonstration of AutoLOD embedded fast and HQ decimation backends|thumb|514x514px|AutoLOD embedded fast and HQ decimation backends]]
 
== Runtime API ==
All the following methods are part of the <code>AutoLOD.MeshDecimator</code> namespace.
 
; <code>void CFastMeshDecimator.Initialize()</code>
: Initializes the MeshDecimator with the Fast backend. This method sets up necessary components or variables required before the decimation process begins.
 
; <code>Mesh CFastMeshDecimator.DecimateMesh(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)</code>
: Decimates the provided mesh (''sourceMesh'') to a specified number of faces (''targetFaceCount'') using the Fast backend.
 
; <code>static Mesh CFastMeshDecimator.DecimateMeshStatic(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)</code>
: Provides a static method to decimate a mesh without needing an instance of the FastMeshDecimator class. It takes a mesh (''sourceMesh'') and decimates it to the specified number of faces (''targetFaceCount'') using the Fast backend.
 
; <code>void CQualityMeshDecimator.Initialize()</code>
: Initializes the MeshDecimator with the High Quality backend. This method sets up necessary components or variables required before the decimation process begins.
 
; <code>Mesh CQualityMeshDecimator.DecimateMesh(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)</code>
: Decimates the provided mesh (''sourceMesh'') to a specified number of faces (''targetFaceCount'') using the Quality backend.
 
; <code>static Mesh CQualityMeshDecimator.DecimateMeshStatic(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)</code>
: Provides a static method to decimate a mesh without needing an instance of the QualityMeshDecimator class. It takes a mesh (''sourceMesh'') and decimates it to the specified number of faces (''targetFaceCount'') using the Quality backend.
 
== Alternative Workflow ==
There are scenarios where you may want '''a single LODGroup for several renderers''', for example a props cluster. AutoLOD 5.2 brought a LODGroup-oriented workflow for this usecase. Just add a LODGroup (preferably on a common parent to all renderers you want to include) and add all renderers you want to include in the cluster in the LOD0 level (required). From the contextual menu, you will be able to generate all the missing LOD levels.
[[File:AutoLODgroupWorkflow.png|alt=The new LODGroup oriented workflow|none|thumb|421x421px]]
The reduction rate will be proportional to the transition height you entered in each LOD level, following this formula: <math display="block">ReductionRate = 1/TransitionHeightRatio</math>Both backends are available and a progress bar will keep you informled during the process.
 
If you want to fine-tune some LODs specifically, just delete the LOD's renderers and regenerate from the contextual menu. The LODs that already have renderers will be ketp untouched.
 
Please note that the meshes decimated using this method are saved in the default export folder that you can customize in the preferences <code>Edit->Preferences->AutoLOD Settings</code>


== Some tips ==
== Some tips ==


* A demo scene is provided in the Scene folder: click play and follow the instructions. The provided material in the scene should appear pink in LWRP/URP and HDRP. Feel free to upgrade the material to your render pipeline, or use your own material.
* A demo scene is provided in the Scene folder: click play and follow the instructions. The provided material in the scene should appear pink in LWRP/URP and HDRP. Feel free to upgrade the material to your render pipeline, or use your own material.
* The toggle Optimize Source Mesh applies a Automatic Decimation to the source mesh. It’s not recommended for detailed meshes, but it can help for basic shapes, such as a cube subdivided in more vertices than it should be.
* Setting 1 on LOD Levels will just apply a distance culling (and an automatic decimation if the toggle is enabled).
* Setting 1 on LOD Levels will just apply a distance culling (and an automatic decimation if the toggle is enabled).
* You can apply changes to a prefab instance, as long as the decimated mesh were saved to the Assets (otherwise the meshes will be missing, as they are stored in the scene data).
* You can apply changes to a prefab instance, as long as the decimated mesh were saved to the Assets (otherwise the meshes will be missing, as they are stored in the scene data).
Line 62: Line 91:
== Warnings ==
== Warnings ==


* Generation can take several minutes for a whole scene. Unity will freeze during the process but a progress bar will provide a visual estimation of what is happening. The progress bar is more precise for Unity 2020 and above than the previous releases.
* Generation can take a long time for a whole scene. Unity will freeze during the process but a progress bar will provide some progress report. The progress bar is more precise for Unity 2020 and above than the previous releases.
* If the processed object has specific components attached to it, they will remain but make sure they still work properly. If they were using the attached MeshFilter or Renderer, they will probably be broken, but it should be easy to fix in most cases.
* If the processed object has specific components attached to it, they will remain but make sure they still work properly. If they were using the attached MeshFilter or Renderer, they will probably be broken, but it should be easy to fix in most cases.
* Please check carefully which objects you put in AutoLOD and understand that there are just too many cases that can end up with bugs, especially with your MonoBehaviour scripts.
* Please check carefully which objects you put in AutoLOD and understand that there are just too many cases that can end up with bugs, especially with your MonoBehaviour scripts.
Line 69: Line 98:
Feel free to contact me via one of the social media availbale on the bottom of
Feel free to contact me via one of the social media availbale on the bottom of


the AutoLOD editor window or via e-mail: [mailto:chaumartinleo@gmail.com chaumartinleo@gmail.com]
the AutoLOD editor window or via e-mail: [mailto:support@leochaumartin.com support@leochaumartin.com]


== References ==
== References ==
https://github.com/Whinarn/MeshDecimator
https://github.com/Whinarn/MeshDecimator
https://github.com/crescent3983/UnityMeshDecimation

Latest revision as of 19:17, 23 March 2024

AutoLOD is a very simple tool that will generate a LOD group with any 3D

object from your scene. It will automatically compute simplified version of your

The AutoLOD editor window under several states of customization

meshes using decimation.

Setup

The whole package is contained in the AutoLOD folder resulting from the import. You can move it wherever you want, but it is recommended to keep the same folder structure.

How to use

AutoLOD consists in an editor window. You can open it via Window->AutoLOD->MeshDecimator.

How to open the window.png

Put the object(s) to be processed into the ”targets” area. Please note that a Renderer is required otherwise the object cannot be added.

AutoLOD MAN2.png

By default, the same presets will be applied to every renderer in the list.

You can customize these presets in the Custom Settings section.

You can also customize per-object settings by folding out targets in the list.

Autolod MAN3.png

Both settings panels are identical, meaning that each object is fully customizable independantly from others or from the common settings.

Autolod MAN4.png

The LODGroup Settings foldout let you control the LODGroup setup as it should be when created, but you can still change it manually when the process is over. You cannot interact with the LODGroup widget (which is NOT the actual widget, but just a representation), only the sliders LOD Levels, Seamless/Performant and Size Culling will influence it.

Autolod MAN5.png

Since 4.0, decimated meshes will be saved to the assets, to the given path. If the path does not exist, the program will automatically create it for you.

When you are ready, just click on the button Generate LOD

Features

  • Minimalist interface and really easy to use
  • Exposes 2 backends to the users : a fast to be used for prototyping of dynamic usage, and a quality for higher quality outputs (since version 5.0)
  • Works in both edit and play mode
  • Works on prefabs instances (no need to unpack them)
  • You can change the default export path from Edit->Preferences->AutoLOD Settings
  • Generates up to 8 LOD for a single object
  • Decimates UVs (from uv1 to uv4) and bone weights too.
  • Compatible with sub-meshes
  • Compatible with SkinnedMeshRenderers with bones and blendshapes support
  • Can be used for simple distance culling too
  • Fully compatible with any render pipeline and any unity version since 2020.3 LTS.

Backends

Since AutoLOD 5.0, you can now choose which backend you want to use between the fast or high quality. Both backends implement Fast quadric mesh simplification but the high quality preserves better UVs and preserve borders.

Demonstration of AutoLOD embedded fast and HQ decimation backends
AutoLOD embedded fast and HQ decimation backends

Runtime API

All the following methods are part of the AutoLOD.MeshDecimator namespace.

void CFastMeshDecimator.Initialize()
Initializes the MeshDecimator with the Fast backend. This method sets up necessary components or variables required before the decimation process begins.
Mesh CFastMeshDecimator.DecimateMesh(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)
Decimates the provided mesh (sourceMesh) to a specified number of faces (targetFaceCount) using the Fast backend.
static Mesh CFastMeshDecimator.DecimateMeshStatic(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)
Provides a static method to decimate a mesh without needing an instance of the FastMeshDecimator class. It takes a mesh (sourceMesh) and decimates it to the specified number of faces (targetFaceCount) using the Fast backend.
void CQualityMeshDecimator.Initialize()
Initializes the MeshDecimator with the High Quality backend. This method sets up necessary components or variables required before the decimation process begins.
Mesh CQualityMeshDecimator.DecimateMesh(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)
Decimates the provided mesh (sourceMesh) to a specified number of faces (targetFaceCount) using the Quality backend.
static Mesh CQualityMeshDecimator.DecimateMeshStatic(Mesh sourceMesh, int targetFaceCount, bool interpolateBlendshapes = false)
Provides a static method to decimate a mesh without needing an instance of the QualityMeshDecimator class. It takes a mesh (sourceMesh) and decimates it to the specified number of faces (targetFaceCount) using the Quality backend.

Alternative Workflow

There are scenarios where you may want a single LODGroup for several renderers, for example a props cluster. AutoLOD 5.2 brought a LODGroup-oriented workflow for this usecase. Just add a LODGroup (preferably on a common parent to all renderers you want to include) and add all renderers you want to include in the cluster in the LOD0 level (required). From the contextual menu, you will be able to generate all the missing LOD levels.

The new LODGroup oriented workflow

The reduction rate will be proportional to the transition height you entered in each LOD level, following this formula:

Both backends are available and a progress bar will keep you informled during the process.

If you want to fine-tune some LODs specifically, just delete the LOD's renderers and regenerate from the contextual menu. The LODs that already have renderers will be ketp untouched.

Please note that the meshes decimated using this method are saved in the default export folder that you can customize in the preferences Edit->Preferences->AutoLOD Settings

Some tips

  • A demo scene is provided in the Scene folder: click play and follow the instructions. The provided material in the scene should appear pink in LWRP/URP and HDRP. Feel free to upgrade the material to your render pipeline, or use your own material.
  • Setting 1 on LOD Levels will just apply a distance culling (and an automatic decimation if the toggle is enabled).
  • You can apply changes to a prefab instance, as long as the decimated mesh were saved to the Assets (otherwise the meshes will be missing, as they are stored in the scene data).
  • You can undo the whole AutoLOD process with Edit -> Undo
  • You can put several objects in the drag and drop area. AutoLOD will just add the valid ones to the list.
  • You can add a MeshRenderer or SkinnedMeshRenderer from its context menu in the inspector

Warnings

  • Generation can take a long time for a whole scene. Unity will freeze during the process but a progress bar will provide some progress report. The progress bar is more precise for Unity 2020 and above than the previous releases.
  • If the processed object has specific components attached to it, they will remain but make sure they still work properly. If they were using the attached MeshFilter or Renderer, they will probably be broken, but it should be easy to fix in most cases.
  • Please check carefully which objects you put in AutoLOD and understand that there are just too many cases that can end up with bugs, especially with your MonoBehaviour scripts.

Contact

Feel free to contact me via one of the social media availbale on the bottom of

the AutoLOD editor window or via e-mail: support@leochaumartin.com

References

https://github.com/Whinarn/MeshDecimator

https://github.com/crescent3983/UnityMeshDecimation