Repair Mesh
A good mesh repair is key for a good optimization.
Indeed before being optimized, a mesh needs to be clean, meaning with connected edges, no overlapping triangles, with triangles' faces oriented consistently and in the correct direction, etc...
A simple example showing how important repaired meshes are is decimation: have a look at this page.
To repair meshes, you need to use the Repair Mesh function, available in the Mesh Menu.
What it does
The Repair Mesh function automatically performs several actions:
Detect and remove duplicated triangles
Some triangles can be duplicated multiple times and overlapping (meaning with coincident vertices), making the polycount too high and potentially creating visual artifacts (Z-fighting).
The process removes them: only one triangle is preserved.
This is automatic: no parameter needs to be enabled in the dialog box.
Vertices welding (proximity tolerance)
This process welds, or merges, together vertices that have the same position (using a tolerance) but different attributes.
Typically, non-manifold borders of a mesh or hard edges are candidates for welding, and the welding will recreate connectivity information at those locations if vertices fall into the given tolerance.
The tolerance is given in the "Tolerance" parameter:
The default value is 0.1mm and generally gives good results.
Sew mesh boundaries
To avoid having visible gaps and cracks in the input mesh, this process sews (stitches) boundaries that are unconnected:
Unconnected boundaries are closed even if the vertices are not coincident by fixing T-junctions:
The tolerance is given in the "Tolerance" parameter (the same value is used for welding and sewing boundaries):
The default value is 0.1mm and generally gives good results.
If gaps bigger than 0.1mm are observed on the meshes, this value needs to be raised, but not too much in order to avoid removing gaps that are part of the mesh topology, like a hole or a marking for example.
TIP In Pixyz Studio, disconnected edges (also called free boundaries) are represented as blue edges when the wireframe is turned on.
Removing degenerate triangles
This process removes degenerate triangles, meaning triangles that are almost flat (all boundaries overlapping).
This is automatic: no parameter needs to be enabled in the dialog box.
Fixing Orientation of adjacent faces consistently
Orienting triangles faces consistently on a model's meshes is one the biggest challenges regarding 3D Data Preparation.
Indeed in most cases, Real-time 3D apps use single-sided materials (or shaders) in order to preserve performance, by rendering only the faces of the mesh that are visible to the camera/user.
This requires meshes to have their triangles faces properly and consistently oriented (see About Face and Vertex Normals).
In the Repair Mesh dialog box, when the parameter "Orient" is enabled, the Orient algorithm is run, trying to orient all the adjacent faces of each mesh consistently.
This actually does two things: find potential strips of triangles that form a Möbius strip and crack it. Then, orient triangles so that all triangles in the same strip are oriented the same way.
NOTE Saying that a face is correctly oriented can often be subjective, as it depends on the position of the viewer. The orientation of the faces in the Repair Mesh algorithm aims at normalizing the orientation on a continuous set of triangles, but it cannot ensure that the final result will be correct for the user.
Although it fixes everything on most volumetric shapes (such as CAD models), the Orient algorithm can have trouble orienting faces properly (as the user would expect) when dealing with surfaces, or shells (as opposed to closed volumes).
To help the algorithm get the best result possible on this kind of meshes, the "Crack Non Manifold" parameter splits non-manifold edges to get two or more manifold edges, when possible.
TIP Set the parameter "Orient" to false if you are happy with the triangles faces orientation and do not want to damage it!
Pixyz offers other functions and methods to help orienting the faces of a model correctly:
- Automatically or semi-automatically using the dedicated functions in the Mesh Menu:
For example, Orient Faces From Current View and Smart Orient Faces will generate point of views to help get a correct faces orientation. - Manually: by manually selecting faces in the scene (with the Selection Mode) and using the Invert Faces Orientation command:
TIP To easily spot triangles' faces that are misoriented in the viewport, set the Backface culling rendering mode to "BF Color" to draw them with a flat pink color.
General behavior
The Repair Mesh function will repair the meshes existing in a part independently from other parts of the scene.
So if 2 meshes boundaries need to be stitched together, are if some triangles faces need to be oriented consistently to each other, they need to be in the same part.
Use the merging functions from the Scene Menu to merge parts together.
If no part is selected in the scene, the Repair Mesh will be executed on all the parts of the scene (hidden parts included).
If you wish to repair only some targeted parts, select them first.
Example
Here is an example of a mesh that requires repair: it is a car door which has disconnected edges (blue edges) within the mesh and inverted triangles faces (pink faces).
Applying the Repair Mesh function with default values repairs the mesh, saving a few triangles, and making it ready to use, or ready or for further optimization.
To go further
Beside the Repair Mesh function, there are a lot of mesh repair functions available in Pixyz core. You can find them in the Function List (F12), in the module Algo.
Each sub-process of the Repair Mesh function explained above can be found as a unitary function, to be executed separately, giving sometimes more control over the parameterization.
To name a few:
- Remove Degenerated Polygons: removes almost flat polygons (within the given tolerance)
- Merge Vertices: welds vertices (see above)
- Orient Normals: orients vertices normals consistently with faces normals (see About Face and Vertex Normals)