Move vertices without distorting texture?

Hi there,

I need to be able to deform an already existing simple geometry with a material in it.
I need to make it shorter depending on parameter.
So, if I make it shorter, the texture deforms.
In order to fix that, I’d need to move its UVs exactly the same relative amount as vertices, so the texture doesn’t stretch or compress.

See this GIF animation that shows how that is accomplish inside MAYA:


It there a way to do that?


Heya, here’s a quick example to show one way to do it: by scaling position.x and uv.x by the same amount. :slight_smile:
PG: Babylon.js Playground

Edit: I showed how to do it in the node material because that’s what you’re asking about I think, but you could also do the same thing in JS using mesh.scaling.x and texture.uScale like in this version of the PG.


Thank you very much @Blake

My coding guy @paleRider will be happy to give that a sight.

We are trying to make a procedural way of creating wood planks of different sizes based on users input.
This is the way I thought it could be done, but you know, I come from offline 3D DCCs, so I don’t know if there are better ways to do this kind of thing.


Thanks, @Blake:

@joie and I, will take a look at both NME based and by-code ways.

Thanks for your time.

Hi there @Blake

I’ve struggling about what we want to achieve and how to do it.

As I see it, we have two options, either scale the texture (that’s what I see you do in your PG with the attribute texture.uScale), OR by scaling the UVs of the object (I don’t know if that is even possible in BabylonJS).

In both scenarios we have the same issue: we need to scale “some” parts of the UVs.

Your scene is quite simple, just a plane.

But we need to create a kind of wood plank with both variable length and thickness.

So, if we want to change the length of the wood plank, we’d just move the vertices to enlarge it, and then scale the UVs of that part of the object accordingly, BUT NOT the others. And viceversa if we want to change its thickness.

So, how do we scale SOME UVs of the object?

Can we just scale a RANGE of UVs and leave the rest intact?

So for example, if we want to enlarge the plank, then we scale in U direction the UVs from 0.0 to 0.5 ONLY.

Is that possible?
Thanks in advance!

For the moment, we’ve seen this thread, so we will be reading it and see if it can fit what we need.

1 Like