How to use texture as a color accumulator?

I’m trying to accumulate the color values in the texture something like a depth buffer.

However if I try to accumulate 4 white(255, 255, 255) pixel values which belong to same pixel position, it could not over (255, 255, 255).

What I want is to make a texture by making the value of 4 pixels stacked up to (1020, 1020, 1020).

Any good idea?

There are texture formats with more than 8 bits per component. For unsigned normalised formats, the value is still clamped to [0,1] regardless of the number of bits, so you need to choose an appropriate divisor. Floating-point formats aren’t clamped. If you’re using blending to perform the accumulation, you can’t use blending with an integer format, but you could use imageAtomicAdd instead.

The available options will depend upon OpenGL version (e.g. image load/store requires OpenGL 4.2 or the ARB_shader_image_load_store extension).

Thanks for your reply GClements.

Do you have any simple example code?

No.

(“Post must be at least 30 characters”, so this).