Question

I've made a small png (100x30) and added it as a texture in Unity. I've also added it to a script so I can poll it, but if I print out its width and height it now states its 128x32. What happened?

I've tried to adjust the camera, but it does not seems to have anything to do with it. Any clue?

Was it helpful?

Solution

Generally textures are scaled to a power of 2 on both sides for performance reasons.

For example multiplication and division are faster if the GPU can assume that you are working with POT textures. Even mipmaps generation process relies on that because division by 2 never produces a remainder.

Old GPU (I don't know exactly but probably even several mobile GPU these days) requires strictly POT textures.

Unity by default will try to scale the texture to a power of 2. You can disable or tweak that setting switching texture import settings to "Advanced".

For more details checkout the doc.

Note that generally you want NPOT textures only for GUI, where you need to control exactly the resolution on screen and mipmap aren't used. For everything in the 3D scene power of 2 performs better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top