Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Texturing on Tubes and Cylinders

Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
04-18-2008 06:04
I was a bit disappointed that I was unable to apply a pattern to the sides of a prim made from a tube or cylinder. It seemed like no repeat number in the world worked. Either I had thin narrow horizontal stripes or I had shade or tones because the number was too small. I never got anything in between; the images on the pattern never came into focus.

How can you make something from these prim shapes and - say - put vertical stripes or recognizable patterns on the outside?

Thanks!
Larrie Lane
Registered User
Join date: 9 Feb 2007
Posts: 667
04-18-2008 06:18
The repeats for cylinders and tubes for a normally 512x512 texture would be 4.00 Horizontally and 1.00 vertically.
Subject to how and if you cut it would depend on your offsets.

Check the mapping tab as well, this should be set to default, if you use planar then it will be all wonky.
Michael Bigwig
~VRML Aficionado~
Join date: 5 Dec 2005
Posts: 2,181
04-18-2008 06:45
I tend to think of it in terms of unwrapping the cylinder. Increase the width of your starting canvas size. Then create with that in mind as being the unwrap of the cylinder.

Then manipulate the final image size to be in the 128, 256, 512 denomination set.

Golden.
_____________________
~Michael Bigwig
__________________________________________________Lead Designer, Glowbox Designs
Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
04-18-2008 07:33
I did, and I've done it in other 3D formats. I'll have to go over the settings suggested and see where I went wrong.

My texture isnt that big. More than half that. It was supposed to tile with repeats.
Larrie Lane
Registered User
Join date: 9 Feb 2007
Posts: 667
04-18-2008 08:07
From: Holocluck Henly
I did, and I've done it in other 3D formats. I'll have to go over the settings suggested and see where I went wrong.

My texture isnt that big. More than half that. It was supposed to tile with repeats.


I would suggest first get to understand your texture in sl by starting with a 10x10x10 cube and apply it to one side only with the repeats at 1.00 vertically and horizontally then apply it to a cylinder or tube of the same size but set the horizontal repeats at 4.00 vertical to 1.00 (you may have to rotate the texture 90 degrees) then your texture will be correct as one or whole.
The reason for setting the repeats to 4.00 for a cylinder or tube is that it is in theory a cube with 6 sides.
As you start reducing the size of your prim you will need to reduce the repeats. So for example, if you make your cylinder or tube 5x5x5 then the repeats would have to be 2.000 horizontally and 0.500 vertically. Why, is because you have just halved your prim size and therefore you must half the texture size using the repeats. If you were to apply this to a cube then the repeats would be 0.500 both Horizontal and vertical.
That is the basic of texture alignment but without seeing the texture and prim you are trying to apply it to then its dificult to be precise and give you an exact answer.

If you are still having problems then try posting a picture of your texture on the forum with the prim type and size or try contacting me inworld.

I am not inworld at the moment so I hope the offset examples I gave here are correct, I will check later and amend if they are wrong but I am sure my memory serves me right.
Holocluck Henly
Holographic Clucktor
Join date: 11 Apr 2008
Posts: 552
04-18-2008 08:36
Oh I'm fine with cubes and I already applied a custom texture to a friend's outfit.

I've done 3D objects for years. This seems more an enigma. I'll just have to check those other settings this evening.

My other problem is I wanted to apply a color to the top of it and use the texture for the sides (inside and outside). Thought it saw the tops of pipes as another face from the sides and bottom.
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
04-18-2008 09:44
From: Larrie Lane
The reason for setting the repeats to 4.00 for a cylinder or tube is that it is in theory a cube with 6 sides.

I'm not sure where you're getting that, Larrie. Cylinders in SL do not use cubical topology. They use honest to goodness cylindrical topology, meaning one stitched side and two endcaps (24 facets each, just to be complete about it). While it's certainly possible, and in some cases even preferable, to make a sphere with cubical topology (six sides), that's not how SL does it.

That said, let's talk about why it actually is that the 4:1 ratio happens to work well. It has to do with simple geometric math, in combination with the power-of-two requirements for textures in OpenGL.

The math part is easy. We all know that the circumference of a circle (or cylinder) is Pi times its diameter. So, in order for a square texture to remain perfectly square as it wraps around a cylinder, it would need to repeat Pi times. But there's an obvious problem with that. Since Pi is not a whole number, the texture won't tile wholly at Pi repeats. In order to make it to tile perfectly, you'd want to round it down to 3 horizontal repeats. It is actually three repeats, not four, that is the optimal number for the least possible stretching of a square texture on a cylindrical side.

