Sunday, August 21, 2022
HomeGame Developmenttextures - Blank 2.2 KB sized PNG prices 2.1 MB in Unity?...

textures – Blank 2.2 KB sized PNG prices 2.1 MB in Unity? What does this symbolize? What to do?

PNG compression works by predicting the subsequent pixel from the pixels that got here earlier than.

If the picture is totally clean, ie. each pixel is precisely the identical because the pixel that got here earlier than, then that prediction is very straightforward, so you may get tiny file sizes even for high-resolution photographs. That makes it a deceptive benchmark to make use of right here.

The hassle is, GPUs can not learn PNGs. They want to have the ability to search to totally different spots within the texture at random, however to try this with a PNG, you’d have to learn and do calculations on the information for all pixels earlier than the one you are attempting to learn earlier than you could possibly decide its color.

So PNG textures must be decompressed to make use of for rendering. One means to try this is to unpack them to literal RGBA8: 8 bits per color channel, 32 bits per pixel (bpp).

Working that out on your picture, that is 1490 x 376 pixels x 32 bpp = 17 928 680 bits = 2 240 960 bytes = 2.137 MiB.

This appears to point that since you’ve set the feel sort to “Editor GUI and Legacy GUI”, Unity is assuming you want lossless dealing with of this picture, so choosing “Automatic” below the import format choices is defaulting to RGBA8.

That 2.137 MiB is the quantity of video RAM it is going to take to make use of this texture in your scene. If it’s essential edit the feel from a C# script, then you definately’ll additionally want a corresponding 2.137 MiB of important RAM for the CPU-side copy of the feel.

There are additionally GPU compression codecs that work in a different way – usually utilizing a set variety of bits per pixel (bpp). This is necessary for realtime rendering – the fastened bitwidth of every block of pixels means you’ll be able to calculate precisely what reminiscence offset to hunt to whenever you need to pattern a selected a part of the feel, relatively than needing to scan and decompress all of the pixels resulting in that one as PNG does. This means we will work with them straight from their compressed format, relatively than decompressing them to full 32 bpp RGBA knowledge.

For occasion, if we retailer this texture in DXT-5, it is going to break the picture into 4×4 blocks, rounding your picture measurement as much as 1492×376, then compress every block to eight bits per pixel. That’s about 547.84 kiB, or a few quarter of the dimensions as uncompressed. You can play with the choices within the format and compression drop-downs to seek out the fitting trade-off between reminiscence measurement and visible high quality on your wants.

Increasing the rendered measurement of this texture by displaying it on a scaled-up sprite doesn’t enhance the quantity of RAM it takes to retailer. So decreasing decision is a good way to save lots of on texture reminiscence – SDF textures make nice use of this, by serving to you get crisp strains even on scaled-up textures, whenever you desire a flat-colour/gradient vector artwork look.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments