Simplify Shape

Simplify is a shape intended for decimating the number of triangles in a mesh with the smaller possible error. It is based on paper

*"Surface Simplification Using Quadric Error Metrics"*by Michael Garland Paul S. Heckbert. My code is based on code from Sven Forstmann's https://github.com/sp4cerat/Fast-Quadri ... lification.

The following properties can be used to define a simplification step in geometry transformation pipeline:

Code: Select all

```
scene.shapes.obj_whitesimplify.type = simplify
# Original mesh name
scene.shapes.obj_whitesimplify.source = obj_whitedisp
# Decimate the triangles up to a 25% of the original mesh
scene.shapes.obj_whitesimplify.target = 0.25
# Scale the error according the size of the triangle edges on film plane (disabled by default)
scene.shapes.obj_whitesimplify.edgescreensize = 0.01
# A flag to avoid touch mesh borders (in order to avoids cracks, etc.)
scene.shapes.obj_whitesimplify.preserveborder = 0
```

Code: Select all

```
[SDL][0.095] Simplify shape obj_whitedisp with target 0.25
[SDL][0.388] Simplify iteration 0 (13107 edge candidates, deleted 7598/7598 of 131072 triangles)
[SDL][0.574] Simplify iteration 1 (13107 edge candidates, deleted 5169/12767 of 131072 triangles)
[SDL][0.752] Simplify iteration 2 (13107 edge candidates, deleted 4730/17497 of 131072 triangles)
[SDL][0.927] Simplify iteration 3 (13107 edge candidates, deleted 5259/22756 of 131072 triangles)
[SDL][1.095] Simplify iteration 4 (13107 edge candidates, deleted 5674/28430 of 131072 triangles)
[SDL][1.256] Simplify iteration 5 (13107 edge candidates, deleted 5434/33864 of 131072 triangles)
[SDL][1.408] Simplify iteration 6 (13107 edge candidates, deleted 5654/39518 of 131072 triangles)
[SDL][1.554] Simplify iteration 7 (13107 edge candidates, deleted 5824/45342 of 131072 triangles)
[SDL][1.691] Simplify iteration 8 (13107 edge candidates, deleted 5896/51238 of 131072 triangles)
[SDL][1.821] Simplify iteration 9 (13107 edge candidates, deleted 5879/57117 of 131072 triangles)
[SDL][1.942] Simplify iteration 10 (13107 edge candidates, deleted 5711/62828 of 131072 triangles)
[SDL][2.039] Simplify iteration 11 (13107 edge candidates, deleted 5571/68399 of 131072 triangles)
[SDL][2.130] Simplify iteration 12 (13107 edge candidates, deleted 6013/74412 of 131072 triangles)
[SDL][2.216] Simplify iteration 13 (13107 edge candidates, deleted 6900/81312 of 131072 triangles)
[SDL][2.295] Simplify iteration 14 (13107 edge candidates, deleted 7454/88766 of 131072 triangles)
[SDL][2.365] Simplify iteration 15 (13107 edge candidates, deleted 7440/96206 of 131072 triangles)
[SDL][2.425] Simplify iteration 16 (13107 edge candidates, deleted 6898/103104 of 131072 triangles)
[SDL][2.427] Subdivided shape from 131072 to 27968 faces
```

This is an example of the main reason I implemented this new shape: for the Mesh => Subdivide => Displace => Simplify chain of geometric transformations.

.edgescreensize property

".edgescreensize" can be used to scale the geometric error by the size of the triangle on the screen. This is an example:

It should be easy to understand where the camera was positioned at the time of the decimation: out of view and far triangles are more decimated than the near one.

Normal, UV, Color and Alpha vertex information

To correctly evaluated the decimation error accounting for Vertex position and Normal would require to work on a 6-D space, for Position+Normal+UV would require a 8-D space, etc.

It is clearly not easily manageable so I'm working only with position and interpolating other vertex attributes.

This can introduce some slight error. This is an example of the UV error, the original mesh:

the simplified one:

This isn't usually a problem for natural patterns like rocks, etc. it is more visible with regular geometric pattern like the one above.

LuxCore geometry pipeline

As you may have noticed, the LuxCore geometry pipeline is becoming a quite powerful tool. For instance, this image

is the result of:

1) load a sphere low poly mesh;

2) subdivide the mesh to have a regular high poly count;

3) apply vector displacement;

4) apply harlequin pattern to the mesh;

4bis) simplify the result;

5bis) apply harlequin pattern to the mesh;

(i.e. you can build a tree, not just a pipeline).