You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
note: depending on how you look at it this might not be a bug, perhaps the user need more control regarding packed image format at export.
Describe the bug
In specific conditions images might be exported as PNG when they should be exported as JPG, which drastically inflate the size of the resulting GLB/GLTF.
To Reproduce/Expected behavior
Have one object with one material applied to it.
Feed the BSDF with a Base Color image texture, a bundled Roughness/Metallic map with separated green channel to Roughness and blue channel to Metallic BSDF inputs. (Base Color and R/M are all JPG)
Feed on AO texture to a glTF Settings group node. (AO is JPG)
Set exporter image format to Automatic.
Export.
Two things may happen:
if your AO texture is of different size than your R/M texture they won't get bundled and all of them stay as JPG. That's expected behavior.
if your AO texture is the same size than your R/M texture the AO get bundled on the Red channel and the whole image become PNG. This drastically inflate the overall .glb size for no reason.
In short, it seems that anytime the exporter find AO, R, or M textures of the same size that aren't bundled it will ignore their respective format and merge them into a PNG RGB channels. This goes against the Automatic format description which state that JPEG will be exported as JPEG and PNG as PNG.
I don't mind the automatic merging but I would prefer the exporter to check the format of each images before merging and if all are JPG make sure that the resulting image is JPG. To me that's what make the most sense in production.
Screenshots
Setup:
AO is 256x256, Base Color and R/M are 1024x1024. Result is 3 light JPG (roughly 100ko*3 = 300ko)
All textures are 1024x1024. AO get bundled with R/M and resulting image is a heavy PNG (100ko Base Color + 1.14Mo AO/R/M = 1.24Mo)
To be very clear, the size increase is partly due to the AO going from 256 to 1024 but that would be a 100ko difference MAX. The blame is really on the PNG format here.
Additional context
You might think that I could just force the JPG format at export, but if I had a normal map I'd not want to do that as it need to be PNG.
You might also think that I just have to bundle AO with R/M before exporting to JPG format. And while this would probably work this means that every time I bake a new AO texture I have to go outside of Blender and bundle it manually with R/M. To me that defeat the purpose of the exporter.
When an image needs to be packed from channels, the packed image can sometimes be a JPEG if one of the constituents is (note: only sometimes!). This is lossy and causes channel-bleed (#818). I think a better default is to prefer being lossless.
If all constituents are JPEG I think the resulting packed image should be JPEG too. Yes this would cause some amount of bleed but
you decrease the size of the texture by a lot (up to 10 times?). If you choose to have AO/R/N as JPEG initially it means you care more about final glb size than quality. Or perhaps we should add an option regarding packed image format in the exporter?
The text was updated successfully, but these errors were encountered:
Yes this totally address the issue, sorry I couldn't find the post before making mine. And I think you ended up with the right solution avoiding packing JPG with PNG all-together. But I've added a comment regarding multiple materials on that issue, I think you guys missed an important problem with automatic packing.
note: depending on how you look at it this might not be a bug, perhaps the user need more control regarding packed image format at export.
Describe the bug
In specific conditions images might be exported as PNG when they should be exported as JPG, which drastically inflate the size of the resulting GLB/GLTF.
To Reproduce/Expected behavior
Have one object with one material applied to it.
Feed the BSDF with a Base Color image texture, a bundled Roughness/Metallic map with separated green channel to Roughness and blue channel to Metallic BSDF inputs. (Base Color and R/M are all JPG)
Feed on AO texture to a glTF Settings group node. (AO is JPG)
Set exporter image format to Automatic.
Export.
Two things may happen:
In short, it seems that anytime the exporter find AO, R, or M textures of the same size that aren't bundled it will ignore their respective format and merge them into a PNG RGB channels. This goes against the Automatic format description which state that JPEG will be exported as JPEG and PNG as PNG.
I don't mind the automatic merging but I would prefer the exporter to check the format of each images before merging and if all are JPG make sure that the resulting image is JPG. To me that's what make the most sense in production.
Screenshots
Setup:
AO is 256x256, Base Color and R/M are 1024x1024. Result is 3 light JPG (roughly 100ko*3 = 300ko)
All textures are 1024x1024. AO get bundled with R/M and resulting image is a heavy PNG (100ko Base Color + 1.14Mo AO/R/M = 1.24Mo)
To be very clear, the size increase is partly due to the AO going from 256 to 1024 but that would be a 100ko difference MAX. The blame is really on the PNG format here.
.blend file/ .gltf
testy-test.zip
Version
Windows, last Blender version (2.91.2)
Additional context
You might think that I could just force the JPG format at export, but if I had a normal map I'd not want to do that as it need to be PNG.
You might also think that I just have to bundle AO with R/M before exporting to JPG format. And while this would probably work this means that every time I bake a new AO texture I have to go outside of Blender and bundle it manually with R/M. To me that defeat the purpose of the exporter.
I think this issue was what started my issue:
If all constituents are JPEG I think the resulting packed image should be JPEG too. Yes this would cause some amount of bleed but
you decrease the size of the texture by a lot (up to 10 times?). If you choose to have AO/R/N as JPEG initially it means you care more about final glb size than quality. Or perhaps we should add an option regarding packed image format in the exporter?
The text was updated successfully, but these errors were encountered: