www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on June 16, 2016, 06:38:44 am

Title: Texture Coordinates
Post by: AGP on June 16, 2016, 06:38:44 am
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?

Code: [Select]
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));
(https://dl.dropboxusercontent.com/u/93826015/Earth.jpg)
Title: Re: Texture Coordinates
Post by: EgonOlsen on June 16, 2016, 06:52:26 am
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.
Title: Re: Texture Coordinates
Post by: AGP on June 16, 2016, 06:58:43 am
Thanks for the quick response. But the following didn't fix it:

Code: [Select]
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);
Title: Re: Texture Coordinates
Post by: AGP on June 16, 2016, 07:05:22 am
Actually, there were some < 0. But the following still didn't fix it:

Code: [Select]
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);
Title: Re: Texture Coordinates
Post by: EgonOlsen on June 16, 2016, 10:07:01 am
But I think that it has to be something like that. I dimly remember similar artifacts when I wrote my loaders.
Title: Re: Texture Coordinates
Post by: AGP on June 17, 2016, 06:25:43 am
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?
Title: Re: Texture Coordinates
Post by: EgonOlsen on June 17, 2016, 09:19:43 am
I'm doing just this (first is U, last one v):

Code: [Select]
uvs[uv1][0], 1 - uvs[uv1][1]

...that's for OBJ format. I don't know if it applies to your format.
Title: Re: Texture Coordinates
Post by: AGP on August 03, 2016, 12:24:22 am
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 (http://www.jpct.net/forum2/index.php/topic,4706.0.html)
Title: Re: Texture Coordinates
Post by: EgonOlsen on August 03, 2016, 10:44:47 am
Neihter of these look like accuracy problems to me.. ???
Title: Re: Texture Coordinates
Post by: AGP on August 03, 2016, 03:11:38 pm
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)?
Title: Re: Texture Coordinates
Post by: EgonOlsen on August 03, 2016, 03:30:59 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?
Title: Re: Texture Coordinates
Post by: AGP on August 03, 2016, 04:33:52 pm
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.
Title: Re: Texture Coordinates
Post by: EgonOlsen on August 03, 2016, 08:57:20 pm
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...
Title: Re: Texture Coordinates
Post by: AGP on August 03, 2016, 09:15:50 pm
Just did. Same problem. I really think it's accuracy.
Title: Re: Texture Coordinates
Post by: EgonOlsen on August 03, 2016, 09:35:20 pm
I still don't. It's not subtle enough for that. I've no better idea though.
Title: Re: Texture Coordinates
Post by: AGP on September 14, 2016, 09:11:37 pm
At least it's comforting to know that it's not a jpct issue: I just ran into the same problem with the Blender importer. So, back to the MaxScript exporter.