Texture Coordinates

Started by AGP, June 16, 2016, 06:38:44 AM

Previous topic - Next topic

AGP

I'm creating my very own JSON-serialized 3d format, for use with Bones. It will come straight out of 3ds max via a MaxScript I'm developing (Python script for Blender to follow). In point of fact, it's almost ready, save for the fact that I don't yet understand how to create a SkinData object (question to be posted on the Bones board and I do already have a SkeletonPose object filled) and the little texture issue that I'm having. I'm creating the Object3D's (non-skinned objects will also be supported in my format) texture coordinates with the following line. And the result is visible in the image that follows (mostly correct save for minor issues). I suspect it's a rounding issue. What do you think, Egon?

anObject.addTriangle(vector1, uv1.get(0), -(uv1.get(1)-1f), vector2, uv2.get(0), -(uv2.get(1)-1f), vector3, uv3.get(0), -(uv3.get(1)-1f));


EgonOlsen

Looks rather like coordinates larger than 1 to me. Which is fine and not a problem, but by subtracting 1 from them, you might that this effect.

AGP

Thanks for the quick response. But the following didn't fix it:


if (uv1.get(0) > 1f)
     uv1.set(0, uv1.get(0)-1f);
if (uv1.get(1) > 1f)
     uv1.set(1, uv1.get(1)-1f);
if (uv2.get(0) > 1f)
     uv2.set(0, uv2.get(0)-1f);
if (uv2.get(1) > 1f)
     uv2.set(1, uv2.get(1)-1f);
if (uv3.get(0) > 1f)
     uv3.set(0, uv3.get(0)-1f);
if (uv3.get(1) > 1f)
     uv3.set(1, uv3.get(1)-1f);

AGP

Actually, there were some < 0. But the following still didn't fix it:


if (uv1.get(0) > 1f)
     uv1.set(0, uv1.get(0)-1f);
else if (uv1.get(0) < 0f)
     uv1.set(0, uv1.get(0)+1f);
if (uv1.get(1) > 1f)
     uv1.set(1, uv1.get(1)-1f);
else if (uv1.get(1) < 0f)
     uv1.set(1, uv1.get(1)+1f);
if (uv2.get(0) > 1f)
     uv2.set(0, uv2.get(0)-1f);
else if (uv2.get(0) < 0f)
     uv2.set(0, uv2.get(0)+1f);
if (uv2.get(1) > 1f)
     uv2.set(1, uv2.get(1)-1f);
else if (uv2.get(1) < 0f)
     uv2.set(1, uv2.get(1)+1f);
if (uv3.get(0) > 1f)
     uv3.set(0, uv3.get(0)-1f);
else if (uv3.get(0) < 0f)
     uv3.set(0, uv3.get(0)+1f);
if (uv3.get(1) > 1f)
     uv3.set(1, uv3.get(1)-1f);
else if (uv3.get(1) < 0f)
     uv3.set(1, uv3.get(1)+1f);

EgonOlsen

But I think that it has to be something like that. I dimly remember similar artifacts when I wrote my loaders.

AGP

But it isn't. All the values outside the 0-1 range were printed as follows:
uv3.get(0): -0.1
uv3.get(0): -0.1
uv3.get(0): -0.0355861
uv3.get(0): -0.0264047

Could you check what your solution was in the loaders?

EgonOlsen

I'm doing just this (first is U, last one v):


uvs[uv1][0], 1 - uvs[uv1][1]


...that's for OBJ format. I don't know if it applies to your format.

AGP

Egon, I think that I'm now experiencing accuracy problems with the weights. I'm almost certain that it's a 3ds max thing, and that the UV issue is the same as the weights issue at this point. I'm pointing this out here in the hopes of getting some kind of insight on the issue.

http://www.jpct.net/forum2/index.php/topic,4706.0.html

EgonOlsen

Neihter of these look like accuracy problems to me.. ???

AGP

Only thing of which I can think is accuracy: both come close but no cigar. What do they look like to you (and remember that I did add that little check for < 0 and > 1 for the UVs)?

EgonOlsen

Quote from: AGP on August 03, 2016, 03:11:38 PM
What do they look like to you...
I'm not sure but certainly not like accuracy problems. It still looks like some u/v problem to be. There's no need to check for u/v <0 or larger >1. It's perfectly fine to use such values. What we were discussion earlier was the conversion that's needed for v, not any kind of clamping. Have you tried without clamping?

AGP

Quote
Looks rather like coordinates larger than 1 to me. Which is fine and not a problem, but by subtracting 1 from them, you might [solve?] this effect.

Originally, I wasn't clamping. Same artifacts.

EgonOlsen

Have to tried to enable clamping on the texture itself? If that changes something (even if it doesn't look right either), it's some issue with texture coordinates out of [0..1]...if not...then not...

AGP

Just did. Same problem. I really think it's accuracy.

EgonOlsen

I still don't. It's not subtle enough for that. I've no better idea though.