Inversion of dynamic textures for right-handed system

We create dynamic textures that swap the direction of text when using the right-handed system.

I’ve looked at a couple of options in the forum, but I’m not getting the desired result without actually scaling the mesh directly (-1, 1, 1). I’d like to avoid applying any scaling on the mesh and rather revise the logic on the texture (based on left/right handedness).

Unfortunately invertY or uscale does not yield the desired effect either.

I’ve created a playground (https://playground.babylonjs.com/#23FNE4)

This is a very simple problem and want to ensure we can handle dynamic textures (irrespective of handedness) that handles both cases.

Any advice / guidance would be appreciated.

You can adjust your texture mapping by inverting U (u0, u1) coordinate of each segment.


 faceUV[i] = new BABYLON.Vector4((i + 1) / faceColumns, 0, i / faceColumns, 1 / faceRows);

Basically UV values here are represented as BABYLON.Vector4(u0, v0, u1, v1) where

  • u0 and v0 are the coordinates of the lower-left corner of the texture (starting point).
  • u1 and v1 are the coordinates of the upper-right corner of the texture (ending point).

So in this new line of code you achieve the following:

  • (i + 1) / faceColumns is now the starting U coordinate. This moves the start point to what was previously the end point of each texture slice.
  • i / faceColumns becomes the ending U coordinate, moving the endpoint to what was previously the start.
2 Likes

Brilliant, thank you for the quick and detailed response.

1 Like