Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebGL and rectangular (power of two) textures

WebGL is known to have poor support for NPOT (non-power-of-two) textures. But what about rectangular textures where both width and height are powers of two? Specifically, I'm trying to draw to a rectangular framebuffer as part of a render-to-texture scheme to generate some UI elements. The framebuffer would need to be 512x64 or thereabouts.

How much less efficient would this be in terms of drawing? If framerate is a concern, would I do better to allocate a 512x512 power-of-two-sized buffer and only render to the top 64 pixels, sacrificing memory for speed?

like image 790
Alterscape Avatar asked Sep 30 '11 16:09

Alterscape


2 Answers

There has never been the constraint for that width must equal height.

like image 137
datenwolf Avatar answered Sep 23 '22 14:09

datenwolf


More specifically: 2D textures are not at all required to be square; a 512x64 texture is not only allowed but should also be efficiently implemented by the driver; on the other hand cube maps need to be square.

For 2D textures, you can use NPOT textures if both wrap modes are CLAMP_TO_EDGE and your minification filter does not require a mipmap. Efficiency of NPOT texture may vary depending on your driver.

like image 38
Benoit Jacob Avatar answered Sep 23 '22 14:09

Benoit Jacob