1
$\begingroup$

I can't find a way to achieve custom split normal effect. I want to use python (mesh normal/hard edge or soft edge) data collected from Maya then write to Blender mesh.

How to do it using the following Python API and how?

bpy.data.meshes[objName].normals_split_custom_set_from_vertices

bmesh module

$\endgroup$

1 Answer 1

3
$\begingroup$

Custom Split Normals

Elaborating on this answer and here

Test script. Run in object mode. Switch to edit mode to see results.

import bpy

context = bpy.context
ob = context.object
me = ob.data
# visualize in edit mode    
me.show_normal_vertex = me.show_normal_loop = True
me.use_auto_smooth = True
# normal custom verts on each axis
me.normals_split_custom_set([(0, 0, 0) for l in me.loops])

enter image description here end up with custom split normals in each of the corner directions. Blue are the vert normals

# all custom split normals pointing up.
normals = [(0, 0, 1) for v in me.vertices]
# make csn's all face up.  
me.normals_split_custom_set_from_vertices(normals)

enter image description here all custom split normals facing up (0, 0, 1)

I am not aware if custom split normals can be accessed from bmesh.

$\endgroup$
3
  • $\begingroup$ really appreciate, I got your idea, and to get a hard/soft edge effect, except setting custom normal split, what else I need? setting sharp edge? $\endgroup$ Mar 22, 2018 at 1:15
  • $\begingroup$ I try it, and I think it is no need to mark sharp edge, I get same hard/soft edge effect like same mesh in Maya.what's your idea? $\endgroup$ Mar 22, 2018 at 1:38
  • $\begingroup$ @XuqiangZhang forgot to mention needs to be run in object mode. $\endgroup$
    – batFINGER
    Mar 22, 2018 at 4:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .