From BlenderWiki

Jump to: navigation, search

Blender 2.62: Remesh Modifier

The Remesh modifier is a tool for generating new mesh topology based on an input surface. The output follows the surface curvature of the input, but its topology contains only quads.

Remesh-modifier-screenshot-00.png

Usage

In the modifier panel, add a Remesh modifier. (This modifier is only available for meshes.) The input mesh should have some thickness to it; if the input is completely flat, add a solify modifier above the remesh modifier.

Mode

There are three basic modes available in the remesh modifier: Blocks, Smooth and Sharp.

This example shows a cone with each of the different remesh modes. From left to right: original cone, Blocks, Smooth, and Sharp

Note that the output topology is almost identical between the three modes; what changes is the smoothing. In Blocks mode, there is no smoothing at all. The Smooth and Sharp modes generate similar output in places where the mesh is already smooth, but Sharp mode preserves sharp details better. In this example, the circular bottom of the cone and the top point of the cone are accurately reproduced in Sharp mode.

Octree Depth and Scale

The Octree Depth sets the resolution of the output. Low values will generate larger faces relative the input, higher values generate a denser output. The result can be tweaked further by setting the Scale; lower values effectively decrease the output resolution.

Input mesh, and the low to high resolution output meshes

Disconnected Pieces

To filter out small disconnected pieces of the output, enabled Remove Disconnected and set the threshold to control how small a disconnected component must be to be removed.

The input mesh (left) is fairly noisy, so the initial output of the remesh modifier (center) contains small disconnected pieces. Enabling Remove Disconnected Pieces (right) deletes those faces.

Sharpness

In Sharp mode, set the Sharpness value to control how closely the output follows sharp edges in the input (use lower values to filter out noise).

Demo Videos

Remesh modifier applied to text to improve topology

Implementation

The code was contributed to Blender by Dr. Tao Ju. See Ton's email: {Bf-committers} Code donation: "Dual contouring re-meshing".

Algorithm

Based on the paper "Dual Contouring of Hermite Data".

A quick explanation of dual contouring:

"Dual contouring generates vertices within a cubic cell, not along the cell edges (as Marching Cubes does). So DC has a lot of freedom of choosing where to place each vertex, and hence can reproduce sharp features by placing vertices along "edges" and "corners". DC computes these sharp feature locations using information obtained by scan-converting the input mesh, and specifically, using the intersection points between the original mesh and the cell edges together with the normals at those points (these are exactly what is written in the .dcf file). However, sometimes the vertex location computed from these points and normals may lie way outside the cell. While occasionally such vertices are "true" sharp features, usually they are caused by noise and error on the input mesh. So in the code, we pull back a vertex if it is too far outside the cell and place it at the average location of all intersections points along the cell edges (this is called a "Mass Point")." — Tao Ju

Code

The original code was modified to compile under GCC (fixing some nonstandard C usage that MSVC allows) and to work on 64-bit systems (pointers were being stored in 32-bit integers.) The mesh input/output code was also modified; the ModelReader interface remains, but the implementations for various formats were removed. The modified code was placed in intern/dualcon/intern/. The dual contouring code is C++, so a small wrapper is used to interface it with Blender. The wrapper's files are intern/dualcon/dualcon.h and intern/dualcon/intern/dualcon_c_api.cpp.

The code is currently available from the remesh-modifier branch of this git repository: nicholasbishop-blender. There now also a second branch based off bmesh: bmesh-remesh-modifier.

Code flow: made assumption that code in intern/ directory doesn't get to know much about Blender internals, so doesn't directly include BKE/DNA stuff. Not sure if correct assumption or not? If not, code could be simplified to use fewer callbacks stuff.

  • MOD_remesh.c:applyModifier() calls dualcon()
  • dualcon_c_api.cpp:dualcon() uses ModelReader subclass to wrap Blender mesh data into format expected by dual contouring code. Then octree object is created and its method scanConvert() is called.
  • octree.cpp:Octree::scanConvert() does all the remeshing magic and (via a callback pointed to dualcon_create_mesh) allocates a DerivedMesh to hold the output.