Is it possible for GUI Image to support compressed textures, i.e. basis?

Is it possible for GUI Image to support compressed textures, i.e. basis?

Also, is there a way to basically convert a scene texture into a GUI image? (to preserve compression, i.e. not render to a renderTargetTexture as a png and use the result as a data url or whatever)

The GUI uses the 2D canvas context to draw stuff, so it’s up to the browser how the images get sent to the GPU.

To create a GUI image from a texture, you can create ImageData from a texture, from which you can create an ImageBitmap, which you can set as a new GUI image’s domImage:

https://playground.babylonjs.com/#CX09WL

1 Like

So finally getting back to this, just a couple months later :slight_smile:

Looks like it doesn’t actually work for basis, i.e.

https://www.babylonjs-playground.com/#E4VDDW#4

(line 174)

No errors, but doesn’t load, though there is a warning: [.WebGL-0x7f9ca20b5000]GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glReadPixels: framebuffer incomplete

Which is same warning I see when I tried it in my project locally.

Anyone know if it’s possible to do this with basis textures? Maybe failing due to mipmaps or something?

GUI is using canvas 2d which does not support compressed textures the only way would be to use a canvas with babylon to load compressed texture, read them as uncompress and populate the gui with that but you d lose all the advantages of compressed in this case.

In your case would planes not work ?

Ok good to know thanks.

Planes could work, but I was using GUI for a part of the UI because was having issues with multi cam/active camera, and because GUI seems to fit it better (and it would make things really easy if I could load my basis sprites in GUI, as I don’t want to load giant pngs), but maybe I need to fix the multi cam issues. --But also because it’s awkward to position planes that are part of the UI, positioned along side of the GUI. Screenshot because that was probably confusing explanation:

(the text at the top right is GUI, as are the planets, but loading them from a PNG sprite instead of basis)

Maybe here you can use a mix experience ? gui for text and planes just for the sprites ?

This would be the most efficient mem wise

but also using png might be just fine :wink: