UnityMeshDecimation
Mesh Decimation for Unity
Install / Use
/learn @crescent3983/UnityMeshDecimationREADME
UnityMeshDecimation
Mesh Decimation for Unity.
This project is based on vcglib tridecimator but rewritten for Unity Mesh and add other features.
Charizard © Pokémon Ltd
Compatibility
Only tested with below versions but may be compatible with other versions.
| Version |------ | Unity 2018.4.x | Unity 2020.3.x
Usage
Use whole project or copy Assets/UnityMeshDecimation to your project
GUI
Open tool from menu Window/Unity Mesh Decimation
-
Input Mesh

-
End Condition

-
Edge Collapse Parameters

-
Output File

Script
using UnityMeshDecimation;
// End Condition
var conditions= new TargetConditions();
conditions.faceCount = 1000;
// Edge Collapse Parameters
var parameter = new EdgeCollapseParameter();
parameter.UsedProperty = VertexProperty.UV0;
var meshDecimation = new UnityMeshDecimation();
meshDecimation.Execute(inputMesh, parameter, conditions);
var outputMesh = meshDecimation.ToMesh();
Extra Weight
Besides adding vertex properties to Quadrics, you can also add extra weight to prevent moving on the bondery of property.
For example, one vertex has different uv coordinates on connected faces.
var parameter = new EdgeCollapseParameter();
parameter.UsedProperty = VertexProperty.UV0;
var property = parameter.GetPropertySetting(VertexProperty.UV0);
property.ExtraWeight = 1;
// Default sample function is self, but you can define a custom one.
// For example, use sampled color instead of uv coordinate.
// property.SampleFunc = (Vector4 value) => {
// return value;
// };
<table>
<tr>
<td>Position</td>
<td>Position, UV</td>
<td>Position, UV, UV extra weight</td>
</tr>
<tr>
<td><img src="./readme_assets/robot_none.png" width="500"/></td>
<td><img src="./readme_assets/robot_uv.png" width="500"/></td>
<td><img src="./readme_assets/robot_uv_extra.png" width="500"/></td>
</tr>
</table>
Example
- Lucy © Stanford University
- Robot © Unity Technologies
Quality Related
The final quality highly depends on the variants of properties. For exmaple, only position is the easiest one, just consider shape duration optimization.
But if you want to consider position, uv, normal etc. at the same time, it will lead to complicated computation, and is hard to find balance between them.
For example, the toon shading used by Arc System Works, the color regions are highly depends on the positions of vertex.
Even if you move slightly, it may lead to severe artifacts.
- Narmaya © Cygames, Inc
