[x3d-public] (FlipY) Texture coordinates for material textures.

Michalis Kamburelis michalis.kambi at gmail.com
Sun Apr 10 08:59:49 PDT 2022


The examples on
https://x3dgraphics.com/examples/X3dForAdvancedModeling/GltfSampleModels/index.html
are incorrect.

You can instead just use
https://github.com/KhronosGroup/glTF-Sample-Models/ examples, and
convert them to X3D yourself using latest view3dscene with
"--no-x3d-extensions" command-line parameter.

Explanation:

Unfortunately glTF has different treatment of texture coordinates than
X3D, assuming that Y=0 is "up" and Y=1 is "bottom of the image". This
is consistent with WebGL, but inconsistent with OpenGL, OpenGLES, X3D.
(Yes, it sucks that WebGL is inconsistent with OpenGL/OpenGLES in this
case.)

OTOH: X3D, OpenGL, OpenGLES, all say that Y=0 is "bottom" and Y=1 is
"up of the texure image".

There are various possible solutions to this:

1. CGE/view3scene by default places "flipVertically=true" in texture
nodes, see https://castle-engine.io/x3d_implementation_texturing_extensions.php#section_flip_vertically
. But this is non-standard CGE extension.

2.  If you perform conversion using CGE/view3scene->glTF with
"--no-x3d-extensions" command-line parameter, than we don't place
"flipVertically" in file, instead we process TextureCoordinates
contents to flip them.

3. Finally, one can also use TextureTransform as you say.

"""
      textureTransform TextureTransform {
        translation 0 -1
        scale 1 -1
      }
"""

achieves what is necessary.

AD 3 is also what i would advise most X3D browsers. (Because AD 2
requires per-vertex processing, which should be avoided in general. AD
1 is CGE specific, and probably most X3D viewers don't care about this
extra optimization that "avoids doing TextureTransform at runtime".)

The examples on
https://x3dgraphics.com/examples/X3dForAdvancedModeling/GltfSampleModels/index.html
are just wrong. Someone used CGE/view3dcene without
"--no-x3d-extensions" to generate glTF outout, and then removed
flipVertically=true, thus making texture coords incorrect. I recall we
talked about it with Don, CGE/view3dscene didn't have
"--no-x3d-extensions" initially. Looks like noone had time to finalize
this properly. The examples should be recreated with
"--no-x3d-extensions".

Regards,
Michalis

niedz., 10 kwi 2022 o 17:05 Holger Seelig <holger.seelig at yahoo.de> napisał(a):
>
> I recently tested the new glTF examples from https://x3dgraphics.com/examples/X3dForAdvancedModeling/GltfSampleModels/index.html with X_ITE alpha version and recognized that the textures coordinated are y-flipped. I also tested View3DScene and it also happens there. I know that glTF does no y-flip with textures  as X3D does, thus a conversion from glTF to X3D should handle this and add a TextureTransform with translation 0 1 and scale 1 -1. This would mean that this TextureTransform must be added to the examples. Is this correct, or are the textures from material nodes somewhere handled specially?
>
> Best regards,
> Holger
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org



More information about the x3d-public mailing list