0
$\begingroup$

I have a mesh with custom split normals. When I look at the normals on the loops through python I see the values I expect, but when I look at the split normals visually in edit mode, they are quite different--and the shading matches what the view is showing.

How do I get the view to show the custom normal data I see in the mesh data with python?

I've tried C.object.data.calc_normals_split() but that copies the values I see in the view into the values I see in python. I want to go the other way.

Details:

C.object.data.loops[1967].vertex_index 
492

C.object.data.loops[1967].normal
Vector((-0.5192142128944397, 0.7101643681526184, 0.4754820466041565))

Viewing the object in edit mode with vertex 492 selected, showing split normals: enter image description here

You can see the y and z values of this split normal are negative whereas they are positive when I printed the loop normal.

$\endgroup$
4
  • $\begingroup$ Can you post screenshots of what it is you experiencing/ looking for? It's unclear just by reading. $\endgroup$
    – Jakemoyo
    Aug 16, 2022 at 17:00
  • $\begingroup$ Thanks - sure, added the code I'm using to test and an image $\endgroup$
    – Bad Dog
    Aug 16, 2022 at 17:24
  • 1
    $\begingroup$ Your problem is that there is a difference between a loop and vertex. Loop is a combination of one edge and one vertex. More info. I'm inclined to believe that if you're looking for the different split normals vectors for each vert then you'll want to go for something like obj.data.polygons.verts or in bmesh bm.faces.verts. Just looping over the verts by themselves will only produce the averaged normal, the split normals are most likely stored in the polygons or maybe the loops. $\endgroup$
    – Jakemoyo
    Aug 16, 2022 at 20:48
  • $\begingroup$ Yes, I know loop normals and vertex normals are different--that's why I was getting the normal from the loop in the example. And the normal in the pic is the split normal (cuz it's magenta.) Not sure about polygons and what they'd give. But see the answer I just posted. $\endgroup$
    – Bad Dog
    Aug 17, 2022 at 12:08

1 Answer 1

0
$\begingroup$

Turns out I needed to run update() on the mesh before trying to set the normals, and then I never got into the weird state in the question. I would love a tutorial on when the update() and calc_*() functions need to be called.

$\endgroup$

You must log in to answer this question.

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