Duplicate Vertices on OBJ Export

Next
 From:  Skwerm
4424.1 
I'm curious about why MoI export to OBJ (and perhaps other formats, I haven't checked) includes duplicate vertices. I was reading another thread here about Octane having problems rendering MoI output and the subject came up about duplicate vertices. That reminded me that I had been meaning to post this question for a while.

I use MoI to create objects that I then bring into Blender. Whenever I've imported an OBJ, the first thing I have to do in Blender is have it clean up all the duplicate verts. Not a big deal, but if I forget to do it on a model I end up getting a rude reminder when it comes time to render and I get flickering, dark fogging, or other weirdness.

Just to make sure it wasn't a problem with Blender's OBJ import (I'm using 2.59) I exported a simple cube solid out of MoI to an OBJ and then imported it into MeshLab. Sure enough, just like in Blender the cube reports having 24 vertices instead of 8 as it should.

Can anyone enlighten me about this?

Thanks.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4424.2 In reply to 4424.1 
If you export without welding, then the 24 vert count is correct. If you select to weld your mesh. then 8 shows in Meshlab....

The question then becomes "why isnt Octane or Blender reading the true vertex normals from the obj file and screwing up the shading??

This question is for Blender or Octane though, not MoI.

EDITED: 14 Aug 2011 by BURRMAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4424.3 In reply to 4424.1 
Hi Skwerm - like Burr mentions that's your choice for there to be duplicate vertices or not depending on whether you set the "Weld vertices along edges" option when exporting from MoI.

That option is on the meshing options dialog here (expand it to get the full controls if you've currently got the compact version of the dialog):




For example if you export a cube object with welding enabled, there will only be 8 3d point vertices in the resulting mesh and the different faces of the cube will share some points in common with one another.

If you export with welding disabled, then each surface will have its own separate vertices along where they shared edges, with the vertices stacked up on top of each other.

That's an option because for some kinds of uses you may not want to have welding - if you plan on separating all the faces from each surface into different objects in your polygon modeling program that may be a bit easier to do with unwelded output since the pieces are not topologically connected. Also some kinds of special effects like outlines on some toon style renderers may rely on having non-shared edges in the mesh to know where to place their outline lines.

Also occasionally some programs may have difficulty with importing files that are welded, where 2 polygons share a single point in common but have distinct UV and vertex normals for each face that use that same 3d vertex point.

But if you don't want to have duplicated vertices in your export, just check that option and you'll have a single shared vertex in those areas instead of duplicated ones.

- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4424.4 In reply to 4424.1 
Hi Skwerm, also just some more info - unless you're doing some kind of special effect like a toon render that is specifically looking for open edges in the mesh there should not be any difference between rendering a welded mesh or an unwelded mesh.

That's because the shading of the mesh is supposed to be controlled by the vertex normals data that is also present in the OBJ file.

If you get a different looking render between an unwelded versus a welded mesh, then that means that your program is ignoring the vertex normals that were supplied in the file and instead trying to calculate brand new ones from scratch by averaging together faces that share points in common.

Blender has a problem with doing precisely that in the latest 2.5x versions - currently their OBJ import script just ignores all the vertex normal data in the OBJ file (those are the lines that start with 'vn') and try to calculate new ones just from the polygonal information. That's not good for CAD data because the normals that have been discarded are ones that have come from the original NURBS surface data and it isn't really possible to get the same exact ones back just by averaging the polygon data since the polygons are only an approximation of that original smooth NURBS surface.

Please see this previous post here for a lengthy description of how vertex normals in the OBJ file are supposed to be used by a rendering program:
http://moi3d.com/forum/index.php?webtag=MOI&msg=4272.3


Basically, as long as Blender just throws away the vertex normals in the OBJ file instead of reading them in and using them, it will always have a problem with CAD data. To my knowledge, Blender is the only rendering program that has this particular problem - all the other rendering programs that I am aware of do read in the vertex normals from an OBJ file and use it to shade the rendered polygon instead of just ignoring them and recalculating them from the polygon face normals.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4424.5 In reply to 4424.1 
Hi Skwerm, also see this thread on the Blender artists forum that talks about the problem with the Blender importer ignoring the vertex normal data:

http://blenderartists.org/forum/showthread.php?182195-OBJ-import-normals

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  YHWH_777
4424.6 In reply to 4424.2 
<< I'm curious about why MoI export to OBJ (and perhaps other formats, I haven't checked) includes duplicate vertices. I was reading another thread here about Octane having problems rendering MoI output and the subject came up about duplicate vertices.>>

I don't think that the duplicate vertices in that case were due to a seam from MoI (since the duplicates are all over the place and not just on a seam). It was just due to a very sloppy mesh. That is why I doubted that the mesh came from MoI, since I have never seen MoI create random duplicate vertices all around the mesh. If you want to take a look at that mesh yourself, you can find it here: http://refractivesoftware.com/forum/download/file.php?id=10501

<< The question then becomes "why isnt Octane or Blender reading the true vertex normals from the obj file and screwing up the shading??

This question is for Blender or Octane though, not MoI.>>

Octane doesn't have a problem reading in normals from MoI.

Blender ignores normal information and calculates its own (which ends up messing up renders from MoI).
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4424.7 In reply to 4424.6 
Sorry YHWH,
I didnt mean to insinuate anything about Octane. I was just responding to the OP and how it's not a question about MoI....
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Skwerm
4424.8 
Thanks everyone for all the help!

I'd always just turned off "Weld Vertices" because of a thread I read back when I started with MoI that said Blender really needed it turned off in order to help with the vertex normals. I hadn't "put two and two together," so to speak, and realized that this was where my current question was originating from.

I'll see what I can do about getting the developer for the OBJ import for Blender to address this problem. If nothing else, I'd like an answer as to why they're being ignored. My guess is that it's just easier to recalc the vertex normals rather than deal with the imported ones.

Cheers!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
4424.9 In reply to 4424.8 
Hi Skwerm,

> I'd always just turned off "Weld Vertices" because of a
> thread I read back when I started with MoI that said
> Blender really needed it turned off in order to help with
> the vertex normals.

It wasn't really Blender itself that needed it turned off - it was a particular import script that Anthony wrote to import moi-generated LWO files into Blender. That particular script needed welding to be off just because it was easier for him to write that one script that way.


Unfortunately Blender has several other problems with vertex normals aside from ignoring them on OBJ import - when you go to edit mode any existing vertex normals are discarded and recreated from the polygon data, and also when you go to render it also discards them.

Here are a couple of previous discussion threads about it:
http://moi3d.com/forum/index.php?webtag=MOI&msg=4256.1
http://moi3d.com/forum/index.php?webtag=MOI&msg=3583.1


There doesn't seem to be very much interest by the Blender devs on fixing up these problems - for example a while back someone opened a bug that any imported vertex normals are discarded if you just go to edit mode and back out again without actually doing anything, and the bug was rejected:
http://projects.blender.org/tracker/?group_id=9&atid=498&func=detail&aid=26405

So for now anyway with all these vertex normal problems Blender is not really very well suited for rendering CAD data compared to other rendering programs.


> My guess is that it's just easier to recalc the vertex normals
> rather than deal with the imported ones.

Sure I guess that's easier but it's also incorrect when the vertex normals in the file are holding information that you can't easily recreate. That's what will happen when the OBJ file was generated from some other original data source than polygons. Like in the case of MoI the normals that are stored in the OBJ file come from the NURBS surface data, so they represent the ideal normal for that point. Since Blender doesn't have access to the original NURBS surface there isn't any way for them to regenerate that exact same data just by trying to average normals from polygon faces.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All