# Apply uvScale per mesh

**URL:** <https://forum.babylonjs.com/t/apply-uvscale-per-mesh/34390>\
**Category:** Questions\
**Tags:** material\
**Created:** [October 1, 2022, 2:09am UTC](https://forum.babylonjs.com/t/apply-uvscale-per-mesh/34390 "2022-10-01T02:09:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alekop](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alekop/32/4380_2.png) [@alekop](https://forum.babylonjs.com/u/alekop)\
**Post date:** [October 1, 2022, 2:09am UTC](https://forum.babylonjs.com/t/apply-uvscale-per-mesh/34390/1 "2022-10-01T02:09:39Z")

</div>

Can we apply uScale, vScale per mesh? For example, if we want to apply the same material to two different sized meshes, we need different uv scales.

---

<div class="post-metadata">

**Author:** ![flex](https://avatars.discourse-cdn.com/v4/letter/f/8baadc/32.png) [@flex](https://forum.babylonjs.com/u/flex)\
**Post date:** [October 1, 2022, 11:38am UTC](https://forum.babylonjs.com/t/apply-uvscale-per-mesh/34390/2 "2022-10-01T11:38:09Z")

</div>

Yes.

> **[BaseTexture | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.BaseTexture#scale)**
>
> Base class of all the textures in babylon.It groups all the common properties the materials, post process, lights... might needin order to make a co \[

If you don’t need to have different u and v scale you can use the scale property.

If you need more granular control, such as different orientation of texture based on whatever criteria you can also edit the UVs. Here’s a snippet:

```
    const positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
    const normals = mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
    const uvs = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
    if(!positions || ! normals || !uvs ) return;
    const numberOfVertices = positions.length/3;
    for(let i = 0; i < numberOfVertices; i++){
        const normal = BABYLON.Vector3.FromArray(normals,i*3);
        const position = BABYLON.Vector3.FromArray(positions,i*3);
        position.multiplyInPlace(scaling).scaleInPlace(1/100);
        
        if (normal.equalsWithEpsilon(BABYLON.Vector3.Left()) ||
            normal.equalsWithEpsilon(BABYLON.Vector3.Right())){
            uvs[i*2] = position.z
            uvs[i*2+1] = position.y;
        }
    }
    mesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs, true);
}

```
