How can i prevent a texture from stretching when scaling a mesh?

So i have created textures in substance designer and imported to unreal with the Substance addon, yet when i apply my texture to a non-uniform mesh, the texture doesn’t scale well. Or if i got for example a perfect cube, if i scale the cube having a texture, the texture will stretch, how can i stop that for happening!!?

Are you scaling your cube on all axes, or just one? By default, if you are scaling an object on a singular axis, the material will stretch to fill that space, a solution would be to use a tiling material. Otherwise, if the textures are being stretched but the mesh is manipulated on all axes, then there is a larger underlying issue.

If you want your texture to tile depending on the object scale, look into using [Object Scale] or [Absolute World Location] nodes in your materials. They both have drawbacks though: you’ll have to separate their outputs into three 2-Vectors: XY, XZ, and YZ to have correct results on all the sides and use different ones depending on face normals; however, if you rotate your object, the result will change, and with the [Absolute World Location] node the object should be static, because when the object moves, the texture stays where it was and it looks weird.

I guess the method that gives you the most control would be to have the cube with three material slots for X, Y, and Z-facing faces, and apply three material instances that use different masks of the [Object Scale] node, so that it would be independent from the object location and rotation.

The thing is that texture is rendered due to its corresponding texture coordinates on mesh in any 3d pipeline (d3 or openGL). If mesh vertices are nonuniformly scaled then the rendered texture will be deformed by their positions. One thing that one can fix is maybe by changing UV

  1. The same as Tuerer said - Within Unreal Material Editor. You can change UV offset, scale, tiling, etc to try to gain the result you wish.

  2. With some complex initial UVs configuration in 3d apps (Blender, 3ds Max, etc). Dont forget that model can have multiple UVs and also can have partial UVs (they are supported by FBX and not supported by OBJ). You can create separate UV for scaled faces and work with them separately in the sense of textures and materials.