Difference (Y fliped) uv cord between babylon and threejs?

Hi all:
New to babylon.Js, I try to migrate the https://github.com/brunosimon/my-room-in-3d project to babylon, after migrate the model texture and shader code, I find the uv cord is Y mirrored(green postion cord to red)


I just mirror the texture in photoshop to solve the problem :joy: . So my question is which is the correct way to solve this problem?

  1. best to change babylon code to adapt same asset with threejs, but i dont know how to change UV cord in shader? multiply some matrix to uv? or some api to change directly?
  2. change blender export options? how?
  3. just use photoshop :grin:

Hello and welcome to the Babylon community! That’s a very cute project you’re migrating :smiley:

Since you already have code to sample the textures, you can just multiply the y coord of the uvs by -1.

1 Like

You can also pass false as the invertY parameter of the Texture constructor in case you are creating the textures yourself.

3 Likes

Thanks for your replay, awsome community @Evgeni_Popov @carolhmj :heart_eyes:
Two solution both works very fine!

vec2 newUvCord = vec2(vUv.x, 1.0 - vUv.y);

and

this.assetsManager.addTextureTask(
  `${key}_${asset.name}`,
  `${this.rootUrl}${asset.file}`,
  false,
  false, // just invertY to false
);
1 Like