Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Render a mesh with smooth vertex normals while preserving sharp corners
ResourceFunction["SmoothMeshNormals"][mreg] renders the mesh region mreg with both smooth surfaces and sharp corners. | |
ResourceFunction["SmoothMeshNormals"][mreg, θ] renders edges with a dihedral angle greater than θ as hard. | |
ResourceFunction["SmoothMeshNormals"][mreg, {e1,e2,…}] renders the edges with indices ei as hard. | |
ResourceFunction["SmoothMeshNormals"][mreg, {{f1,f2,…},…}] renders with the specified face smoothing groups. | |
ResourceFunction["SmoothMeshNormals"][…, form] gives the results in the format specified by form. |

| "Graphics3D" | Graphics3D object showing the smoothed mesh |
| "GraphicsComplex" | GraphicsComplex object representing the smoothed mesh |
| "SmoothingGroupGraphics3D" | Graphics3D object showing color-coded face smoothing groups |
| "SmoothFaceGroups" | list of smoothing group face indices |
| "SmoothFaceGraph" | Graph representing face smoothing groups |
| {form1,form2,…} | list of multiple forms formi |
Render a mesh with smooth curves and sharp edges:
| In[1]:= | ![]() |
| Out[1]= | ![]() |
Visualize the face smoothing groups:
| In[2]:= | ![]() |
| Out[2]= | ![]() |
SmoothMeshNormals works equally well with MeshRegion, BoundaryMeshRegion and other linear regions:
| In[3]:= |
| Out[3]= | ![]() |
| In[4]:= |
| Out[4]= | ![]() |
SmoothMeshNormals works with open and closed regions:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
Specify the dihedral angle threshold used to classify edges as hard:
| In[6]:= | ![]() |
| Out[6]= | ![]() |
A negative angle threshold will classify all edges as hard:
| In[7]:= | ![]() |
| Out[7]= | ![]() |
An angle threshold of Infinity will classify all edges as soft:
| In[8]:= | ![]() |
| Out[8]= | ![]() |
Specify the indices of the hard edges explicitly:
| In[9]:= | ![]() |
| Out[9]= | ![]() |
Use All to classify all edges as hard:
| In[10]:= | ![]() |
| Out[10]= | ![]() |
Use None to classify all edges as soft:
| In[11]:= | ![]() |
| Out[11]= | ![]() |
Specify the face smoothing groups explicitly:
| In[12]:= |
| In[13]:= | ![]() |
| Out[13]= | ![]() |
Visualize the specified smoothing groups:
| In[14]:= | ![]() |
| Out[14]= | ![]() |
Excluded face indices are considered to be in their own isolated smoothing group:
| In[15]:= | ![]() |
| Out[15]= | ![]() |
Use "Graphics" to get a graphics object with the partially smoothed surface:
| In[16]:= | ![]() |
| Out[16]= | ![]() |
Use "SmoothingGroupGraphics" to visualize the separate face smoothing groups with arbitrary colors:
| In[17]:= | ![]() |
| Out[17]= | ![]() |
Use "GraphicsComplex" to get the GraphicsComplex that represents the partially smoothed surface:
| In[18]:= | ![]() |
Apply custom styling:
| In[19]:= |
| Out[19]= | ![]() |
Use "SmoothFaceGraph" to get a Graph of adjacent faces connected by a soft edge:
| In[20]:= | ![]() |
| Out[20]= | ![]() |
The connected components of this graph represent the separate face smoothing groups:
| In[21]:= |
| Out[21]= |
These components can be returned directly using "SmoothFaceGroups":
| In[22]:= | ![]() |
| Out[22]= |
Use a list of multiple forms to avoid repeated computation:
| In[23]:= | ![]() |
| Out[23]= | ![]() |
SmoothMeshNormals may not smooth singular edges:
| In[24]:= |
| In[25]:= |
| Out[25]= | ![]() |
| In[26]:= |
| Out[26]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License