Skip to content

Clarification: Texture Image Orientation #1021

@mlimper

Description

@mlimper

Hi,

we are currently running into an issue with texture image orientation.

The glTF 2.0 spec says the following:
First image pixel (UV coordinates origin) corresponds to the upper left corner of the image. Implementation Note: OpenGL-based implementations must flip Y axis to achieve correct texture sampling.

So, just to get this straight:
This means that exporters should store texture images in the typical standard orientation where the lower left corner of the image corresponds to the lower left corner of the UV space - correct? I am asking because this is what usually requires the flip, which the spec expects from the GL implementation.

Here's a simple (Collada) example loaded in MeshLab:
image

The image is loaded into the UV space "as-is". Meaning, the eye of the duck is still in the upper right corner, as it was in the original image. In this case, the OpenGL-based implementation must flip.

The issue we're observing right now is that exporters start to flip images, or UV coordinates, because runtimes seem to expect them in a non-standard (? at least uncommon) orientation. See, for example, this thread:
Kupoman/blendergltf#59

This applies to BabylonJS (at least the version we are using) and Three.js, which seem to expect the images or UVs "upside down":
https://threejs.org/examples/webgl_loader_gltf2.html
https://threejs.org/examples/js/loaders/GLTF2Loader.js
(search for "_texture.flipY = false;")

So, given that those two engines already do it consistently, it could also be that I am getting this wrong?
Or are the runtimes indeed missing to flip the texture properly?

Thanks a lot in advance!

@bghgary Can I ask you again about your comments on this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions