Dynamic Texture With KTX?

I’m not sure if this is possible, but we’re trying to figure out a way to use letters in a sprite sheet. They have to be a sprite sheet because the bump maps will need special normal maps to mimic embroidery. It looks like the DynamicTexture is our best bet but that just uses PNG files. Is it possible to load the image with compression?

Seems highly un-likely. Compressed textures are usually made in an offline process / utility program taking textures understood by CPU’s [jpg, png, bmp] and encoding them into ones that are customized for GPU can use [dxt, etc1, etc2, pvrtc,astc].

I do not know of any javascript conversion code. Worse, it can be pretty slow. ASTC conversion can take minutes. Worst, you will have to generate based on what GPU are on. Dynamic KTX might sort of an oxymoron.

The one caveat is that since I have no idea what a sprite sheet is, maybe I am misunderstanding what you are asking. If you are saying that you wish update a texture in t scene with the cpu then transfer it to the gpu in a compressed texture, I wouldn’t want to be you.

Here is a playground. Using DynamicTexture I can render letters from a custom sprite sheet. Using PNG files isn’t ideal but I don’t understand the code under the hood enough to know if it is using BabylonTextures that could be .ktx

https://www.babylonjs-playground.com/#11GAIH#87

If you are asking can img.src be a compressed texture, I am doubtful. The context of that DynamicTexture is a 2D canvas, not a WebGL canvas. Compressed textures are associated OpenGL / WebGL. 2D canvas is a CPU thing.

Not sure you would gain anything other than GPU memory footprint, anyway. Since not using GPU, no point AFAIK.

You it is not possible to use compressed texture with a 2d canvas which as @JCPalmer explained is the base used in the dynamic texture.

You would need in your case to rely on procedural textures for instance to be able to directly do the same in the main 3d context.