Maya Mel Script: vrnNormalifique

Tutorial / 20 May 2020

The short version and an important notice!

This script builds on the idea of having weighted vertex normals and allows the user to "snap" normals to faces to create better looking smoothing for low poly hard surface objects. It does not lock unnecessary vertex normals and does not break hard edges which differentiates it from all other similar scripts out there!
I've made this script some time ago while I still had my Maya license. Due to various reasons (detailed here and here), I have ditched Maya for Blender. At the time of this blog post I do not own a Maya license and since it's illegal to use the Student Version for any commercial work like putting scripts on Gumroad or recording free tutorials on Youtube I cannot take screenshots or do a tutorial on how to use my script. I hope this will change at some point as Maya Indie becomes available worldwide and I buy a subscription.


Special Thanks!

This is a result of more than 5 years of going through different versions and seeing this implemented in different ways in Maya.
Special thanks to AMC Romania, Infinity Ward and more recently Arkane Studios for the projects that required face snapped normals and the inspiration for me to think this script through!


A bit of technical background

(Feel free to skip this section if you're familiar to how weighted normals work)

A couple of years ago Autodesk introduced weighted vertex normals to Maya, paving the way to better vertex normal shading. 

For each vertex in a mesh, the new algorithm would calculate the normal as a weighted average of the surrounding faces' normals. The weighting is done by surface area so the resulting normal will align more with the larger faces.

The advantages are significant for low poly meshes since it reduces the amount of gradients in the shading. These lesser gradients also get reflected in less gradients in baked normal maps which make these normal maps easier to compress and reduce those bad shading artifacts that are caused by the compression algorithm.

The script will align (and lock) the vertex normals of the current selection to the normals of the selected faces. The effect is similar to Maya's weighted normals setting but the resulting normals will be "snapped" rather than just weighted.

This allows for smoother shading on low poly hard surface materials that use bevels. This will also result in cleaner normal map bakes with less gradients which in turn will cause less normal map compression artifacts.


You can download my script here:

https://gum.co/vrnNormalifique

Installation:

1. Copy the files into the script directory, usually:

My Documents/maya/<version>/scripts

2. Restart Maya or execute "rehash" in the Script Editor.


Usage:

Call the function with either commands:

vrnNormalifique(0);

-will set the perimeter normals so that they snap to the current

selected faces

vrnNormalifique(1);

-will set all the normals in the current selection to the average normal

of the entire selection

Bonus commands:

vrnSoftEdge;

-softens edges while keeping custom normals

vrnCopyNormal;

-copies the normal of the current selection

vrnPasteNormal;

-pastes the normal to the current selection


Requirements:

Maya 2017 or newer (might work in previous versions although not tested)


Version History:

v 0.1 alpha

-initial version

-limitation: internal hard edges relative to initial selection are

not preserved

v 0.2 beta

-added vrnSoftEdge procedure which soften edges while preserving custom normals

-rewrote from scratch with new logic based on vrnSoftEdge

v 1

-initial public release

-fixed some bugs

v 1.1

-added bonus vrnCopyNormal and vrnPasteNormal