Simplifying a 3D Mesh

 
Important Note

Outdated Version:
You are looking at an outdated documentation version for an older RapidCompact CLI distribution. If you are using a newer version of the CLI please refer to the documentation of the current CLI release version.

< previous page next page >

Within this tutorial, we are going to use RapidCompact CLI to simplify a 3D mesh. This process is sometimes also referred to as Mesh Reduction or as Mesh Decimation. The latter term, decimation, is used within the RapidCompact CLI options and settings.

Table of Contents
 

Decimation Parameters

back to top

RapidCompact CLI has several settings that can be used to control the decimation process:


Mesh Decimation

Name Type Default Valid Range Quick Description
decimation:collapseUnconnectedVertices Flag true {true, false} switches collapsing of nearby, unconnected vertices on/off
decimation:preserveCommonMeshBorders Flag true {true, false} preserves borders (vertices) common between meshes
decimation:preserveMaterialBorders Flag false {true, false} preserves mesh material borders during decimation
decimation:preserveNormals Flag false {true, false} preserves vertex normals during decimation
decimation:preserveTiledUVs Flag false {true, false} preserves repeating texture coordinates during decimation
decimation:preserveTopology Flag true {true, false} switches computation of new normals after decimation on or off
decimation:preserveUVs Flag false {true, false} preserves texture coordinates during decimation
decimation:recomputeNormals Flag true {true, false} switches computation of new normals after decimation on or off
decimation:boundaryPreservationFactor Real 0.5 {0 .. 1} factor to steer preservation of boundaries during decimation
decimation:collapseDistanceThreshold Real 0.005 {0 .. 0.10000000000000001} threshold w.r.t BBox diagonal for collapsing nearby vertices
decimation:tiledUVThreshold Real 1.5 {1 .. inf} UV extent after which a UV channel is considered repeating (= tiling texture)
decimation:defaultTarget String f:20000 ; f:; %; f:% target parameter for decimation during compact
decimation:method String quadric {'quadric', 'edgeLength'} method to be used for decimation

The first setting, decimation:qualityWeight can be used to give some vertices more quality weight than others in the decimation process. For example if there is the need to have a more dense topology in some areas, such as human faces, those can be weighted more compared to other areas of the mesh. decimation:preserveUVs and decimation:preserveMaterialBorders are working very well together if the texture coordinates and material coverage should be preserved while also simplifying the geometry. You can read more about this topic here. decimation:defaultTarget is a setting related to decimation, however, is only used when decimation is indirectly invoked using the compact (-c) master operation. The third setting is about the choice of keeping the original input normals also after decimation or computing entirely new ones, the latter is recommended for most cases and set as default. decimation:method, can be used to specify which method should be used for decimation. There are two methods available: "quadric" (the default) and "edgeLength". The setting decimation:preserveUVs is discussed within a separate tutorial. With decimation:preserveTopology, you can turn the strict preservation of topological features on or off. The last three settings, decimation:collapseUnconnectedVertices, decimation:boundaryPreservationFactor and decimation:collapseDistanceThreshold can be used to control (and enable / disable) the collapsing of unconnected, closeby vertices and, for the boundary preservation, to specify how strongly boundaries should be preserved during the decimation process. We will explore all of the settings for untextured meshes by example within the following paragraphs. Note that, within this tutorial, we will not use the --compact master operation (which also does some other things apart from decimating the mesh), but we will instead limit ourselves to the mesh decimation part.

Getting Started

To get started with the decimation functionality of RapidCompact CLI, we will use a simple example mesh of a scanned nefertiti bust, which you can download here.

This mesh has 1,5 million faces, which makes it a medium-sized data set. Although it could already be used like this for many visualization applications, some might require a variant that consists of less triangles, for example for quick rendering in a VR or game context. Another reason for generating a simplified version might be the reduction of bandwidth which is needed to transmit this mesh over a network (for example, for online presentation). Within the baking tutorial, we will see how to generate different texture maps, applied on the low-resolution asset, can help us to faithfully preserve the details of the high-resolution original. However, within this tutorial, we will just simplify the 3D geometry of the mesh.

 

Setting Target Values

back to top

To generate a simplified version of the nefertiti mesh, you can use the following command line:

    rpdx -i nefertiti.ply -d 2000 -e nefertiti-lowpoly.obj
    

This command will generate an OBJ file entitled nefertiti-lowpoly.obj, containing the simplified version of the input mesh. The decimate command, here abbreviated using the shorthand version d, accepts several parameters. By default, a number is interpreted as a target amount of vertices. However, you can also specify a target amount of faces, or a target percentage of vertices or faces. Examples:

The method used by default is the quadric method. There is also another one, which is entitled edgeLength. The edgeLength method is more simple and hence slightly faster, and it produces a resulting mesh where the triangles have a very regular distribution, which can be beneficial for some applications. However, the quadric method will be preferred in most cases, as it preserves features relatively well. The following figure shows a comparison of the results, using a strong simplification to 1% of the original vertices:

If you like, try out different values for decimation:boundaryPreservationFactor, in order to see which influence this parameter has on the final result. For this mesh of the nefertiti bust, it will influence the seam at the bottom, where the mesh is open because it has not been scanned from the bottom. The shape of this seam is pretty random anyway, therefore you may prefer not to explicitly preserve it in this case - above example images were generated with decimation:boundaryPreservationFactor set to zero. Within the next section, we will see where this parameter can come in more handy.
 

Advanced Simplification Commands

back to top

Now that we have studied the basics about simplifying a mesh with the RapidCompact CLI we will have a look at some functions for specific simplification use-cases by adding advanced commands:

 

Preserving Boundaries

back to top

A common artifact arising during simplification is deformation of open mesh boundaries. To experience this by example, we will use this model of a teapot.

To see what happens when a mesh is simplified without special constraints for the boundaries, set decimation:boundaryPreservationFactor to zero and run this command:

    rpdx -i teapot.obj -d v:500 -e reduced.obj
    

This will produce a reduced teapot that looks like this:

Not very satisfying, you would probably say. What looks especially ugly and "wrong" are the displaced boundary vertices, leading to the handle and spout floating somewhere in the air, instead of being connected to the body of the teapot. The reason for this is that the teapot's spout and handle were actually separate pieces that are not connected to the body's vertices within the original model. In such cases, it helps to apply some special constraints for the mesh boundaries. Setting decimation:boundaryPreservationFactor to 0.5 gives a much nicer result:

 

Preserving Topology

back to top

For most visualization applications, we obtain good result by decimating input meshes without caring about the topology of the result. This allows the simplification algorithm to remove small holes or handles, for example, when creating a low-poly approximation of the input mesh. However, for certain applications and certain input models, we may want to preserve the exact topology of the input, meaning: holes should never be closed, and handles and different surface parts should never be merged. Regarding the visual quality of the output, topology preservation can especially be useful when dealing with geometric details like fine strands. Here's an example mesh which we can use for a small test (original Hairball model courtesy of NVIDIA research): hairball.ply A detail view on it looks like the following:

We can simplify this input model to 25% of its faces, using the following command:

    rpdx -i hairball.ply -d f:25% -e result.ply
    

The result will look like the following:

As can be seen, the simplification took away some of the tips of the strands. It also allows, in principle, that the vertices of separate strands will get merged together, or that strands will get split up into multiple pieces possibly floating in the air, in other words: it allows for changes of the mesh topology. RapidCompact can be configured to forbid such changes, using the flag decimation:preserveTopology:

    rpdx -i hairball.ply -s decimation:preserveTopology true f:25% -e result-pt.ply
    

In this case, this will lead to a much better preservation of the many single strands of the hairball, and to a better preservation of its "volume", as no strands will be merged or torn apart by the simplification:

 

Merging Close Vertices

back to top

For certain meshes, especially those generated through CAD, the surface may be composed out of several parts, or patches. Such patches are often not explicitly connected at their boundaries, but instead vertex positions of two neighboring patch boundaries will simply match. Without boundary preservation, we might run into problems here, as those boundaries may "crack up" (compare the example of the teapot shown above). In such cases, we can also handle the problem differently: instead of preserving boundaries (using decimation:boundaryPreservationFactor), we can also weld them together. This effectively means that we are allowing the simplification method to merge nearby vertices, regardless of whether they belong to the same surface patch or not. This can be done using the setting decimation:collapseDistanceThreshold, which is a value relative to the model's bounding box diagonal. For this simple example mesh of two bent sheets, setting decimation:collapseDistanceThreshold to zero and performing decimation to 500 vertices will produce a result like this at the boundaries between both patches:

In constrast, by setting decimation:collapseDistanceThreshold to 0.1, we obtain a result where the boundary vertices of both sheets have been "welded" together:


< previous page next page >