0
$\begingroup$

I'm a software developer, I have a external application that generates .obj files. After importing the generated model I see, only when the view is set to "Render" or to "Material", or when I disable auto smooth, that a lot of normal directions are flipped.

It's strange because they are perfect when auto-smooth is enabled. The model contain some hard edges, to avoid normal interpolation/smoothing in those I generate multiple vertices when they are in a hard-edge: each vertex will have the same position, but different normals.

I think that the normals are fine because I see their directions on my app and they are fine there, but Blender flips some of them. Why? Is the order of each vertex in each face important? Should I avoid having more than one vertex defined with the same position (having more vertex normals than vertex positions)?

EDIT: I changed my program to avoid repeating vertex positions, now it contains more vertex normals than vertex positions.

EDIT 2: Changed my program to delete duplicated normals, problem persists.

EDIT 3: Changed my program to order the vertices in each face. It seams that Blender overrides the normals written in the .obj file... This solves the problem for the cube model below, but it doesn't solve it when the model is smooth but have some hard edges... Blender keeps changing the normals, overriding the imported ones >:

My app, face color depends on the interpolated normal. The result is OK

Blender view after disabling auto-smooth, it looks awful, normals seems to be averaged

.obj file that I imported on Blender. Seems good to me.

    o Robot
v 0.100000 -0.100000 -0.100000
v 0.100000 0.100000 -0.100000
v 0.100000 0.100000 0.100000
v 0.100000 -0.100000 0.100000
v -0.100000 0.100000 -0.100000
v -0.100000 -0.100000 0.100000
v -0.100000 0.100000 0.100000
v -0.100000 -0.100000 -0.100000
vn 1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 -1.000000 0.000000

f 1//1 2//1 3//1
f 4//1 1//1 3//1
f 5//2 2//2 3//2
f 6//3 3//3 7//3
f 4//3 3//3 6//3
f 8//4 1//4 5//4
f 7//2 3//2 5//2
f 2//4 5//4 1//4
f 8//5 5//5 7//5
f 6//5 8//5 7//5
f 6//6 8//6 4//6
f 8//6 1//6 4//6
$\endgroup$
  • $\begingroup$ Could you post some images of the results your are getting, both from blender and your application. Would be interesting to see the object in edit mode showing normals and how it should be looking. Could you also provide a as simplified file as possible reproducing the problem $\endgroup$ – Duarte Farrajota Ramos Apr 28 '17 at 0:42
  • $\begingroup$ I posted the images and the .obj file (I made a change in my program too, described after "EDIT:", but it didn't resolve the problem) $\endgroup$ – dv1729 Apr 28 '17 at 10:58
  • $\begingroup$ Never mind, I read the .obj file again, its clearly bugged... Sorry $\endgroup$ – dv1729 Apr 28 '17 at 11:03
  • $\begingroup$ Edited again, problem persists... $\endgroup$ – dv1729 Apr 28 '17 at 11:28
  • $\begingroup$ I don't know enough about this, but it seems you are using split normals (ie more than one normal per vertex), and from the screenshot they don't seem to be pointing in the expected direction. If you clear them, or apply an edge split modifier it might look better. $\endgroup$ – Duarte Farrajota Ramos Apr 28 '17 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.