早上好,这是2个纹理非幂的典型例子.
由于多种原因,纹理在分辨率上需要2的幂,这是一个非常常见的错误,每个人都碰巧陷入这个陷阱:)我也是.
2个纹理的非功率在某些设备/ GPU上运行平稳的事实,仅仅取决于OpenGL驱动程序实现,一些GPU清楚地支持它们,其他一些不支持,我强烈建议你选择pow2纹理以便能够保证所有设备的功能.
最后但并非最不重要的是,使用2个纹理的非强大功能可能会让你在GPU内存利用率方面陷入困境,因为大多数接受非powerof2纹理的驱动程序需要在内存中将纹理重新缩放到最接近2因子的更高功率.例如,具有520X520的纹理可能导致1024X1024的实际存储器映射.
这是你不想要的东西,因为在现实世界中“大小很重要”,特别是在移动设备上.
你可以在OpenGL Gold Book中找到一个很好的解释,OpenGL ES 2.0:
In OpenGL ES 2.0, textures can have non-power-of-two (npot)
dimensions. In other words, the width and height do not need to be a
power of two. However, OpenGL ES 2.0 does have a restriction on the
wrap modes that can be used if the texture dimensions are not power of
two. That is, for npot textures, the wrap mode can only be
GL_CLAMP_TO_EDGE and the minifica- tion filter can only be GL_NEAREST
or GL_LINEAR (in other words, not mip- mapped). The extension
GL_OES_texture_npot relaxes these restrictions and allows wrap modes
of GL_REPEAT and GL_MIRRORED_REPEAT and also allows npot textures to
be mipmapped with the full set of minification filters.
我建议你评估这本书,因为它对这个主题做了相当不错的报道.