kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
263 stars 39 forks source link

Support for multiple UV channels #149

Closed DavidArayan closed 5 years ago

DavidArayan commented 5 years ago

Hello,

We have been using this tool and it's absolutely fantastic, so thank you for sharing this tool!

I'd like to ask if it were possible to add support for multi UV channels? For example, currently trying to export GLTF with baked lightmaps (in seperate uv channels) looks messed up. Does USDZ actually support multiple UV channels?

Have a great day!

kcoley commented 5 years ago

Hi @DavidArayan . I just merged a fix to support the TEXCOORD_1 attribute, so two UV channels should be supported. Are you trying to use more than two UV maps?

DavidArayan commented 5 years ago

Hello @kcoley . We are just using 2 UV channels at the moment, 2nd being for lightmaps. That was really quick work thank you! will pull, and try it out.

DavidArayan commented 5 years ago

Hello @kcoley Sorry, just tried out your changes but the lightmaps in the secondary UV channel are still not applied to the USDZ model. I'll try to source you an example GLTF file to check out.

DavidArayan commented 5 years ago

Hello @kcoley

I've got the files for reference.

USDZ

screen shot 2019-02-28 at 5 50 18 pm

GLTF

screen shot 2019-02-28 at 5 50 28 pm

Original files (as a zip) contains the .GLTF file and the converted .USDZ file UV_Cube.zip

kcoley commented 5 years ago

@DavidArayan thanks for the sample model. It looks like the occlusion texture is actually set in the usdz file, but QuickLook seems to be multiplying the occlusion map to the diffuse color. However, if you view the usdz file in Xcode, it seems to behave more like ThreeJS, where the occlusion texture effect is "decreased" when facing a light source:

screen shot 2019-02-28 at 6 04 09 am

However, the UV map for Three.js used for occlusion seems to be incorrect.

The usdz file looks similar to how BabylonJS is rendering the model in the sandbox:

screen shot 2019-02-28 at 6 05 42 am

But again, it looks like the occlusion is baked with the diffuse color.

So in summary, it seems to be an issue with how Quicklook is handling AO.

DavidArayan commented 5 years ago

Hello @kcoley ,

Thank you for your insight. I might end up writing an external tool that either merges the UV channels into a single channel or just not use lightmaps.

kcoley commented 5 years ago

@DavidArayan no problem, and good luck!