Closed ghost closed 5 years ago
Could it be because of the asset https://s3.us-east-1.amazonaws.com/sayduck-production/a/shared_assets/files/000/010/829/fda8dd8cb6880ec0e153aa6bc06be273e0a2728fcc1c4e5176471964e10541c1-optimized_texture_jpg_2048.jpg ?
It seems to be a grayscale image.
Hi @sayduck-daniel , yeah seems to be the case. Is this texture being used as a normal map? I believe glTF expects it to be an RGB texture, similar to this: https://github.com/KhronosGroup/glTF-Asset-Generator/blob/master/Output/Material/Textures/Normal_Plane.png
Yes, it's a normal map. But it seems greyscale normal maps work with gltf.
Do you think it would be out of the scope of this project to implement a safeguard in case a texture is in grayscale perhaps?
We are importing models from another system and it happens we used a lot of maps in greyscale.
@sayduck-daniel sure we could do that, have the grayscale values duplicated to the RGB channels
@sayduck-daniel actually, duplicating the grayscale isn't really a normal map and would yield the wrong results. This would probably involve generating a new normal map from a sobel filter, which might be better handled with a separate tool. I'll look into how difficult this might be or if there is already a tool out there.
Yes that is correct.
One thing in favor of having the convert in there for me is the fact sometimes an user uploads a RGB map and somehow this map gets converted to grayscale by ImageMagick in our side.
ImageMagick seems to take the decision that if there is nothing on 2 channels it should be set to grayscale.
I tried to counter this behavior but so far nothing conclusive. On top of that, glTF renders as normal with this map in greyscale.
If someone stumbles upon this problem there is what we did:
After further investigation, we realised that ImageMagick is smart enough to automatically convert an image to grayscale if the image is an actual grayscale:
convert my_image_created_with_photoshop_and_set_to_RGB_with_3_channels.jpg imagemagik_image.jpg
This will result in a grayscale if it detects only grey!!!
To avoid that, we are now using only RGB and use the parameters -type truecolor -colorspace RGB
for JPG and -define png:bit-depth=8 -define png:color-type=6 -colorspace RGB
for PNG.
@sayduck-daniel I merged a change for this to copy the single channel grayscale to the RGB channels: https://github.com/kcoley/gltf2usd/pull/98
Feel free to re-open if this still causes issues
I started getting:
This is the GLTF failing:
Any idea from where this could come?