Jump to content

  • Log In with Google      Sign In   
  • Create Account


Cylindrical texture coordinates


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 floatingwoods   Members   -  Reputation: 278

Like
0Likes
Like

Posted 13 September 2012 - 10:52 AM

Hello,

In my application I want to handle textures in a same way, even if they are applied in a different manner (projection, cylindrical, spherical, box). So this means I don't want to use automatic texture coord. generation, but I want to calculate them myself, when the object is created.

Usually, people calculate one texture coordinate (u,v) for each vertex (x,y,z). So each vertex will always have assigned the same texture coordinate.

But in my understanding, this cannot work when using cylindrical/spherical texture mapping:

suppose that one of the triangle (with vertices A, B, C) closing the cylinder has following angular coordinates (in polar coordinates, in degrees): 340, 350, 10

So those 3 vertices will be mapped following 3 u-texture coordinates: 0.9, 0.95, 0.05 (approximately!)

But that is not correct: the texture fragment would be spanning across almost the whole texture!

we should rather have following u-texture coordinates: 0.9, 0.95, 1.05

I could assign the vertex C the u-texture coordinate "1.05" to make that triangle look ok, but the problem is that the same vertex C is also part of other triangles, which might rather require the u-texture coordinate "0.05".

I hope I explained myself clearly enough ;)

So the only solution to this would be to have 3 texture coordinates for each triangle, rather than to have one texture coordinate for each vertex. Do people usually do that?

Is there another option?

Thanks for any advice!

Sponsor:

#2 dpadam450   Members   -  Reputation: 807

Like
-1Likes
Like

Posted 13 September 2012 - 03:46 PM

So the only solution to this would be to have 3 texture coordinates for each triangle, rather than to have one texture coordinate for each vertex. Do people usually do that?

the texture fragment would be spanning across almost the whole texture!

What the hell are you talking about. How does a texture fragment which has a single pixel from a texture have a whole texture mapped to it? That's impossible. And to unwrap a cylinder to a texture you only need 2 uv's. You have to have a seam obviously. Take a soup can without top/bottom, cut the label from top to bottom and unfold. It is 2d applied to a cylinder.

#3 floatingwoods   Members   -  Reputation: 278

Like
0Likes
Like

Posted 13 September 2012 - 04:06 PM

Thank you for the reply dpadam450,

I didn't use the right word I guess. With "texture fragment" I meant "one textured triangle part of the cylinder".
I attached a picture to this reply, it should clarify my problem.

Thanks

Attached Thumbnails

  • textureQuestion.jpg


#4 dpadam450   Members   -  Reputation: 807

Like
0Likes
Like

Posted 13 September 2012 - 04:27 PM

Right so don't build a triangle that goes over that seam. That's how it has to be obviously. You can either cut up your triangles along the seam or/but for any model done by an artist they will have seams anyway. You don't make seams and then model them, you make the seams cut through existing vertices based on your models shape.

#5 floatingwoods   Members   -  Reputation: 278

Like
0Likes
Like

Posted 13 September 2012 - 04:44 PM

Thanks again.

Obviously that's one way to do. But it is very troublesome if you are not directly in control of what geometry is being used (i.e. the user can edit and manipulate the geometry)
The way I am doing it now (see my "funny" explanation above) works, but instead of calculating the texture coordinates on a vertex basis, I am calculating the texture coordinates on a triangle basis:

Basically, instead of one pair of texture coordinate per vertex, I use 3 pair of texture coordinate per triangle

I just wanted to confirm that this method is also being used sometimes, since I will have to be able to export the whole thing at some point, and provide something "standard" ;)

#6 dpadam450   Members   -  Reputation: 807

Like
0Likes
Like

Posted 13 September 2012 - 07:15 PM

No it is never used because there is no reason to not open it up in a 3d application and edit it. Not to mention a perfect cydlinder that had the triangle as you have shown it should have never ever been built that way.

#7 floatingwoods   Members   -  Reputation: 278

Like
0Likes
Like

Posted 14 September 2012 - 03:03 AM

Well, then here is a stupid question maybe:

With the specially prepared cylinder (with correct seam) you will still need special handling at the seam points: indeed every seam point is part of a triangle "opening" the cylinder, and a triangle "closing" the cylinder, thus every seam point will need 2 differentiated texture coordinates... unless you create the cylinder open (i.e. two overlapping seams, each seam point is present twice).

Please refer to the picture: points B & C in the upper part, will require different texture coordinates!

Attached Thumbnails

  • textureQuestion2.jpg


#8 Ignifex   Members   -  Reputation: 507

Like
2Likes
Like

Posted 14 September 2012 - 08:08 AM

The second form, the "open" cylinder, is the common solution used in almost every model exporter available. The reason is exactly as you have mentioned.
Texture coordinates are not the only attribute that can differ per vertex on the model. Multiple normals are also commonly available, forcing even more splitting into multiple "single attribute" vertices.

#9 floatingwoods   Members   -  Reputation: 278

Like
0Likes
Like

Posted 14 September 2012 - 08:19 AM

Thank you Ignifex!

That makes sense.

Cheers




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS