cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Having a tool to quickly Normalise face normals

Having a tool to quickly Normalise face normals

Hello,

 

We recently noticed that if we have non normalised face normals on our meshes, the viewport2.0 will render visuals with broken reflections (as if the normals where different).

We currently have a slow python tool snippet to fix these normals:

import math
import maya.mel as mel
def normalize_normal():
mesh_to_vertices = cmds.polyListComponentConversion(toVertexFace=True)
cmds.select(mesh_to_vertices, replace=True)
all_vertices = cmds.ls(sl=True, l=True, flatten=True)
#print(all_vertices)
 
[action(i) for i in all_vertices]
def action(i):
cmds.select(i, replace=True)
#normals_xyz = cmds.polyNormalPerVertex(q=True , xyz=True)
normals_xyz = mel.eval("float $value2[] = `polyNormalPerVertex -q -xyz`;")
 
normals_x = normals_xyz[0]
normals_y = normals_xyz[1]
normals_z = normals_xyz[2]
 
#Formula
n= math.sqrt(pow(normals_x,2) +  pow(normals_y,2) + pow(normals_z,2))
x=normals_x/n
y=normals_y/n
z=normals_z/n
 
cmds.polyNormalPerVertex(xyz=(x, y, z))
 
normalize_normal()
 
Or the second "fix" is if we also apply a small rotation on meshes that also fixes the renderer issue.
more details can be found in case 18393186.

link to exemple files : https://a360.co/3kqva3z 


Thank you,

Morgan

 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea