'How can i repeat a texture at its original scale on my cube in unity
So as you see in the picture, i made a texture repeat on a rectangle(its size is 40,10,60) but it repeat the same amount of time on every face,so depending of the size of the face the texture is stretched. In the picture you see that on the top face the texture repeat correctly and keep its original size but on the other faces it is streched. Is there a way to repeat the texture without changing its size ? Thank you for your responses.
Edit : this script in c# does exactly what i want but is there a way to do it without a script since it was done in 2017 ? https://github.com/Dsphar/Cube_Texture_Auto_Repeat_Unity/blob/master/ReCalcCubeTexture.cs
Solution 1:[1]
Unfortunately you will probably need to create a new material with the same image for each different scale using the 'Tiling' attribute:
*** Edit #1
The x and y Tiling values need to proportional to the scale of the plane or it will stretch.
Solution 2:[2]
If the size of the mesh being textured is static, you can change its UVs in a 3d program. You could even change the UVs via script.
Another option would be to look into worldspace (triplanar) shaders. These texture based on world position rather than the vertices local position.
If you are using Shader Graph, look at the triplanar node. https://docs.unity3d.com/Packages/[email protected]/manual/Triplanar-Node.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David |
| Solution 2 | Grp24 |

