Loading textures from UnityWebRequest with DXT5 compression

Hi,

Something I’m just trying to work out is in regards to if it’s possible to use a UnityWebRequest with a non RGB24 or RGBA32 format?

I use these lines to load a saved .png in a compressed fashion.

byte[ ] bytes = System.IO.File.ReadAllBytes(Application.persistentDataPath + “/Thumbnails/” + subDirectory + contentID + “.png”);
Texture2D texture = new Texture2D(1, 1, TextureFormat.DXT5, false);
texture.LoadImage(bytes);

I’d like to do the same when I use a UnityWebRequest but I can’t seem to see a way of requesting what format the texture is provided in. Is there a way I can do this?

Ideally would like to use the example on this page but provide the texture format I want: Unity - Scripting API: Networking.UnityWebRequestTexture.GetTexture

Thanks,

Hi @Virtimed ,

Have you already tried to store a texture with DXT5 compression in your server and retrieve it using UnityWebRequestTexture.GetTexture on the client using Unity’s Editor?

If so, and it’s not loaded properly, do you have any error message on the Unity’s Console?

Thanks!

@DiegoDePalacio_1 Ahh I don’t think so. I thought with the old WWW API you could specify the format?

I’m not sure about that, but you can certainly try with the current version to use it without specifying the format explicitly.

If you have errors while doing it, you can share them with us, in order to help you further.

@DiegoDePalacio_1 Sorry for necroing this thread, but I hardly found any place talking about this.

https://pasteio.com/xO1H12KOh70g

My wish is to download already compressed images and display them. Depending on platform it should be either DXT5 or ASTC. I tried using UnityWebRequestTexture.GetTexture and letting unity decide behind the hood, but with this apporach I found that ASTC format seems to work, it downloads image and recognises it correctly. How ever when it comes to DXT5 it sees texture as null (in code example in link).

So I tried more manual approaches with ready texture.LoadRawTextureData(data); and using simple get webrequest, but then best I could was loading image.dds that was compressed with dxt1 and even then the image were not correct (if image would be 123456789 then what was displayed was 234567891, so part of it cut and placed at the end pf the image). Regardless DXT5 did not work regadless of the approach.

Is there any specific converter needed for DXT5, or any library should work?