Is there a way to "repeat a texture" instead of stretching it

Hi everybody,

I have a problem with a texture. Here’s it :

With a simple mesh of 1m X 1m


Everything’s fine because the length of a brick is about 20 cm.

But : when my mesh is 2m X 1m


My texture is “stretched”. Even if it is not perfect because of the junctions, i’d prefer it to be repeated twice BUT WITHOUT changing the UScale because I 've some other walls with the same texture but with other dimensions.

Is there a way to do that ?

Thanks in advance,


1 Like

You may try tiling - More Materials | Babylon.js Documentation

1 Like

You’re right but I would not like to create a texture with different U/V for each of my walls.

hey @bvaisman

for keep scaling and keep the UV you need make custom UV for only for one texture

this method help you make textures base on POSITION And Normal ( direction of UV Plan) of the object ( scale object damage result so you can just use this method for unscaled models )

1 Like

Thanks for your answer, it works well with planes but my walls are boxes and it does not work any more when i replace your grounds by boxes. .

I’m sorry, i don’t understand anything in shaders. :pensive:

Maybe these threads can help:


you can handle that base on your model situation

for example this condition work on box

for exact answer we need see the situation


Thanks @Evgeni_Popov and @nasimiasl,

Your solutions are both working.

I have a dream, :grin: that this function should be a standard option when we define a material on a mesh.

Is the material “stretched” or “repeated” ?

But i don’t know if it is possible to implement it on all types of meshes.

1 Like

No, unfortunately my PG is very specific for the cube, that won’t work for other shapes.