纹理缓冲区对象或常规纹理? [英] Texture buffer objects or regular textures?

查看:201
本文介绍了纹理缓冲区对象或常规纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenGL SuperBible讨论纹理缓冲区对象,它们是由VBO内部的数据构成的纹理。看起来使用它们有好处,但我发现的所有示例都创建了常规纹理。有没有人有任何建议关于什么时候使用其中一个? 根据扩展注册表,纹理缓冲区只有一维,不能进行任何过滤,必须通过访问显式texels(按索引),而不是归一化的[0,1]浮点纹理坐标。所以它们并不是真正的纹理替代品,而是大型的统一阵列(例如蒙皮矩阵或每个实例数据)。将它们与统一缓冲区进行比较比将它们与常规纹理进行比较更有意义,就像完成在这里



编辑:如果您想为常规的过滤2D纹理使用VBO数据,你不会绕过数据副本(最好通过PBO完成)。但是,如果你只是想要平淡的数组访问VBO数据和属性不足够,那么纹理缓冲区应该是选择的方法。



编辑:在检查SuperBible中的相应章节之后,我发现他们一方面提到纹理缓冲区总是一维的并且可以通过离散的整数纹理元素偏移进行访问,但是另一方面却没有明确提到缺乏过滤。在我看来,他们或多或少地将它们作为纹理进行宣传,只是从缓冲区获取数据,这解释了OP的问题。但如上所述,这只是错误的比较。纹理缓冲区只是提供了一种直接访问着色器中的缓冲区数据的方式(虽然有一个可调节的元素类型),但不是更多(使它们对普通纹理无用),但也不会少(它们仍然是一个很棒的功能)。


The OpenGL SuperBible discusses texture buffer objects, which are textures formed from data inside VBOs. It looks like there are benefits to using them, but all the examples I've found create regular textures. Does anyone have any advice regarding when to use one over the other?

解决方案

According to the extension registry, texture buffers are only 1-dimensional, cannot do any filtering and have to be accessed by accessing explicit texels (by index), instead of normalized [0,1] floating point texture coordinates. So they are not really a substitution for regular textures, but for large uniform arrays (for example skinning matrices or per instance data). It would make much more sense to compare them to uniform buffers than to regular textures, like done here.

EDIT: If you want to use VBO data for regular, filtered, 2D textures, you won't get around a data copy (best done by means of PBOs). But when you just want plain array access to VBO data and attributes won't suffice for this, then a texture buffer should be the method of choice.

EDIT: After checking the corresponding chapter in the SuperBible, I found that they on the one hand mention, that texture buffers are always 1-dimensional and accessed by discrete integer texel offsets, but on the other hand fail to mention explicitly the lack of filtering. It seems to me they more or less advertise them as textures just sourcing their data from buffers, which explains the OP's question. But as mentioned above this is just the wrong comparison. Texture buffers just provide a way for directly accessing buffer data in shaders in the form of a plain array (though with an adjustable element type), not more (making them useless for regular texturing) but also not less (they are still a great feature).

这篇关于纹理缓冲区对象或常规纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