[Lite] How to tranform a texture?

Please have a look at his PG (line 37 and 50): Babylon Lite Playground

I want to scale and rotate the texture but setting uScale or uAng doesn’t change anything. What is the correct way to apply the transform? I also tried to use cloneTexture2D but that also doesn’t help. What is missing here?

Maybe this example will help - Babylon Lite Playground

Thank you but i can’t do that in my case because the same geometry is used with different textures.

Good catch. Two separate things were biting you:

1. The UV transform machinery is opt-in at material build time. Lite only compiles the per-texture UV matrices into the shader when the material needs them (pay for what you use). Until now, that flag was only set automatically for glTF materials with a non-identity KHR_texture_transform, so a hand-built material with uScale/uAng silently missed the machinery: the values were stored but the shader had no slot to receive them. I just landed a fix for that(pr on its way): any texture carrying a non-identity uScale/vScale/uAng/uOffset/vOffset at build time now enables the machinery automatically. So in the next build, your original code works as written, as long as the values are set before the mesh enters the scene.

2. Changing the transform at runtime needs a dirty mark. These are plain fields, nothing observes them. After mutating them post-render, call markMaterialUboDirty(material) (exported from the package root) so the material UBO is rewritten. One extra subtlety for animation: if your transform starts at identity and only becomes non-identity at runtime, the build-time scan cannot see the future. Call enableMaterialUvTransform(material) before the first render (also exported from the package root after my pr ), then mutate + mark dirty each frame.

Note the transform is per texture channel (baseColor, normal, emissive, ORM each get their own matrix), and no cloneTexture2D is needed for any of this.

I saw the new enableMaterialUvTransform function. This works for PBR materials only. Do you also plan to add a solution for the StandardMaterial?

Yes it is almost done actually :slight_smile:

feat(standard): support material UV transforms by deltakosh · Pull Request #548 · BabylonJS/Babylon-Lite

Thanks a lot for the “transformUv” i wonder how can i transform a texture, this PG is very helpful!!