Mirroring an object with custom normals correctly

To mirror an object along X, Y or Z axis in Blender the “Miror” operator is usually used. For example, to mirror an object along the global X axis, in the 3D viewport window menu we need to select: Object – Miror – X Global. Or we can do it simpler just applying a scale of -1 to the object along the desired axis: s – x – -1. However, if there are custom normals on the object, they are not recalculated, which subsequently causes the appearance of various artifacts.

Let’s take the “Suzanne” object as an example and add custom normals to it. In the Properties area, open the Object Data tab and in the Geometry Data section, press the Add Custom Split Normals Data button. In the Modifiers tab, add the “NormalEdit” modifier to the object and set arbitrary values. Now, if we mirror an object in a standard way (s – x – -1) and apply a scale to it (Ctrl + a – Scale), it will be visually clear that normals was broken. At the same time, the “Mirror” modifier mirrors the object correctly, taking into account the custom normals.

We can mirror an object relative to the X axis with correct conversion of custom normals without using the “Mirror” modifier using the following script:

Original code author: Joey (blender.stackexchange).

In this code

We first recalculate custom normals and enable the auto-smoothing mode, which is necessary to work with them.

Next, for each mesh polygon, we rotate all the loops in the opposite direction, leaving the starting point unchanged.

After that, we mirror the normal on each loop relative to the X axis and save them in a separate list.

Actually mirror the mesh relative to the X axis:

Flip the normals

And add recalculated custom normals, already reflected relative to the X axis.

If we now apply scale to the mirrored mesh, to check custom normals, we will see that they are processed correctly.

For the same mirroring relative to other axes, we need to make minimal changes to the script in order to recalculate the required (Y or Z) component of the normals.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments