#ASTC DXT5 image downloading via webrequests
1 messages · Page 1 of 1 (latest)
Can I confirm is it even possible to download texture in ASTC or DXT formats? or I need to download it as raw data or something?
So UnityWebRequestTexture supports only png/jpg. So UnityWebRequest needs to be used and that bit[] from resposne needs to be converted into texture.
But I am still confused how to do it correctly. As ASTC kinda works, but DXT does not give me texture normaly.
using (UnityWebRequest request = UnityWebRequest.Get(url)) {
request.SetRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate");
request.SetRequestHeader("Pragma", "no-cache");
request.SendWebRequest();
// Creating task interuption logic. It will be interupted either globaly or locally.
while (!request.isDone || interruptToken.IsCancellationRequested) {
if (interruptToken.IsCancellationRequested) {
Debug.Log("Task {0} cancelled");
request.Abort();
interruptToken.ThrowIfCancellationRequested();
}
await UniTask.Yield();
}
if (WebRequestError(request)) {
Debug.LogWarning($"Error while downloading resource < {url} >, error: {request.error}");
return null;
}
byte[] data = request.downloadHandler.data;
Debug.Log($"Downlaoded from< {url} >");
Debug.Log(data.Length);
Texture2D texture = new Texture2D(512, 256);
texture.LoadImage(data);
texture.Apply();
}
This way return ASTC image which is very blurry, and dxt is just fails to create any time of image. Any guidelines that could help with this?
ASTC seems to be accesible mor easily, but DXT5 fails hard. Best was able to do is load DDS file, but even knowning its resolution image was cut in incorrect place. It is really confusing.