Overcoming image reflections and right hand systems per mesh

ref UV Map flipped for Imported Mesh from Blender file.glb - #61 by JohnK


  1. Some meshes created by Babylon.js have textures reflected, for example https://playground.babylonjs.com/#KZDXTB#7
  2. Some imports come from apps using a right handed system.

Especially when mixing imports from different apps and/or directly created babylon.js meshes 1 and 2 together can prove insurmountable.

Proposed solution.

  1. Add additional options’ parameters where appropriate that would ensure textures are not reflected.
  2. add the property reflection to a mesh in the form
mesh.reflection = N; //N a Vector3 which is the normal of a plane through the mesh origin (mesh position)  in which the mesh is relected.

I am happy to do a PR for 1. For 2, I am happy to produce a reflection matrix that can be applied to a mesh but have no clue how such a matrix is applied to the world matrix.

I belive using the reflection together with a rotation on a mesh will be able to orientate a mesh from a RHS to display within our LHS as it was in the RHS.

I will first produce a reflection function in a PG as an example to check it works.

Timescale unknown but definitely after the v5.0 launch

EDIT Problems with reflection, see my post below

1 Like

I think the problem has already a solution (If I understand correctly): The texture can be loaded with invertY OR the texture.vScale can be set to -1 OR the mesh uvs can be inverted

Unfortunately these do not cover every situation it seems when you read through the full link I gave UV Map flipped for Imported Mesh from Blender file.glb

Unless ecoin and I are missing something.

EDIT I know think I need to go back to looking closer at left hand and right hand systems for 2. I still think there is some mileage in looking at correcting, via a new parameter, image direction on creation particularly for cylinders and polygons with holes.

Yes, to summarize, you cannot use invertY or revert any of the Texture scales because of these requirements:

  1. To work with both Babylon created Meshes (UV start from top left) and GLTF (UV starts from bottom left) at the same time
  2. To work with Texture transforms (any combination of rotation/offset/scale)
  3. To work with Bump Textures for correct normal mapping with other Textures

This is not true for Babylon.js see UV Map flipped for Imported Mesh from Blender file.glb - #63 by JohnK

Text reflection can occur if in constructing a mesh uv values are flipped on the faces of the mesh, (u, v) values are still read from the bottom left of the image.

It appears that just forming a reflection matrix that only works by adjusting the worldMatrix is not sufficient as depending on the plane of reflection some triangular facets need their normals reflected while other need their indices reversed. Back to the drawing board.

1 Like