- Sep 10, 2016
- 602
- 465
This is something that hasn't ever been enough to warrant putting in a guide, but still irritates me whenever I see a map get it wrong, so it's time to talk about it.
Here's a tile floor, connecting to a 45-degree tile floor.
This looks strange - no one would build tile floors like this in real life.
Let's rotate the texture on the 45-degree floor by... 45 degrees.
Hmmm, that looks wrong too. What gives?
As it turns out, no amount of translating this texture on the X and Y axes will make it align.
We could add a trim between the two floors, but we could also... just do it right.
You may notice that 8 tiles is enough to cover the non-angular floor.
I'm using a 1024x1024 texture with a scale of 0.5, so that means each hammer unit will contain 2x2 of the texture's pixels.
So, the texture will fit perfectly within a 512x512 surface.
In this case, it only takes 8 of the texture's 16 tiles to fill up our 256-height floor here.
The reason why it isn't fitting properly on the angled floor is because none of the side lengths are a clean multiple of 256.
Anyone who went to school should know that the hypotenuse is the longest face of a triangle.
We can consider each side of our angled face to be a triangle with two 256-length faces and the hypotenuse.
So, we can get the exact side length with Pythagoras' equation:
sqrt(256^2 + 256^2) = 362.03867196751233249323231339768
Now, to make our 8 tiles perfectly fit the angular surface, we need to multiply our texture scale of 0.5 by [the side length of the angular surface / the side length of the original surface]:
362.03867196751233249323231339768 / 256 = 1.4142135623730950488016887242097
1.4142135623730950488016887242097 * 0.5 = 0.70710678118654752440084436210485
Hammer isn't that precise, so we can just simplify it to 0.707.
So let's try setting the texture scale on both axes of the angular surface to 0.707:
Wow! That fits perfectly, and I didn't even need to shift it on either axis!
But it makes the tiles look too big.
This is because the angular surface is much thicker than the non-angular, because of the factors I explained earlier.
So, all we need to do is adjust the geometry with vertex edit to make the angular surface thinner:
I don't feel compelled to explain this in full, but this has made the width of the angular surface almost identical to the width of the non-angular.
But now our textures look wrong again:
This is because the ratio of "side length" between the angular surface and regular surface has changed.
You can see that across the angular surface, 6 tiles are now enough to cover it - but it doesn't mesh perfectly with the regular surface anymore, since the side length of the regular surface never changed and so 8 tiles still cover it.
In a sense, we've multiplied the side length of the angular surface by 3/4.
So let's just multiply the texture scale by the same amount!
0.70710678118654752440084436210485 * 0.75 = 0.53033008588991064330063327157864
Let's simplify that to 0.53 and apply it to our angular surface on both axes:
Hmmmm, that still looks wrong. Let's press "Justify L" and "Justify B" in the Face Edit Sheet.
Looking great! But you may notice it looks wrong on one axis.
To put it simply, we've set the texture scale to be 3/4 of what it once was on the axis that connects with the non-angular surface, because the side length of that axis changed.
But the side length of the other axis didn't really change - it's still a 256x256 triangle.
So let's set its texture scale back to what it was (and then justify L or B depending on whether it's the X or Y axis):
That's a lot more mathematically sound.
But I don't tend to do it this way, because it makes the tiles non-square and creates weird seams, as you can see in the image.
Generally, you're doing this with textures that only tile on one axis anyway, such as wood planks, so I tend to end up just leaving it as 0.265 or 0.53 on both axes.
Although, if your wood textures are rotated the other way, it actually becomes immensely important to do it via the more mathematically pure method.
Hopefully this all made sense, and has helped you make your angular surfaces look right instead of using smoke and mirrors to cover their visual errors.
Also, if you know how to texture stuff with alt-rightclick, you can do that and it'll have the same result as this method - but I dislike doing it that way, since it loves to reset whenever you do anything with the brush.
It's also a great way to keep you from gaining any mathematical understanding of angled geometry.
Here's a tile floor, connecting to a 45-degree tile floor.
This looks strange - no one would build tile floors like this in real life.
Let's rotate the texture on the 45-degree floor by... 45 degrees.
Hmmm, that looks wrong too. What gives?
As it turns out, no amount of translating this texture on the X and Y axes will make it align.
We could add a trim between the two floors, but we could also... just do it right.
You may notice that 8 tiles is enough to cover the non-angular floor.
I'm using a 1024x1024 texture with a scale of 0.5, so that means each hammer unit will contain 2x2 of the texture's pixels.
So, the texture will fit perfectly within a 512x512 surface.
In this case, it only takes 8 of the texture's 16 tiles to fill up our 256-height floor here.
The reason why it isn't fitting properly on the angled floor is because none of the side lengths are a clean multiple of 256.
Anyone who went to school should know that the hypotenuse is the longest face of a triangle.
We can consider each side of our angled face to be a triangle with two 256-length faces and the hypotenuse.
So, we can get the exact side length with Pythagoras' equation:
sqrt(256^2 + 256^2) = 362.03867196751233249323231339768
Now, to make our 8 tiles perfectly fit the angular surface, we need to multiply our texture scale of 0.5 by [the side length of the angular surface / the side length of the original surface]:
362.03867196751233249323231339768 / 256 = 1.4142135623730950488016887242097
1.4142135623730950488016887242097 * 0.5 = 0.70710678118654752440084436210485
Hammer isn't that precise, so we can just simplify it to 0.707.
So let's try setting the texture scale on both axes of the angular surface to 0.707:
Wow! That fits perfectly, and I didn't even need to shift it on either axis!
But it makes the tiles look too big.
This is because the angular surface is much thicker than the non-angular, because of the factors I explained earlier.
So, all we need to do is adjust the geometry with vertex edit to make the angular surface thinner:
I don't feel compelled to explain this in full, but this has made the width of the angular surface almost identical to the width of the non-angular.
But now our textures look wrong again:
This is because the ratio of "side length" between the angular surface and regular surface has changed.
You can see that across the angular surface, 6 tiles are now enough to cover it - but it doesn't mesh perfectly with the regular surface anymore, since the side length of the regular surface never changed and so 8 tiles still cover it.
In a sense, we've multiplied the side length of the angular surface by 3/4.
So let's just multiply the texture scale by the same amount!
0.70710678118654752440084436210485 * 0.75 = 0.53033008588991064330063327157864
Let's simplify that to 0.53 and apply it to our angular surface on both axes:
Hmmmm, that still looks wrong. Let's press "Justify L" and "Justify B" in the Face Edit Sheet.
Looking great! But you may notice it looks wrong on one axis.
To put it simply, we've set the texture scale to be 3/4 of what it once was on the axis that connects with the non-angular surface, because the side length of that axis changed.
But the side length of the other axis didn't really change - it's still a 256x256 triangle.
So let's set its texture scale back to what it was (and then justify L or B depending on whether it's the X or Y axis):
That's a lot more mathematically sound.
But I don't tend to do it this way, because it makes the tiles non-square and creates weird seams, as you can see in the image.
Generally, you're doing this with textures that only tile on one axis anyway, such as wood planks, so I tend to end up just leaving it as 0.265 or 0.53 on both axes.
Although, if your wood textures are rotated the other way, it actually becomes immensely important to do it via the more mathematically pure method.
Hopefully this all made sense, and has helped you make your angular surfaces look right instead of using smoke and mirrors to cover their visual errors.
Also, if you know how to texture stuff with alt-rightclick, you can do that and it'll have the same result as this method - but I dislike doing it that way, since it loves to reset whenever you do anything with the brush.
It's also a great way to keep you from gaining any mathematical understanding of angled geometry.
Last edited: