#Download ASTC files and show them as sprites

1 messages · Page 1 of 1 (latest)

main geyser
#

Can you not download astc format textures?

main geyser
#

Download ASTC files and show them as sprites

main geyser
#

Why downloaded ASTC image is shown only if Compress() is called, and even then the image is not only rotated, but slided to a side and corner is pink?


 Texture2D texture= new Texture2D(width, height, TextureFormat.ASTC_4x4, false);
            byte[] data = request.downloadHandler.data;
            texture.LoadRawTextureData(data);
            //texture.LoadImage(data);
            texture.Compress(true);
            //texture.LoadImage(data);
            // texture.LoadRawTextureData(data);
            texture.Apply();
#

Width and Height is correct as I know resolution of image before downloading it.

pine flicker
main crater
main geyser
main geyser
#

so what you telling me, for mobile you need to use ASTC format compression, but file it self cannot be .astc ?

pine flicker
#

how is it rotated? -90, 90, 180?

main crater
#

At least That's why assume.

main geyser
pine flicker
#

I presume you did try some of the other ASTC TextureFormats

main crater
#

Is there any specific reason you can't load a PNG or JPG?

main geyser
main geyser
main crater
main geyser
# main crater The memory used by a texture is defined by it's format. You can discard the load...

I am discarding png. Only thing I have in memory is Sprite.
This is example on Windows. I download PNG, compress it to DXT5, create Sprite out of it. Delete PNG and have only sprite in memory.
But if you dont compress PNG it will be not DXT5 but RGBA, which takes 4 times more memory. On pc that doesn't matter what so ever, but mobile webgl is as weak as it can be. and compressing takes quite some time.

#

by the way, I am super thankfull for you to looking at this

pine flicker
#

So the image you have shown above is a Sprite, correct?

main crater
main geyser
main crater
#

And it would probably not be any faster than compressing a PNG at runtime.

pine flicker
#

Just to cover all the bases try assigning the texture to a material and the material to a plane then screenshot that

main geyser
pine flicker
#

OK, just ruling out that Sprite.Create is doing something silly

main crater
main geyser
#

interesting enought editor preview shows image kinda correct. Same with dds and astc:

main geyser
#

so 16-byte header would explain the incorrect display.

main crater
main geyser
main crater
main geyser
#

Hello again, I would like to get some guidance once again. This time with DXT. I successfully loaded resolution and compression, removed header. But loading raw data I get some weird data: \

#

this how this should look like.

#

I mean I personally like new look, but Not sure what exactly I should do. I tried some things, like flipping data array and stuff, but it doesnt seem to work nicely. Any keywords what I should look for would be great!

main crater
#

This would probably require an in-depth understanding of the DXT compression algorithm.

main geyser
#

Could it be that something is shifted? as seems that RGBA data is incorrect bet location of pixel is correct? or that is out of question?

main crater
#

I don't know enough about compression to say anything productive. Might want to google on how the algorithm works and how it is implemented in unity.