Questions tagged [image-unit]

Image units are binding points for OpenGL textures, separate from texture image units, that allow arbitrary read/write and atomic access, not available with textures.

The idea with image load/store is that the user can bind one of the images in a Texture to a number of image binding points (which are separate from texture image units). Shaders can read information from these images and write information to them, in ways that they cannot with textures.

This can allow for a number of powerful features, including relatively cheap order-independent transparency.

If you think that this is a great feature, remember that there is no such thing as a free lunch. The cost of using image load/store is that all of its write operations are not automatically coherent. By using image load/store, you take on the responsibility to manage what OpenGL would normally manage for you using regular texture reads/FBO writes.

opengl.org wiki

This extension provides GLSL built-in functions allowing shaders to loadfrom, store to, and perform atomic read-modify-write operations to asingle level of a texture object from any shader stage.These built-infunctions are named imageLoad(), imageStore(), and imageAtomic*(),respectively, and accept integer texel coordinates to identify the texelaccessed.The extension adds the notion of "image units" to the OpenGLAPI, to which texture levels are bound for access by the GLSL built-infunctions.To allow shaders to specify the image unit to access, GLSLprovides a new set of data types ("image*") similar to samplers.Eachimage variable is assigned an integer value to identify an image unit toaccess, which is specified using Uniform*() APIs in a manner similar tosamplers.

ARB_shader_image_load_store

10 questions
5
votes
0 answers

Writing to a single colour channel with image_load_store

The image_load_store extension provides load/store functions with *vec4 access only. If I have layout(rgba32f) uniform image2D myimage; for example, it seems like I have to write to the entire pixel at once: imageStore(myimage, coord,…
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
3
votes
1 answer

Write to mutiple 3Dtextures in fragment shader OpenGL

I have a 3D texture where I write data and use it as voxels in the fragment shader in this way: #extension GL_ARB_shader_image_size : enable ... layout (binding = 0, rgba8) coherent uniform image3D volumeTexture; ... void main(){ vec4 fragmentColor…
tigeradol
  • 259
  • 2
  • 16
3
votes
1 answer

How do you get the size of an image unit (eg. image2D) in GLSL just like textureSize

textureSize is a handy function to get texture dimensions in a shader without having to pass them in by hand as uniforms. Is there a similar API for image units?
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
3
votes
0 answers

Accessing image2D from image2DArray

I am asking probably a simple question.I have a texture array (GL_TEXTURE_2D_ARRAY) of image2D textures.I access the array in a fragment shader via image2DArray.How do I get an access to the images of the array? imageLoad() has a param for layer…
Michael IV
  • 11,016
  • 12
  • 92
  • 223
2
votes
1 answer

OpenGL Image Load/Store 24-bit RGB images

It looks like glBindImageTexture does not have an image format for 24-bit RGB (3 8-bit channels) images. My texture has an internal format of the type GL_RGB8 (a 24-bit RGB image). Unfortunately I cannot easily change the type of my texture that I'm…
AnimatedRNG
  • 1,859
  • 3
  • 26
  • 39
2
votes
2 answers

Performance implications setting readonly/writeonly on image units in GLSL

In glBindImageTexture(), access can be GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE. I assume that these should match the readonly and writeonly qualifiers on image units (eg. image2D or imageBuffer) in GLSL. I haven't noticed any difference when…
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
1
vote
1 answer

OpenGL 4.2 use same texture as image and as sampler

Is it legal (and well defined) to use the same texture as an image2D as well as a sampler2D? currently I use imageLoad() and imageStore() within the GLSL shader to write and load from a image2D. However, I would like to read (not write) also from…
matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76
1
vote
1 answer

GLSL Atomic Image Access

My other post intends to collect general information on the kinds of GLSL spinlocks, but unfortunately nothing has come of it, nor has it solved my problem. Therefore, a specific question. I reduced my problem down to a minimal example, presented…
geometrian
  • 14,775
  • 10
  • 56
  • 132
0
votes
2 answers

GLSL 4.2 - how to retrieve size of image?

In GLSL 4.2 one can use the image2D datatype with imageLoad and imageStore functions. those functions take ivec to determine which pixel to write/read. in order to calculate the proper ivec, i need to know the size of the image. But how do I…
Mat
  • 4,281
  • 9
  • 44
  • 66
0
votes
2 answers

GLSL image2D antialiasing

Is it possible to set MSAA sampling for image2D? Can it be of multisampled type as texture2D in OpenGL? I am writing first pass not to a render buffer (or texture) but to image where I store several pixel copies of the same primitive but at…
Michael IV
  • 11,016
  • 12
  • 92
  • 223