It's pretty easy to see this, just by putting an image of a circle in your texture. Repeat the texture 4 times, and you'll see the circle squish horizontally by about 33%, to become an oval. But repeat it just 3 times, and the circle will look almost perfect. It is stretched horizontally, just slightly, by the missing Pi decimals, if you want to get technical about it, but that's hardly noticeable. It's as close to perfect as you're going to get with whole numbers.

OK, so if three is optimal, how come textures with a canvas size ratio of 4:1 are so often used? Well, here's where we get into OpenGL's limitations. Textures must be measurable in powers of two. There's no such thing as 3:1 sized texture that can be measured in powers of two in both directions. The closest you can get is 4:1. If you want your texture to repeat just once as it wraps the cylinder, the best canvas size ratio you can use, even though it's far from ideal, is 4:1.

There is an even better solution. Mount a Pi:1 sized texture on a 4:1 sized canvas, and then repeat it 0.785 times horizontally. The unused portion of the canvas will be hidden; only the Pi:1 sized portion will show. You do waste a few pixels that way, but if you want a perfectly sized texture for a cylinder, that's the only way to do it.

For an example, let's say your canvas is 512x128. The subject area would be 402x128, and the remainder of the canvas could then just be left blank. When you apply the texture to your cylinder, set the horizontal repeats to 0.785, and just the subject area will show. The blank padding area will disappear, and the texture will appear to be perfect on the cylinder.

In that particular example, you'd have 41 kilobytes worth of wasted texture memory from the hidden pixels. You'd have to do it 25 times, with 25 separate textures, to waste a single megabyte. The waste is pretty minimal.

Bottom line, the 4:1 ratio has very little to do with the actual topology of the cylinder. I don't recommend using it. If you're repeating a square texture, 3:1, not 4:1, is what will keep it as square as possible. If you're using just a single repeat, then a Pi:1 sized image, mounted on a 4:1 sized canvas, is best.

From: Larrie Lane
As you start reducing the size of your prim you will need to reduce the repeats. So for example, if you make your cylinder or tube 5x5x5 then the repeats would have to be 2.000 horizontally and 0.500 vertically. Why, is because you have just halved your prim size and therefore you must half the texture size using the repeats. If you were to apply this to a cube then the repeats would be 0.500 both Horizontal and vertical.

Now you've lost me, Larrie. If you're talking about repeats per face, then the physical size of the surface(s) is irrelevant. A face is a face is a face.

If you're working with repeats per meter, then sure, the repeat values would change as the surface size changes. But why would you use repeats per meter on a cylinder side? RPM works best for planar surfaces. There's not generally much call to bother with it on a non-planar surface like the side of a cylinder.

Usually, all you'll be concerned with is how many times the texture repeats as it makes its way around the circumference. Sometimes, you'll also care about how many times it repeats height-wise. But almost never would you need to care how many of those repeats happen to fit into a meter.


From: Larrie Lane
If you are still having problems then try posting a picture of your texture on the forum with the prim type and size or try contacting me inworld.

While it's very generous of you to offer your in-world time, I must say, I really hate it when people go that direction. When a question is asked here, but not fully answered here, a great many people lose out.

First, every individual who is actively involved in the discussion deserves to be able to follow it through to its full conclusion. When you pull the discussion off the forum, those people are shut out. Second, for every one person that posts a question on the forum, there are always countless others with the same question who don't post. Some people, for whatever reason, just read and don't ever speak up. Just because those people are silent doesn't mean they don't still deserve the same benefit of learning. Answering a discussion in-world helps only one person, but answering it here helps lots of people simultaneously.

So For everyone's sake, it's always best to keep the discussion on the forum if that's where it started.
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
04-18-2008 09:52
From: Holocluck Henly
I've done 3D objects for years. This seems more an enigma. I'll just have to check those other settings this evening.

When you do get back to it this evening, take a good look at the repeat and offset settings. You'll find they work exactly the same way in SL as they do in the texture placement utilities of many other programs. Maya's 2D placement node, for example, has an almost identical set of fields. (Maya's has a lot more options, but the basics are the same.) Pretty much every 3D application I've ever used has had something along similar lines.

From: Holocluck Henly
My other problem is I wanted to apply a color to the top of it and use the texture for the sides (inside and outside). Thought it saw the tops of pipes as another face from the sides and bottom.

To texture different sides of a prim differently, turn on Select Texture in the editor. Then you can individually click on faces to select them. Whatever texturing or coloring changes you make will then be applied only to your selection, not to the whole object.

The wording "Select Texture" is a bit of a misnomer, and confuses pretty much everyone at first. I've been saying for years that they aught to just put a 3-way selection mask toggle at the top of the editor. We should have "Select Whole Objects", "Select Individual Prims", and "Select Individual Faces". That would actually make literal sense. "Select Texture" makes no sense at all.
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.