MayaPython_AverageNormalsToUVs

January 26, 2024 · View on GitHub

a maya python plugin to write average normals of a mesh into uvs, by maya.api.OpenMaya library

Prerequisites

  • Enable dx11shader.mll in Maya plugin manager for shader preview

Procedure

  • For each object in the selection list
    • Store original vertex normals for recovery
    • Average vertex normals
    • Fetch averaged vertex normal at face-vertex level and encode it into UV2 with octahedron compression
    • Restore to original normals
    • Decode average normals in vertex shader

Demo

Comparison

Tips

  • Create a new dx11shader material and link it to /Shader/DXS_NormalDisplay.
  • Check out Surface Data bound with corresponding semantics in dx11ShaderMaterial
  • Before executing [AverageNormalsToUVs.py],
    • History clear up in Atrribute Editor
    • Make sure there are 3 UV sets in the model, and UV values are not NULL.
    • Check out UV index order with [PrintUVSets.py] cuz it’s not always in order as UV Editor presents.
  • maya.api.OpenMaya not work on skinned mesh UV(don't know why), so here is a replacement by maya.cmds.

Ref

Maya工作流的平滑法线描边小工具

Octahedron normal vector encoding

[Maya API] Vertex tangent space