How can I prevent texture stretching while scaling a mesh?

Hi all. I would love to be able to create brick and tile walls by taking a wall mesh and non-uniformly scaling it to a desired length and height while preserving the proportions of the brick or tile textures. I’ve tried using world aligned textures, and as long as the walls line up with the world axes, it works great. But as soon as I rotate a mesh, the texture retains its world alignment and swims out of line with the mesh. I played around with the LocalAlignedTexture node, but it doesn’t seem to do anything. How do you use LocalAlignedTexture properly? Or can you somehow rotate the world aligned texture to match the local space of a mesh? Any help would be greatly appreciated. Thanks.

1 Like

Hi!

First method

Issue - need scale with integer 2, 3, 4… not 2.1 or 3.24, because tiling between scalable and not scalable meshes is broken.

Second method

You can scale with any coefficients, but needed adjust selected parameters for new texture.

1 Like

This seems very awesome. Bookmarking this page for sure!

Thank you!

Thanks for the guide! What do youplug the bump offset group into?

Thanks for the solution but is that method still the same or any improvements? Because I’m working with modular parts right now and most of time I have to scale corner parts down (without integer numbers) to not blend with other rooms floor. So I don’t want to get busy to adjust every single deformed part. It has to be done in much effective way otherwise working with modular parts is being useless.

Is this the solution you are looking for?

I think my way it is a little easier dealing with modular building.

how did you that Maximvm?

First one is working correctly, but I need to scale my object in 3d, it only works in 2 directions now. Help, I’m not good at shaders :slight_smile:

Thank you sooo much for this, u saved me A LOT of time !!!

These methods work perfectly for height adjustments, but still stretches with width adjustments. :frowning:

Now that you’ve shown exactly what it is I’ve been looking for. Care to write up a tutorial or video of exactly step-by-step how it was done?

The video was quite fast. I could tell a blueprint was used to accomplish the task, but I’m sure the only ones able to pick up on exactly what was happening are those who are well experienced. It looked like you were using a child too and not a parent, but I haven’t gotten into doing those quite yet. A step-by-step for a noob would be wonderful.

Sure, I was not sure this was interesting. I posted long time ago and I didn’t received much reply about my question.
Anyway today I may be able to upload a new video where I show exactly to do it from scratch since I will have to redo a new project!

PTV Unreal Engine 4 Material Tutorial 5 (UV Mapping) - YouTube try this , shows scaling a 3D rock without texture being affected

1 Like

thank u so much was looking for that exact video for the past couple of hours.

Argh. Video is removed.

The only solution that I can do right now is to split the material into three. First one to handle x-y plane, second one to handle x-z plane and the last to handle y-z plane.

This works well for box shape which has 6 faces. Each material to be assigned to two corresponding faces.
It works perfectly for scaling and rotating.

There must be a more elegant implementation than this. :slight_smile:

Thanks! I was able to use your code to add this feature to my Master Material.

I use the Static X, Y, Z parameters to identify which coordinates to use. I created the toggle at the bottom to turn the feature on and off.

Also, I noticed the constants were just duplicates of the coordinates, so I was able to eliminate the static constants by plugging in the scale where the constants were.

Thought I’d share.

Something like on the screenshot is better to use for simple cube-ish geometry. No switches and single sampler.

I’ve tried following this screenshot, however the texture doesn’t quite seem to tile the way I’d expect it to.
image
This is how it looks with a Static Mesh cube at scale 1,1,1
When I scale it up along the Y axis, this is how it looks:


It also behaves weirdly on the sides:
image
The top and bottom of the cube tile exactly as expected.

This is how it looks, when scaling the cube up on the X axis:
image
Now the left and right sides of the cube tile properly alongside the top and bottom, but the front and back faces don’t.

Finally, when scaling the cube up on the Z axis, the front and back faces tile properly alongside the top and bottom, but the left and right faces don’t.


Did I just set up the Material BP incorrectly?


(Spreading the nodes out, so it’s easier to see what connects to what)