What's the difference between clamp and repeat textures?

By logic, setting a texture to “repeat” should repeat the texture. So why do I get no difference between clamp and repeat settings when I apply a texture to a cube and scale the cube? This feels like a very big oversight for a game engine if it can only “tile” textures on terrain, which is the only place I’ve actually seen textures tile correctly.

To illustrate my point, here is what the texture looks like when I scale a cube.

Here is what I want it to look like when I scale the cube.

Regardless of whether I have my texture set to repeat or clamp, I get the exact same result. So what is the difference, and how can I get my texture to work like example 2, and not like example 1?

Scaling an object does not change how the Texture is applied to that object.

To increase or decrease the tiling you have to change the texture tiling property in the Material. Clamp will stop tiling and just stretch the last pixel row if the texture tiling property is set to more than 1 in the x or y dimensions. Repeat makes it tile but only in accordance with the tiling property setting, not scale.

Ah…looked at that second “what I want” picture again. It can’t be done, not by using the Unity cube and changing settings. Asking about Repeat/Clamp was just confusing the issue.

The rule for 3D models is, when an object stretches, the texture stretches. You’re wanting the system to change that to “when an object stretches, the texture tiles more.” That makes sense. It’s called planar-mapping. But it takes a special set-up this cube doesn’t have. And it won’t track the model (if you did get a different cube to look this way, then changed size, the texture would still just stretch/shrink.)

In 3D modelling, objects are unwrapped a certain way, using a certain number of materials. The Unity cube has one material, and is unwrapped so the entire texture is pasted 1x1 on each face. Since it uses one material, you can only set the tiling on them all the same way. In other words, you can make the right side tile 1x2, the way you have it, but then every face will tile 1x2.

One way would be to make/find a new cube, using three materials (for each pair of aligned faces.) Three materials means you can supply three tilings. Or, could just use 3 small cubes (if the match is correct, they will be seamless.)