Keep hard edges on import and export?

   6099   7   1
User Avatar
Member
464 posts
Joined: Aug. 2014
Offline
Hello everyone.
I'm a very fresh Houdini Apprentice user. I'm barely a week into it, so I might be asking about some obvious things. ops:

I ran into two problems when importing and exporting geometry.

1. Is it possible to retain hard edges from an OBJ file imported with a File SOP? The object gets smoothed on import, and all vertex normals seem to be lost. I've read some threads here on the forum about this, but I still have no clue on how to get those normals back.
Oops. This was a user-error. I picked the wrong file version. But the second question is still valid.

2. If I write a geometry to an OBJ file with a ROP Output Driver, I end up with all edges hardened. How do I tell Houdini to keep vertex normals in the exported file?

AJ
User Avatar
Member
28 posts
Joined: Dec. 2012
Offline
I fully admit I'm a relative newbie to the Houdini giants on this forum, but I'd suggest you look at the Facet SOP. There are check boxes for computing normals, as well as an option to cusp polygons to ‘permanently’ set their hardness.

A copy of your file would be helpful!
User Avatar
Member
464 posts
Joined: Aug. 2014
Offline
Hello Cradders, and thank you for your response.
Cradders
I fully admit I'm a relative newbie to the Houdini giants on this forum, but I'd suggest you look at the Facet SOP. There are check boxes for computing normals, as well as an option to cusp polygons to ‘permanently’ set their hardness.
I'd like to avoid re-creating vertex normals inside Houdini, and rather re-use existing hard edges from imported OBJ file.

It turns out it's more trickier than I thought it is. When I import the object, at first it seems that Houdini preserves object's vertex normals (the model looks correct after the OBJ is imported into the scene), but they break immediately after I transform the mesh with xform.

What is interesting, is that transformations on object level do not cause vertex normals to break. Why?

I've prepared a very simple scene as an example, so you can see what I mean.

Regarding my second question. You can try to export the mesh with either the ROP Driver or with RMB->“Save Geometry…” command, and compare the vertex normals from the original OBJ file to what Houdini exported. You'll notice that the exported mesh contains only hard edges.

I'm sure the original vertex normals are somewhere out there… I can see them as vertex attributes in the details view. I tried promoting these attributes to points, but it was a bad idea, since there are fewer points than vertices.
I have no idea how to extract those normals and re-apply on the geo before exporting it back to file.

Attachments:
test.hipnc (58.2 KB)
input_geometry.zip (3.0 KB)

User Avatar
Member
4189 posts
Joined: June 2012
Offline
no time to check your file but try unchecking ‘Recompute Point Normals’ on Transform node
User Avatar
Member
464 posts
Joined: Aug. 2014
Offline
MartybNz
no time to check your file but try unchecking ‘Recompute Point Normals’ on Transform node
Cool! Many thanks MartybNz. This fixed the problem with normals being ditched by xform transformations.
But another (off-topic) question arises. When is it useful to recompute point normals? I mean, in what part of Houdini having this option enabled is the most helpful?
I still have difficulties understanding the point entity, how it relates to a vertex, and how it is different from it.
User Avatar
Member
4189 posts
Joined: June 2012
Offline
Have a read through this page on an explanation of geometry attributes:

http://www.sidefx.com/docs/houdini13.0/model/attributes [sidefx.com]
User Avatar
Member
464 posts
Joined: Aug. 2014
Offline
MartybNz
Have a read through this page on an explanation of geometry attributes:

http://www.sidefx.com/docs/houdini13.0/model/attributes [sidefx.com]
So, a point is Houdini's term for naming what other 3d packages simply call vertices. On the other hand, Houdini's vertices are… vertices that constitute a single primitive (polygon). Nice.

Anyway, I'd like to return to my main question.
I'll rephrase it:
Is it possible to import a mesh that has predefined hard edges (or smoothing groups), and then export it from Houdini with normals intact, while preserving vertex order at the same time?

—–
EDIT: I was browsing the forum in order to find an answer to my question, and I stumbled upon this post by Antoine Durr: https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=88831#88831 [sidefx.com]
(…)The process of saving to .obj (which uses the gwavefront standalone) converts point normals and calls them vertex normals inside the .obj. Vertex normals are ignored. It is probably time to refile that RFE for gwavefront to handle vertex normals.

It looks like gwavefront.exe might be the culprit. It doesn't matter if I have vertex normal attributes or not, because they are ignored by the exporter. And if I make points unique and promote my vertex normals to point normals, I end up with separated faces (and no soft-edges), which is not what I want.

I guess that in order to accomplish what I need, I'd have to write a custom OBJ exporter that respects vertex normals. Unless somebody already did this, and is kind enough too share it perhaps?
User Avatar
Member
464 posts
Joined: Aug. 2014
Offline
I wrote a very simple OBJ exporter in Python. It preserves points order, uvs, and most importantly, vertex normals.
And all would be perfectly fine and dandy, if it didn't flip primitive facing in the exported file. So, in order to export geometry with correct facing, I need to place a Reverse SOP first.

I suspect I might have messed something up in a loop that iterates through vertices of primitives. But it does so in order from Prim.vertices().
I tried reversing the loop (reversed(Prim.vertices()) but then, while the primitives indeed get reversed, it also causes a change in their winding, which of course leads to a slightly different shading (due to reversed tessellation) and is unacceptable.

Until I find where the problem lies, I'd like to reverse facings of all polygons of a given instance of a Geometry class with the code. Does hou module contain a function that is an equivalent of a Reverse SOP? I looked for it, but in vain.
Having to place Reverse SOP before each export is way too tedious, even as a makeshift solution. :roll:
—–
Update:
I've resolved this by making my exporter an HDA and by placing two reverse SOPs inside it (one for reversing faces before the export, the latter - to reverse them back).
  • Quick Links