In 3D data preparation, it can be required to reach a specific polycount to properly display a 3D model on a particular device or platform (e.g. a maximum of 100 000 triangles is advised for HoloLens).

There are many possibilities to achieve that with Pixyz Studio, but the most direct way is by decimating meshes, using the "Decimate To Target" function.

"Decimate To Target" reduces meshes density until a targeted polycount is reached.


The function is available from the Optimize Mesh Menu.


Parameters

The function is mainly controlled by a "Triangle Count" criterion (or "Triangle ratio"), which is the number of triangles left after the decimation. 


More control over the reduction can be achieved using the parameters available in the "Advanced" tab.

They are meant to preserve the model's UVs and topology, and set the method used for decimating the model:


Parameter

Description

UV Importance

This parameters defines how UVs (texture coordinates) should be preserved during the decimation process:

  • Preserve Seams And Reduce Deformation: preserves UV seams (UV islands contours) from being displaced, and UV islands from being distorted, stretched (along with the textures using the UVs).
  • Preserve Seams: specifically preserves UV seams (UV islands contours) from being displaced, without trying to preserve other UV information.
  • Ignore UV: UVs are not preserved at all when decimating, resulting in potential UV and textures stretching/displacement/overlapping.

NOTE                Choosing "Ignore UV" does not give the same result as decimating meshes with no UV at all: UVs are still attributes potentially preventing decimation from delivering the best result (see here).

Protect Topology

If disabled (default), important topological singularities of the mesh (like holes for example) can change and some edges can become non-manifold. But the visual quality will be better on model with complex topology, because you let the algorithm get to a better overall result rather than trying to preserve topological singularities at all costs.

If keeping the topology of your model is important, enable the parameter.

Iterative Threshold

This parameter enables a different method for decimating large models, like industrial models with a very high polycount (several millions). 
Indeed this type of models require a large quantity of memory to be processed, requiring a different, iterative decimation method. 

The iterative method is triggered when the quantity of triangles to decimate is higher than the threshold.

So you should set the number of triangles according to your computer memory capacity. As a rule of thumb, count 5 GB of RAM for 1,000,000 triangles.


WARNING        If the available memory is not sufficient to process the model, your CPU might swap and slow down your computer dramatically.


General behavior

The "Decimate To Target" function takes the whole scene (or the whole list of occurrences defined as input) into consideration: although this algorithm operates at Part level (on the meshes), it is based on the whole set of Parts (given as function input) to evaluate the target polycount. 

It means that calling the function with a list of 10 Parts is different from calling 10 times the function with a single Part 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 use cases (buildings, houses...), it is advised to call the function a single time with a list of all of the Parts, so that meshes made of a very few triangles such as walls or windows are kept intact while the decimation focuses on denser meshes.


About the algorithm

The algorithm behind the "Decimate to Target" function is based on the Quadric error metric method, that reduces the density of a mesh by collapsing its edges:



First, the algorithm 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). 

Then, it removes in priority the edges generating the less errors until it reaches the targeted polycount. 

The user can influence the computed score by modifying the "UV Importance" parameter. The global edge error for the edges displacing UVs will get higher error scores than the others, and thus will be deleted last.

Examples

Here are simple examples explaining how to setup the "Decimate To Target" function:

Game model

With the Game asset below, here is how parameters should be set in order to obtain a beautifully decimated model:

  1. Repair mesh: as explained here, it is better to repair a mesh before decimating in order to reconnect edges and avoid gaps
  2. Target Strategy: Here the model is already quite low poly for a character (~35k triangles), so the target should not be too low, but it mostly depends on how far from the camera the decimated model will be. Let's try the default 10 000 triangles value (~30%).
  3. Setting other parameters: 

Parameter

Parameter value

Explanation

UV Importance

Preserve Seams And Reduce Deformation

UVs need to be preserved, because our model has textures applied. These textures play a great role at making it look good. We do not want them to be too distorted

Protect Topology

Enabled

Enable it in order to preserve the panda's topological singularities (e.g. the eye sockets) as much as possible


As you can see below, when the parameter is disabled, the holes like the eyes and the mouth are starting to stretch a little:


Iterative Threshold

Disabled

No need to enable it as the model is very low poly and will not require a lot of memory to be processed by the decimation function


Here is the result of the decimation, that reduced the model and preserved the required attributes:



NOTE                With this animated model, skins, bones and animation were also properly preserved during the decimation process!


CAD model

With the CAD / Hard surface model below, which is a car door, here is how parameters should be set in order to obtain a beautifully decimated model:

  1. Repair mesh: as explained here, it is better to repair a mesh before decimating in order to reconnect edges and avoid gaps
  2. Target Strategy: Here the model is quite dense (~18k triangles), so there is room for a good reduction. Let's try keeping 10%.
  3. Setting other parameters:


Parameter

Parameter value

Explanation

UV Importance

Ignore UV

This model, like most CAD model has no UVs (they can of course be added afterwards if necessary)
Anyway as explained here, it can be interesting to check first if the model has UVs that might prevent the decimation to reduce as strongly as required, and remove them.

Protect Topology

Enabled

As the door panel has a rather simple topology, it is preferable to enable this parameter to try to keep its topological singularities like the small holes at the bottom

Iterative Threshold

Disabled

No need to enable it as the model is very low poly and will not require a lot of memory to be processed by the decimation function


Here is the result of the decimation, that reduced the model and preserved the required attributes:


API function parameters

Check the API Reference page to learn how to use this function in Python code:


Related topics