Closed enzyme69 closed 5 years ago
Works ok on Clay-Viewer:
@enzyme69 do you have a sample model that repros this issue?
@kcoley This is the one: USDZ_donut_rgba_error.zip
Maybe the texture itself is problematic. Just now, I convert all the PNG into JPG and works!
So the texture it's failing on is the Ambient Occlusion png, which has 4 channels. The _convert_materials_to_preview_surface
function goes in expecting to use the r
component of the occulusionTexture
image as the occlusion map, sees a 4 channel image, which jumps to logic trying to unpack a glossiness map.
I think if you change your ao.png to only be 3 channels, it should work
@enzyme69 yes what @ox says is correct since the logic initially assumes that you are using an ORM texture (occlusion: r, roughness: g, metallic: b). The texture logic definitely needs refactoring. I will look into that later today to make it more robust. But in the meantime, @ox solution should work.
Also something interesting I found with RGBA and RGB, try the model below: https://sketchfab.com/models/f8b43d7d9f914480bfc91c8a4d6fd314
For some PNG, it gives this weird flipped overlapping material on the USDZ after conversion. Again this is seems to be RGBA related. If I save PNG as RGB, it works good.
It makes me wonder if we actually have "Occlusion Transparency Shader" already ...
@kcoley Do you mean in the Blender material node itself, I could have Roughness - Metalness -Occlusion (greyscale) plug into RGB node which will translate into GLTF and works with your conversion?
It's this Metalness and Roughness which unfortunate...
It makes me wonder if we actually have "Occlusion Transparency Shader" already ... I have a similar issue. My model does not reflect light the same way it does in gltf
@sulydeni @sulydeni I think the USD implementation in XCode/iOS always reads the alpha value even if it is not used in the glTF and is ignored in the usd file. I'll make an issue to remove the alpha channel from the texture if it is not used in glTf.
I recently merged a change to remove alpha channel based on alpha mode: https://github.com/kcoley/gltf2usd/pull/93
Just now, I exported GLTF material from Blender, and during conversion, I am getting this error:
So far, I have tested 3D GLTF from Sketchfab only and never had issue. Only today I am setting up the shader based on GLTF Blend example. Then I exported the object and getting an error. It does not seem to like RGBA, maybe I should change it to JPG?