Is texture size required to be power of two for the best performance / quality?

I have been looking through BabylonJS docs and HTMLGameDev forum trying to figure if I should create materials using power of two textures from the quality vs performance point of view? Could someone please clarify this or at least point me to the right direction please?

Here are already very good answers - Why are textures always square powers of two? What if they aren't? - Game Development Stack Exchange

From my personal experience I’ve never had any problems with non-power-of-two textures.

I think I found partial answer to above question. Sharing in case anyone stumbles upon this question thread.

From page: WebGL and OpenGl we can read

While OpenGL 2.0 and later for the desktop offer full support for non-power-of-two (NPOT) textures, OpenGL ES 2.0 and WebGL have only limited NPOT support.

However, actual WebGL 2.0 spec webgl 2.0/#4.1.3 states it is no longer the case.

Texture access works in the WebGL 2.0 API as in the OpenGL ES 3.0 API. In other words, unlike the WebGL 1.0 API, there are no special restrictions on non power of 2 textures. All mipmapping and all wrapping modes are supported for non-power-of-two images.


I am still not sure if and/or how NPOT texture affect the performance though.

Thanks @labris. From the forum you linked I read it might affect performance. Is that the case for BabylonJS? I am targeting only WebGL 2.0.

From advanced topics from BabylonJS:

On WebGL1 context, all textures are resized to a power of two to produce the best quality. This resize may impact performance.
On WebGL2 context, no resize is required and any size texture will be rendered with the best quality.

Nothing about the performance. I guess best way would probably be testing it.

The gain/loss of performance of power of 2 / non power of 2 texture sizes is not on Babylon.js side but on GPU side, so is not covered in the doc as it depends on your GPU. I’m not sure there’s any difference in perf using POT/NPOT textures nowadays… You would indeed need to test to know for sure (but you would need to test on different GPUs).

i believe it’s mainly memory consumption,
e.g. a texture of 400 * 400 will be scaled to 512 * 512 on the GPU.
i don’t know for sure, but i’m assuming it’s done by adding borders(/bezels), so 112*112 unused but memory consuming pixels are added

Thanks guys.

@aWeirdo Might be newbie of me to ask but why would GPU scale up textures? I came across some papers and threads from like 10 years ago mentioning VRAM usage. I dare to assume technology improved since then. Any chance for links to some reading references? I am struggling to find anything more up to date.