This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > July 2005 > texture coordinates on sphere where 1 and 0 meet





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author texture coordinates on sphere where 1 and 0 meet
John Andrews

2005-06-26, 7:25 pm

crap- the message i posted yesterday was deleted from the list ('cause
i added an attachment/.jpg image, probably) and i didn't save the
original... here ~it is again, briefly:


I've got a sphere; mars, actually. I created it from a DEM. It's an
IndexedFaceSet of approximately 100k polygons. I'm overlaying a
topographic image of the planet onto the model. The image lines up
perfectly, with one problem: the "x" texture coordinates range from 0
to 1. 0 is at the front/center of the sphere, .25 on the far right-hand
side, .5 in the back/center, .75 at the far left, then ending at 1 again
in the front/center of the model. Again, the image lines up perfectly,
except along a thin strip of triangles--from the top to the bottom of
the sphere (y)--where the texture coordinates, for any given triangle,
are ~.01 on the right-side vertex(es) and ~.99 of the left-side
vertex(es) (in other words, triangles which straddle the 0-longitudinal
line). Along this strip, the complete image is placed again, in
reverse.


below perhaps illustrates better- this is what the X texture
coordinates look like (from the perspective of looking at the sphere
down the y-axis in the negative direction)





.5

.675 .375

..75 .25

.875 .125

1|0



so, it is the triangles that straddle this "1 | 0" divide that i'm
having trouble with. Any suggestions? The obvious/quick solution is to
build the model such that no triangles straddle this divide but rather
meet here along a smooth line, but this is not an ideal solution given
the processes by which i generate the model.

thanks much,
john

Rex Melton

2005-06-28, 7:32 pm


In order to get a visually 'seamless' wrapping of a texture onto your IFS
sphere/ellipsoid/etc, you have to arrange the vertex coordinates and texture
coordinates such that there is a vertex at the seam and for each vertex
there are a pair of texture coordinates that map the opposite edges of the
texture to the same vertex. e.g.:

for each vertex at the seam:
coord[ x0, y0, z0 ]

there are texture coordinates:
texCoord[ 1.0, fn(y0) ] texCoord[ 0.0, fn(y0) ]

I think your alternatives are

1) generate the geometry such that the vertices align with the texture edges
(which you already mentioned)

or

2) recreate your texture so that the edges coincide with existing geometry
vertices, then recalculate the texture coordinates to match.

Good luck - and I'd be interested to see your model if you publish it.

-Rex

John Andrews wrote:

> crap- the message i posted yesterday was deleted from the list ('cause
> i added an attachment/.jpg image, probably) and i didn't save the
> original... here ~it is again, briefly:
>
> I've got a sphere; mars, actually. I created it from a DEM. It's an
> IndexedFaceSet of approximately 100k polygons. I'm overlaying a
> topographic image of the planet onto the model. The image lines up
> perfectly, with one problem: the "x" texture coordinates range from 0
> to 1. 0 is at the front/center of the sphere, .25 on the far right-hand
> side, .5 in the back/center, .75 at the far left, then ending at 1 again
> in the front/center of the model. Again, the image lines up perfectly,
> except along a thin strip of triangles--from the top to the bottom of
> the sphere (y)--where the texture coordinates, for any given triangle,
> are ~.01 on the right-side vertex(es) and ~.99 of the left-side
> vertex(es) (in other words, triangles which straddle the 0-longitudinal
> line). Along this strip, the complete image is placed again, in
> reverse.
>
> below perhaps illustrates better- this is what the X texture
> coordinates look like (from the perspective of looking at the sphere
> down the y-axis in the negative direction)
>
> .5
>
> .675 .375
>
> .75 .25
>
> .875 .125
>
> 1|0
>
> so, it is the triangles that straddle this "1 | 0" divide that i'm
> having trouble with. Any suggestions? The obvious/quick solution is to
> build the model such that no triangles straddle this divide but rather
> meet here along a smooth line, but this is not an ideal solution given
> the processes by which i generate the model.
>
> thanks much,
> john




john.andrews@beg.utexas.edu

2005-06-28, 7:32 pm

thanks rex. quick question: how does one apply 2 texture coordinates
to a single vertex coordinate? Using the conventional method i employ
now, each vc has a single tc, and the number of vc=number of tc (and
vc# 25,284 in the list corresponds to tc# 25,284, etc...).


i've posted the model, btw:

http://www.beg.XXXXXX.edu/indassoc/...alone/seam1.htm


john


Rex Melton wrote:[color=darkred]
> In order to get a visually 'seamless' wrapping of a texture onto your IFS
> sphere/ellipsoid/etc, you have to arrange the vertex coordinates and texture
> coordinates such that there is a vertex at the seam and for each vertex
> there are a pair of texture coordinates that map the opposite edges of the
> texture to the same vertex. e.g.:
>
> for each vertex at the seam:
> coord[ x0, y0, z0 ]
>
> there are texture coordinates:
> texCoord[ 1.0, fn(y0) ] texCoord[ 0.0, fn(y0) ]
>
> I think your alternatives are
>
> 1) generate the geometry such that the vertices align with the texture edges
> (which you already mentioned)
>
> or
>
> 2) recreate your texture so that the edges coincide with existing geometry
> vertices, then recalculate the texture coordinates to match.
>
> Good luck - and I'd be interested to see your model if you publish it.
>
> -Rex
>
> John Andrews wrote:
>

