When I setTextureScale = 0.5, I would expect the texture to be half the size, but in fact, it makes it bigger but less than twice as big. What’s the math going on here that I’m not understanding?
Thanks for any tips,
-Greg
When I setTextureScale = 0.5, I would expect the texture to be half the size, but in fact, it makes it bigger but less than twice as big. What’s the math going on here that I’m not understanding?
Thanks for any tips,
-Greg
Those parameters transforms the incoming uv-coordinates of your model.
The math is quite simple:
u = u * scale.x + offset.x;
v = v * scale.y + offset.y;
So in a simple case like a texture on a plane you will have 4 uv pairs, one for each corner. If you have a scale of (1.0, 0.5) and an offset of (0.1, 0) that’s what happens:
u v
0, 0 --> 0.1, 0
0, 1 --> 0.1, 0.5
1, 1 --> 1.1, 0.5
1, 0 --> 1.1, 0
Usually the coordinate 0, 0 represents the lower left corner of the texture. That means the texture is shifted in x-direction 10% to the left and therefore you will see 10% of the repeated texture on the right side. No shift in y-direction but the coordinates are scaled down. The lower edge will stay at 0 but the upper edge of the plane is mapped to 0.5 instead of 1.0 so you will see only the lower half of the texture streched over the plane.
Texture coordinates doesn’t change the mesh, just where a triangle is “located” on the texture (in texture-space). If you have unwrapped a model you should know that ![]()