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

GPU Group gpugroup at gmail.com
Sun Apr 10 11:26:40 PDT 2022


I found a flag in shader (sent by uniform) can flip conveniently: if uvs
are from gltf, node's internal bufferView/Accessor struct flip uv flag set
(during gltf parsing) and in shader if(flip) uv.y = 1.0 - uv.y.

On Sun, Apr 10, 2022 at 10:12 AM Brutzman, Donald (Don) (CIV) <
brutzman at nps.edu> wrote:

> Michalis, thanks for noting that problems emerged in prior glTF conversions
> for the online examples for Web3D.
>
> If someone is able to help us correct and update them satisfactorily, that
> will be welcome.  Likely interesting too since we can then use subversion
> diff to look at differences.
>
> all the best, Don
> --
> Don Brutzman  Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA
> +1.831.656.2149
> X3D graphics, virtual worlds, Navy robotics https://
> faculty.nps.edu/brutzman
>
> -----Original Message-----
> From: x3d-public <x3d-public-bounces at web3d.org> On Behalf Of Michalis
> Kamburelis
> Sent: Sunday, April 10, 2022 9:00 AM
> To: Holger Seelig <holger.seelig at yahoo.de>
> Cc: X3D <x3d-public at web3d.org>
> Subject: Re: [x3d-public] (FlipY) Texture coordinates for material
> textures.
>
> The examples on
> *
>
> https://x3dgraphics.com/examples/X3dForAdvancedModeling/GltfSampleModels/ind
> ex.html
> <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/ind
> ex.html
> <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/ind
> ex.html
> <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
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20220410/ea5e8539/attachment-0001.html>


More information about the x3d-public mailing list