Skip to content

crescent3983/UnityMeshDecimation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnityMeshDecimation

中文版說明

Mesh Decimation for Unity.

This project is based on vcglib tridecimator but rewritten for Unity Mesh and add other features.

Input 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

    Input

  • End Condition

    End Condition

  • Edge Collapse Parameters

    Profile

  • Output File

    Output

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;
// };
Position Position, UV Position, UV, UV extra weight

Example

  • Lucy © Stanford University
99970 tris
(Source)
50000 tris
(50%)
10000 tris
(10%)
  • Robot © Unity Technologies
6132 tris
(Source)
3000 tris
(50%)
600 tris
(10%)

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
87753 tris
(Source)
48909 tris
(55%)

Releases

No releases published

Packages

No packages published

Languages