Rex Melton

2005-06-28, 7:32 pm


By using separate coordinate indices and texture coordinate indices. A simple
example will (I hope) explain it better than a description. Two adjacent polys
with coordinate indices at the vertices:

0--3--4
| | |
1--2--5

The IFS coordinate indices for this surface would be:

coordIndex [ 0 1 2 3 -1, 3 2 5 4 -1 ]

To texture this surface with your full texture with the edges joined at a seam
down the middle, (along the 3-2 line) the texture coordinates would be:

texCoord [
0.5 1.0, 1.0 1.0, 0.0 1.0, 0.5 1.0,
0.5 0.0, 1.0 0.0, 0.0 0.0, 0.5 0.0 ]

and the texture coordinate indices:

texCoordIndex [ 0 4 5 1 -1, 2 6 7 3 -1 ]

Hope that makes sense.

And thanks, I'll check out the model.

-Rex

john.andrews@beg.XXXXXX.edu wrote:
[color=darkred]
> thanks rex. quick question: how does one apply 2 texture coordinates
> to a single vertex coordinate? Using the conventional method i employ
> now, each vc has a single tc, and the number of vc=number of tc (and
> vc# 25,284 in the list corresponds to tc# 25,284, etc...).
>
> i've posted the model, btw:
>
> http://www.beg.XXXXXX.edu/indassoc/...alone/seam1.htm
>
> john
>
> Rex Melton wrote:

john.andrews@beg.utexas.edu

2005-07-01, 7:27 pm

again, thanks, Rex. I've never used texCoordIndex[] before--i've never
had to--but yes, your explanation makes perfect sense to me- basically
you've defined the x texCoord along the 3-2 line twice--as both 0 and
1--and use, via texCoordIndex[], whichever makes sense to paint/texture
a given polygon. There's a little twist to my problem, however, which
is not addressed in your reply... *BUT* using your solution plus
something else i've figured out, i've got something that works. I
wanna go ahead and run through it, below, in case you or anyone else
knows of other/more efficient solutions.

Based on your example, my polygons actually look more like this:


0---3-4
| / |
1-2---5


with IFS coordinate indices:


coordIndex [ 0 1 2 3 -1, 3 2 5 4 -1 ]


texCoord [
0.500 1.000, *0.166 1.000, **0.166 1.000, 0.500 1.000,
0.500 0.000, *0.833 0.000, **0.833 0.000, 0.500 0.000 ]


texCoordIndex [ 0 4 5 1 -1, 2 6 7 3 -1 ]


Now, in your example, what i have defined as *0.166 and **0.166, you
defined as 1.0 and 0.0, respectively. You could do this because, at
that location (along the 3-2 line) the X textCoord could be defined
as either 0 or 1. In my case, however, the image begins and ends at
"/"; in other words, the seam is at "/". So coord #3's x texture
Coordinate is .166, #4,5,0,1 are 0.5, #2 is .833, and the centroid of
"/" is 1 (or 0). This wouldn't work- i would have the same problem i
had before.


So what i figured out- i can take my JPEG image

-----
| |
-----

and copy a thin strip down the left side of the image, and paste onto
the right side (and copy a strip from the right and paste it onto the
left)


-------
| |
-------

and *then* use something like the following texCoords:

texCoord [
0.500 1.000, 1.000 1.000, 0.166 1.000, 0.500 1.000,
0.500 0.000, 0.833 0.000, 1.000 0.000, 0.500 0.000 ]

This is exactly what you suggested, with the additional kink of having
to create a JPEG image that partially overlaps itself on the ends, then
redefining the x texCoords so that coordinate #2 is 0.0, coordinates
#4,5,0,1 are 0.5, and coordinate #3 is 1. This solution works
perfectly; i'm wondering, though, if there is another way to do it
such that one wouldn't have to create an overlapping JPEG. ...for
future reference.

thanks,
john

john.andrews@beg.utexas.edu

2005-07-01, 7:27 pm

again, thanks, Rex. I've never used texCoordIndex[] before--i've never
had to--but yes, your explanation makes perfect sense to me- basically
you've defined the x texCoord along the 3-2 line twice--as both 0 and
1--and use, via texCoordIndex[], whichever makes sense to paint/texture
a given polygon. There's a little twist to my problem, however, which
is not addressed in your reply... *BUT* using your solution plus
something else i've figured out, i've got something that works. I
wanna go ahead and run through it, below, in case you or anyone else
knows of other/more efficient solutions.

Based on your example, my polygons actually look more like this:


0---3-4
| / |
1-2---5


with IFS coordinate indices:


coordIndex [ 0 1 2 3 -1, 3 2 5 4 -1 ]


texCoord [
0.500 1.000, *0.166 1.000, **0.166 1.000, 0.500 1.000,
0.500 0.000, *0.833 0.000, **0.833 0.000, 0.500 0.000 ]


texCoordIndex [ 0 4 5 1 -1, 2 6 7 3 -1 ]


Now, in your example, what i have defined as *0.166 and **0.166, you
defined as 1.0 and 0.0, respectively. You could do this because, at
that location (along the 3-2 line) the X textCoord could be defined
as either 0 or 1. In my case, however, the image begins and ends at
"/"; in other words, the seam is at "/". So coord #3's x texture
Coordinate is .166, #4,5,0,1 are 0.5, #2 is .833, and the centroid of
"/" is 1 (or 0). This wouldn't work- i would have the same problem i
had before.


So what i figured out- i can take my JPEG image

-----
| |
-----

and copy a thin strip down the left side of the image, and paste onto
the right side (and copy a strip from the right and paste it onto the
left)


-------
| |
-------

and *then* use something like the following texCoords:

texCoord [
0.500 1.000, 1.000 1.000, 0.166 1.000, 0.500 1.000,
0.500 0.000, 0.833 0.000, 1.000 0.000, 0.500 0.000 ]

This is exactly what you suggested, with the additional kink of having
to create a JPEG image that partially overlaps itself on the ends, then
redefining the x texCoords so that coordinate #2 is 0.0, coordinates
#4,5,0,1 are 0.5, and coordinate #3 is 1. This solution works
perfectly; i'm wondering, though, if there is another way to do it
such that one wouldn't have to create an overlapping JPEG. ...for
future reference.

thanks,
john

Rex Melton

2005-07-08, 7:48 pm


Hi John,

Sorry for the delay responding, been out of internet range for the last
week or so.

The rather simple model I had in mind from my previous reply started with
the assumption that the edges of the texture (along s=0, s=1) and the
vertices of the geometry at the seam aligned along a line of longitude of
the sphere/ellipsoid. I think from your description that that assumption is
not valid.

Your solution works, I don't have a 'better' suggestion.

The bottom line is - to apply a texture to any individual poly of an IFS
requires a texture that is continuous across the face of the poly. You can
either craft the texture to match the geometry (which you have done) - or
craft the geometry to match the texture.

Regards,

-Rex

john.andrews@beg.XXXXXX.edu wrote:

> again, thanks, Rex. I've never used texCoordIndex[] before--i've never
> had to--but yes, your explanation makes perfect sense to me- basically
> you've defined the x texCoord along the 3-2 line twice--as both 0 and
> 1--and use, via texCoordIndex[], whichever makes sense to paint/texture
> a given polygon. There's a little twist to my problem, however, which
> is not addressed in your reply... *BUT* using your solution plus
> something else i've figured out, i've got something that works. I
> wanna go ahead and run through it, below, in case you or anyone else
> knows of other/more efficient solutions.
>
> Based on your example, my polygons actually look more like this:
>
> 0---3-4
> | / |
> 1-2---5
>
> with IFS coordinate indices:
>
> coordIndex [ 0 1 2 3 -1, 3 2 5 4 -1 ]
>
> texCoord [
> 0.500 1.000, *0.166 1.000, **0.166 1.000, 0.500 1.000,
> 0.500 0.000, *0.833 0.000, **0.833 0.000, 0.500 0.000 ]
>
> texCoordIndex [ 0 4 5 1 -1, 2 6 7 3 -1 ]
>
> Now, in your example, what i have defined as *0.166 and **0.166, you
> defined as 1.0 and 0.0, respectively. You could do this because, at
> that location (along the 3-2 line) the X textCoord could be defined
> as either 0 or 1. In my case, however, the image begins and ends at
> "/"; in other words, the seam is at "/". So coord #3's x texture
> Coordinate is .166, #4,5,0,1 are 0.5, #2 is .833, and the centroid of
> "/" is 1 (or 0). This wouldn't work- i would have the same problem i
> had before.
>
> So what i figured out- i can take my JPEG image
>
> -----
> | |
> -----
>
> and copy a thin strip down the left side of the image, and paste onto
> the right side (and copy a strip from the right and paste it onto the
> left)
>
> -------
> | |
> -------
>
> and *then* use something like the following texCoords:
>
> texCoord [
> 0.500 1.000, 1.000 1.000, 0.166 1.000, 0.500 1.000,
> 0.500 0.000, 0.833 0.000, 1.000 0.000, 0.500 0.000 ]
>
> This is exactly what you suggested, with the additional kink of having
> to create a JPEG image that partially overlaps itself on the ends, then
> redefining the x texCoords so that coordinate #2 is 0.0, coordinates
> #4,5,0,1 are 0.5, and coordinate #3 is 1. This solution works
> perfectly; i'm wondering, though, if there is another way to do it
> such that one wouldn't have to create an overlapping JPEG. ...for
> future reference.
>
> thanks,
> john


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews