Obj2rad precision issue?

Hi, I have a question regarding face normal perturbation.

I have a dense OBJ file which I’m trying to convert to either “rtm” or “rad” using obj2mesh/obj2rad, but no matter what I do the surface normals come out unperturbed (nx=Nx).

To look into the problem more closely I looked at just a single polygon, and even though it has vertex normals which are not identical, the texfunc section is not generated in obj2rad. Admittedly the difference between these normals is not big, but I’d still like to see them interpolated. Also, meshlab loads and renders this polygon without any issues.

Could this be a precision issue?

Here’s the OBJ file definition:

g default
v 0 9.7041597 3.7353301
v 0.0648700 9.7040806 3.7353201
v 0.0648700 9.7593098 3.7337399

vn 0.0002610 0.0286400 0.9995900
vn 0.0008080 0.0286900 0.9995880
vn 0.0008300 0.0288170 0.9995840

f 1//1 2//2 3//3

And the generated rad file:

obj2rad test2.obj

default polygon default.1
0
0
9
0 9.7041597 3.7353301
0.06487 9.7040806 3.7353201
0.06487 9.7593098 3.7337399

Done processing file: test2.obj

10 lines, 8 statements, 0 unrecognized

Update: after digging into obj2rad code, I see that indeed this is a precision issue:

if (d1 < COSTOL || d2 < COSTOL || d3 < COSTOL)
return (ISBENT);
return (ISFLAT);

Where COSTOL is defined as 0.999995. I wonder what the implications of relaxing this tolerance would be? Is it safe to do so?

Yes, I see this limit is applied bothin obj2rad and obj2mesh. It amounts to a little less than 1/5 of a degree, which although small, could concievably be visible if not corrected in a set of facets. You can certainly alter this value, and if you see a difference with and without normals, I may go ahead and follow your suggestion for upcoming releases. Why don’t you try setting COSTOL to 0.99999996, which is about one arc-minute? I think that should be safely below the visibility tolerance in most circumstances.

Thanks, that’s very helpful!

Can you kindly direct me to where I can find the same tolerance limit in obj2mesh?
I tried to look for it but didn’t find anything similar.

Thanks!

It calls the same routine. If you fix it there, it should affect both obj2rad and obj2mesh.

Hmm, tried to change COSTOL as you advised, and I’m getting “mesh is empty”, “empty mesh octree” , “no patches in mesh”…I guess I messed up something…

Well, looks like this error has nothing to do with COSTOL, I get it with the original COSTOL as well. Something in my development environment is causing this (doesn’t happen with normal obj2mesh).