It appears there is a problem with the automatically generated UV coordinates for the Cylinder primitive.
In previous versions (2.6, I think, but not sure), it was possible to completely map a texture once around the sides of a Cylinder by using the tiling factors x=1 and y=3.14159 (and a y-offset of 0.5, otherwise it was shifted).
But in my current version of Unity (3.3), this has completely changed: Now, if I set the tiling to x=1/y=1, the height mapping is correct, but along the rotational axis the texture is mapped TWICE around the Cylinder, even if the texture is set to “Clamp”. If I set the tiling to x=0.5, the left half of the texture is mapped twice around the Cylinder, the right half of the texture is not visible.
And I just noticed the same problem for the Torus (as seen in the Material preview window), and even for a standard Sphere (although only in the Material preview window - a Sphere in the scene is mapped as expected).
Attached some snapshots for the x=0.5/y=1 tiling.
How can I map a texture exactly once around a Cylinder primitive, without modelling my own (or adapting the UVs manually via script or shader)?
Shall I open a bug for this? Is this known? Or is there some tricky workaround?
The cylinder primitive is just a standard mesh (modeled in Maya I believe). It was probably changed because the current mapping is more generally useful, and it was intentional so it’s not a bug. You might as well just model your own; it makes no difference where the mesh comes from.
Hm, why would it be intentional to remove the possibility to map a texture exactly once around a cylinder? The current behaviour (for the default tiling of x=1/y=1) can easily be reproduced with the other method, simply by using x=2 instead of x=1, but not vice versa.
I can see there’s some conflict between mapping both the side and the caps conveniently, but there should be a different way to solve this?
(of course we could just model our own, but this would somewhat defeat the purpose of having a builtin primitive )
And it also doesn’t explain the incorrect display in the Material preview window for all primitives except the cube.
The primitives are there for quick prototyping; you’d very rarely use them in a final project no matter what the UV mapping is like. For example, judging from your graphic, you’d want to properly model a soda can, and not use a basic cylinder. The material preview is there to give you an idea how it would look on different shapes, and isn’t meant to be literally representative of anything.
That is of course a valid point, especially in view of a soda can.
But it is still not a reason why Unity should display these objects deliberately incorrectly, just because “you shouldn’t use it anyway”. Or in the case of the textured Material preview, “well, this is kinda what it probably will look like, but if you use the same object in your scene, it will actually look completely different” (compare the two sphere snapshots above).
I don’t think the shapes used in the material preview are intended to correspond to (or visually represent) the built-in primitives, if that’s what you mean. (And I wouldn’t be surprised if the mappings differed between the two.)
The point of the material preview is not to see the UV mapping but the material setup. The only thing that differs is the UV mapping.
I don’t know if they really changed the mapping but as long as the material preview resembles the same detail and optics as in game it’s allright. As was said: it’s a material-preview and primitives are mainly for prototyping. You need something specific - do it yourself or ask an artist. that kind of UV setup is a matter of 1 minute to do.