Issue with Cylindrical and Spherical coordinate generation

Topics: User Forum
Jan 24, 2007 at 7:46 PM
I'm really not sure if I'm going crazy or if thsi is a real issue...
It's kind of tricky to describe the problem that I'm experiencing without showing an image: I have a few images that show the problem but unfortunatly there is no way to upload them on this forum.

I have noticed one issue with the cylindrical and spherical texture coordinate generation process. It seems that the alghorithm used in GenerateCylindricalTextureCoordinates and GenerateSphericalTextureCoordinates would lead to texturing errors.
Both functions are internal using the GetUnitCircleCoordinate to determine the UV coordinate using a trnasformation from cartesian coordinate to cylindrical coordinate, and then from cylindrical to UV coordinate.
The easiest way to notice the problem is to generate the cylindrical texture coordinate for a cylinder with 4 side. I used the follwoing XYZ triplets for the test object:

1.00, -1.00, 0.00
0.00, -1.00, 1.00
-1.00, -1.00, 0.00
0.00, -1.00, -1.00
1.00, -1.00, 0.00 (extra vertext for texture mapping purpouse)

1.00, 1.00, 0.00
0.00, 1.00, 1.00
-1.00, 1.00, 0.00
0.00, 1.00, -1.00
1.00, 1.00, 0.00 (extra vertext for texture mapping purpouse)

Please notice that the cylinder has 4 sides, and could be built using 8 vertex only but we need 10 vertex to perform a proper textur mapping.

The UV coordinate generate from the cylindrical mapping functions are:

0.75, 1.00
0.50, 1.00
0.25, 1.00
0.00, 1.00
0.75, 1.00 (this is wrong...we want 1.00, 1.00)

0.75, 0.00
0.50, 0.00
0.25, 0.00
0.00, 0.00
0.75, 0.00 (this is wrong...we want 1.00, 0.00)

The last face will show a texture with reverse U direction.
the problem is that to do a correct texturing we need to map two identical points to a different UV coordinate.
The error is caused from the fact that the GetUnitCircleCoordinate will never return a value of 1 for the U coordinate, making it impossible to wrap a full texture (from U=0 to U=1) on the object.
The angles of 360 degree and zero degree will both return a U value of 0, but we need to return a U value of 1 when the angle is 360.
It seems to me that the only way to address this problem is to add special tests to see if the points that have U=0 belong to a face with normals in the forth quadrant: in that case we can change the U value to 1 .

Please let me know if you can reproduce the issue.

Developer
Feb 12, 2007 at 10:07 PM
Correct, it's a known issue. What usually ends up happening is you end up with a tiny backwards copy of the texture. All of the texture coordinate generation routines were meant to be flexible enough to apply to any type of model. What I mean is you might have mesh that's kinda like a cylinder, so you pick the cylindrical generator. At the time, I couldn't think of a general way to solve the issue. Looking for a duplicate edge might work.