WebGL 和矩形(2 的幂)纹理
众所周知,WebGL 对 NPOT(非二次幂)纹理的支持较差。但是宽度和高度都是 2 的幂的矩形纹理又如何呢?具体来说,我尝试绘制矩形帧缓冲区作为渲染到纹理方案的一部分来生成一些 UI 元素。帧缓冲区需要为 512x64 或左右。
这在绘图方面会降低多少效率?如果帧速率是一个问题,我是否会更好地分配一个 512x512 的两倍大小的缓冲区并仅渲染到前 64 个像素,从而牺牲内存以提高速度?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从来没有宽度必须等于高度的限制。
There has never been the constraint for that width must equal height.
更具体地说:2D 纹理根本不需要是正方形的; 512x64 纹理不仅是允许的,而且还应该由驱动程序有效地实现;另一方面,立方体贴图需要是正方形的。
对于 2D 纹理,如果两种环绕模式均为 CLAMP_TO_EDGE 并且您的缩小过滤器不需要 mipmap,则可以使用 NPOT 纹理。 NPOT 纹理的效率可能会因您的驱动程序而异。
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.