GLB export changes original image

OS: Windows 10 x64
Browser: ungoogled-chromium 108.0.5359.95
Babylon.js: 5.38.0
Playground: Babylon.js Playground

Expected:
Exported GLB should contains the original image.

Actual:
JPEG-encoded image is converted to PNG.
Image size goes from 8160 bytes to 112602 bytes.
See the console.assert codes for detail.

You must pass the mime type when creating the texture for the exporter to use the correct image type:

Note that the exported image size is different from the source image because the data are read from the texture and recompressed. We don’t keep the original source image to avoid consuming too much memory.

1 Like

But the image is recompressed even if the source image is kept in case of loaded glb.

In fact, we have the original data because context lost handling is enabled by default (engine.doNotHandleContextLost == false). This is true for any texture (but the data is not always in _buffer). If the context lost handling is disabled, however, no data is available.

So maybe using the original texture data when engine.doNotHandleContextLost == false could be a solution in this case…

cc @bghgary and @srzerbetto

1 Like

This can be an optimization if the original texture data is available and matches the mime type. Anyone want to contribute a fix?

1 Like