Author Topic: Texture Coordinates  (Read 6373 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Texture Coordinates
« 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));

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #1 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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #2 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);

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #3 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);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #4 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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #5 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #6 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.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #7 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #8 on: August 03, 2016, 10:44:47 am »
Neihter of these look like accuracy problems to me.. ???

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #9 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)?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #10 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?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #11 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #12 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...

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Texture Coordinates
« Reply #13 on: August 03, 2016, 09:15:50 pm »
Just did. Same problem. I really think it's accuracy.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Coordinates
« Reply #14 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.