Texture buffer objects or regular textures?
Asked Answered
E

3

8

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?

Endocardial answered 8/6, 2011 at 15:13 Comment(1)
To sum up what Christian said : TBOs are for advanced uses. For what you usually call a "texture" (i.e. an image), use glGenTextures & co.Hogweed
F
8

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).

Fennie answered 8/6, 2011 at 15:29 Comment(6)
This is completely wrong. That exension supports 1d,2d and 3d texturesKef
@VJo No, your comment is wrong. Read the linked extension specification for more insight. Perhaps you are messing up texture buffers with PBOs.Fennie
@VJo : Buffer textures are one-dimensional arrays of texels and also Buffer textures do not support mipmapping, texture lookups with normalized floating-point texture coordinates, and texture filtering of any sort. And btw, it's part of OpenGL 3.1+ : opengl.org/sdk/docs/man3/xhtml/glTexBuffer.xmlHogweed
The first link confused me, as it said something about 1d,2d and 3d textures. Your second edit answered the question. Calvin's link explained better what texture buffer isKef
@VJo The first link (extension spec) uses exactly the words Calvin used in his comment. Reading the overwiew of an extension spec often gives more insight than the specification additions, as they are often quite scattered and taken out of context.Fennie
Is there any performance comparisons made? Aren't both on Graphics Ram?Hammons
R
1

Buffer textures are unique type of texture that allow a buffer object to be accessed from a shader like a texture. They are completely unique from normal OpenGL textures, including Texture1D, Texture2D, and Texture3D. There are two main reasons why you would use a Buffer Texture instead of a normal texture:

  • Since Texture Buffers are read like textures, you can read their contents from every vertex freely using texelFetch. This is something that you cannot do with vertex attributes, as those are only accessable on a per-vertex basis.
  • Buffer Textures can be useful as an alternative to uniforms when you need to pass in large arrays of data. Uniforms are limited in the size, while Buffer Textures can be massive in size.
  • Buffer Textures are supported in older versions of OpenGL than Shader Storage Buffer Objects (SSBO), making them good for use as a fallback if SSBOs are not supported on a GPU.

Meanwhile, regular textures in OpenGL work differently and are designed for actual texturing. These have the following features not shared by Texture Buffers:

  • Regular textures can have filters applied to them, so that when you sample pixels from them in your shaders, your GPU will automatically interpolate colors based on nearby pixels. This prevents pixelation when textures are upscaled heavily, though they will get progressively more blurry.
  • Regular textures can use mipmaps, which are lower quality versions of the same texture used at further view distances. OpenGL has built in functionality to generate mipmaps, or you can supply your own. Mipmaps can be helpful for performance in large 3d scenes. Mipmaps also can help prevent flickering in textures that are rendered further away.

In summary of these points, you could say that normal textures are good for actual texturing, while Buffer Textures are good as a method for passing in raw arrays of values.

Ropeway answered 29/6, 2020 at 22:6 Comment(0)
A
0

Regular textures are used when VBOs are not supported.

Agosto answered 8/6, 2011 at 19:34 Comment(3)
This is wrong as texture buffers don't provide the usual features of regular textures.Fennie
Can't say that the answer is wrong, as regular textures can always be used to emulate the behavior of TexBO when the feature (extension) is not supported by the hardware.Environmentalist
@Environmentalist Ok, if viewed from that point, you're probably right.Fennie

© 2022 - 2024 — McMap. All rights reserved.