donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.42k stars 150 forks source link

VRM Support #1137

Open donmccurdy opened 1 year ago

donmccurdy commented 1 year ago

VRM is a file format focused on features relevant to humanoid character avatars. The format consists of extensions on top of the glTF file format, and could be implemented in glTF Transform as a set of extensions similar to @gltf-transform/extensions.

hybridherbst commented 1 year ago

One note here as we're also looking into this: v0 is widely used, v1 is "official" now but seems to still be beta/in testing and is comparatively complex. v0 has lots of typos in the spec, very fun to work with...

miramocha commented 12 months ago

Somewhat related to this. Is there a way to turn off byteStride on export? I was able to read and write VRM0 with this super rough code and it works fine in ThreeJS.

https://github.com/donmccurdy/glTF-Transform/pull/1180/files#diff-9a9aab68c9cd82e5d7eeae7f9fd766aaf20558c7c9c7644fb8d55296936b277a

But UniVRM plugin does not handle these byteStrides really well. For the context, UniVRM is a Unity extension/package that allows apps to load VRM on runtime. And every VRM Unity app I found seems to use it. (See below)

F_2UZbvW0AA5fw5

We can use typings from @pixiv. But in my code I'm not sure how do that so I serialize most of them and only keep track of texture and node reference.

hybridherbst commented 12 months ago

@miramocha can you attach an example file? If the byteStride is missing they may simply be incorrect glTF files that are parsed by some more loosely checking implementations (or the ones where extra care has to be taken to read, strictly speaking, broken data).

(btw I'm also looking at VRM import/export support for UnityGltf, UniVRM has many issues)

donmccurdy commented 12 months ago

Probably byteStride here means interleaved vertex data? If you're using an application that doesn't support interleaved data, you can disable that with --vertex-layout separate in the CLI, or with .setVertexLayout on the IO classes:

miramocha commented 12 months ago

That's the settings I'm looking for, thank you so much!!!! image

miramocha commented 12 months ago

@miramocha can you attach an example file? If the byteStride is missing they may simply be incorrect glTF files that are parsed by some more loosely checking implementations (or the ones where extra care has to be taken to read, strictly speaking, broken data).

(btw I'm also looking at VRM import/export support for UnityGltf, UniVRM has many issues)

If you are interested, they weren't supporting interleaved vertex until relatively recently here: https://github.com/vrm-c/UniVRM/pull/1949

and even that it's still bit buggy. ThreeVRM seems to support it perfectly fine though