Decimate To Target
The "Decimate to Target" algorithm, based on the quadric error metric method, reduces the polycount by smartly deleting vertices, whilst preventing smoothing artifacts and topological irregularities
The algorithm is mainly controlled by a "Target Triangles Count" criterion, which is the number of triangles left after the decimation. Thus, this algorithm can be used to specify a target polycount to ensure that a model fits to the performance of a device for example.
It is also controlled by parameters meant to preserve geometric particularities topologically important
it might be more practical and faster than the "Decimate To Quality" method, but is also more destructive, less-preserving of the decimated objects topology, if you do not use functions controls properly.
Weighting
The "Decimate To Target" algorithm is based on edge collapse. First, it calculates a new vertex placing, and then computes a misplacement error score for each edge. The score is calculated by adding different geometrical deviations (boundaries, normals and UVs). Pixyz then removes in priority the edges generating the less errors until it reaches the targeted polygon count.
The user can influence the computed score by modifying the input weights: it will be multiplied with the corresponding parameter.
For example, if the usecase requires to preserve the optimized model from UV distortion, the "UV Weight" can be set to a higher level. For each edge, the UV error will be multiplied by this level. The global edge error for the edges displacing UVs will get higher error scores than the others, and thus will be deleted last.
TIP Good values for weights are 1, 10, 100 and 1000.
Maximum deviation
The user can also indicate a maximum deviation for some error parameters, meaning that the edges will not be removed if the displacement is higher than the input value.
WARNING Setting a max deviation can prevent from reaching the targeted polycount. Set the parameter "Force Target" to "True" to avoid this situation.
Behavior
The "Decimate To Target" algorithm takes the whole scene (or the whole list of occurrences) into consideration: although this algorithm operates at Mesh level, it is based on the whole set of Meshes (given as function input) to evaluate the target polycount.
It means that calling the function with a list of 10 meshes is different that calling 10 times the function with a single mesh each time. In the first case, the target will be reached for the whole set of mesh, while it will be reached for each mesh individually in the second case.
For AEC usecases (buildings, plants...), it is advised to call the function a single time with a list of all of the meshes, so that meshes made of a very few triangles such as walls are kept intact while the decimation focuses on denser meshes.
TIP Prior to performing a decimation, its is best to repair the model first, in order to reconnect potential cracks or gaps existing in the original model and prevent the decimation to accentuate them. Set the parameter "Orient" to false if you are happy with the polygons faces orientation and do not want to damage them. Repairing the mesh(es) may reconnect several vertices, which eliminates some boundaries and gives some slack to the decimation algorithm.
Advanced parameters
The algorithm only requires a polygon target (triangles count) to work.
Anyway, more control can be achieved using the parameters available in the "Advanced" tab:
- Use Vertex Weight: if True, this parameter uses colored vertices to preserve edges connected to these vertices from being deleted. Only vertices painted with a Red color (255,0,0) are considered
- Boundary Weight: This weight defines how important the edges defining the mesh boundaries (free edges) are during the decimation process, to preserve them from distortion
- Normal Weight: This weight defines how important vertex normals are during the decimation process, to preserve the smoothing of the mesh from being damaged
- UV Weight: This weight defines how important UVs (texture coordinates) are during the decimation process, to preserve them from being distorted (along with the textures using the UVs)
- Sharp Normal Weight: This weight defines how important sharp edges (or hard edges) are during the decimation process, to preserve them from being distorted
- UV Seam Weight: This weight defines how important UV seams (UV islands contours) are during the decimation process, to preserve them from being distorted (along with the textures using the UVs)
- Force Target: If True, this parameter forces the targeted polycount to be reached even if none of the constraints (max deviation parameters) is respected. In that case the decimation process will act in two passes: the first with respect of constraints and the second without
- Normal Max Deviation: This parameter constraints the maximum normals deviation (angle threshold) allowed during the decimation process
- Forbid UV Overlaps: This parameter forbids UVs to fold over and overlap each other during the decimation
- UV Max Deviation: This parameter constraints the maximum UV deviation (displacement) allowed during the decimation process
- UV Seam Max Deviation: This parameter constraints the maximum UV seams deviation (displacement) allowed during the decimation process
API function parameters
All algorithm parameters are listed and explained in the API documentation: