donmccurdy / glTF-Transform

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

Incorrect vertex color dequantization, context-dependent #1271

Closed timothyallan closed 9 months ago

timothyallan commented 9 months ago

I have a clients model which goes through my gltf-transform v3.10.0 + node 18.19 optimizing process, which is basically the same as the R3F transform here https://github.com/pmndrs/gltfjsx/blob/master/src/utils/transform.js

As soon as reorder({ encoder: MeshoptEncoder }) is introduced (with either 'size' or 'performance' options), this happens:

Screenshot 2024-02-17 at 12 27 26 PM Screenshot 2024-02-17 at 12 22 15 PM

Loading it into the online viewer, it appears fine, but shows 5 errors relating to a material clearcoatFactor from the blender export, but nothing super out of the ordinary. Screenshot 2024-02-17 at 12 53 40 PM

I've run many dozens of different models through this pipeline and it's the first time this has happened. Any suggestions or ideas? I can provide a private link to the model if required.

donmccurdy commented 9 months ago

@timothyallan is it possible that there's alpha blending enabled on this material, where it should be opaque? That's my first guess, and reorder() could certainly cause unexpected issues in such a model. But if not, I may need to take a look at the model. My email address can be found on my GitHub profile or website (https://www.donmccurdy.com/).

donmccurdy commented 9 months ago

Thanks @timothyallan! I've fixed the issue and published to v4.0.0-alpha.7. Installing from the @next tag will pull in the v4 alpha release:

npm install --save @gltf-transform/core@next @gltf-transform/extensions@next @gltf-transform/functions@next
timothyallan commented 9 months ago

Just tested it, and it works great now. Thanks for your assist on this @donmccurdy!