microsoft / glTF-SDK

glTF-SDK is a C++ Software Development Kit for glTF (GL Transmission Format -https://github.com/KhronosGroup/glTF).
MIT License
541 stars 100 forks source link

Can a single vertex have multiple UV coordinates depending on how many faces it belongs to? #138

Open jimver04 opened 6 months ago

jimver04 commented 6 months ago

Hi,

Let us assume that we have two triangles connected to make a quad.

I use gltf-sdk to export the quad with 4 UV texture coordinates, one per vertex, as follows.

The upper triangle (T1) has all 3 UV coordinates as pink (3 dots at pink pixel in the example) image

whereas the lower triangle (T2) has 1 new UV coordinate (1 dot at green) and two old pink UV coordinates from T1 image

So far so good.

In Blender3D, when I select the face of T2, I can change the UV coordinate of the shared upper vertex for T2, image

the part of T2 at shared vertex become green without affecting T1. image

When I export from Blender3D to gltf, this shared vertex that has different UV coordinate for T1 vs T2, becomes duplicated:

image

From what I have understood, GLTF format does not allow a vertex to have two UV coordinates. See this stackoverflow: https://gamedev.stackexchange.com/questions/140132/how-can-i-use-blender-style-uvs-and-not-per-vertex-in-opengl whereas Blender allows it. Blender uses all features of OpenGL whereas GLTF is let us say a "gpu friendly" format (https://stackoverflow.com/questions/61521259/vertex-normal-texture-uv-coordinate).

Best, Dimitrios

bghgary commented 6 months ago

I'm not sure I understand the ask. glTF-SDK is intended to read/write a glTF, so if the glTF spec doesn't support this, then the SDK won't either. If there is no way to represent what you want in a glTF, then the SDK won't be able to represent it and thus the questions are moot. Or did I misunderstand something?