Problems with storing data in alpha-channel

I have a font atlas texture made with MSDF gen; i’m trying to view it, when i try to view the alpha channel in isolation with

void main() 
    frag_out = vec4(vec3(texture(u_atlas, texCoord).a), 1);

The result is solid white; but the content of the alpha channel is not solid white, i know this because when i output a*r the result is different than just outputting r.

Similarly when writing data to the alpha channel, i find that the data i read from it is not the data i put in. My shader in that case is basically

void main() { frag_out = ivec4(d, 255-d, d, 255-d); }

Rendered with GL_MAX blending in 4 cycles: twice with only RG enabled; and twice with BA enabled. But when i read from the alpha channel its always 255.

The second example i know is not a driver bug, because i’ve tested it on windows and linux. The first example i’m less sure of because i’ve only tested it on ubuntu with default drivers; but on both rx480 and a geforce 710 i had lying around…

Regardless i want to know what i can do about this.

Show more code.

Why are you using ivec4 with 0…255 values instead of vec4 with 0…1 values to write frag_out in your 2nd example?

Try this: Allocate+bind an FBO render target with normalized color values with an alpha channel (e.g. GL_RGBA8), enable RGBA in color mask, set a clear color with 0 alpha, clear the render target, disable alpha test, blending, and all other tests (depth,stencil,etc.) write a single layer, read back a pixel using a format/type with alpha. If problems, ditch the single layer and just read back the color after clearing the render target. Change the clear color and verify that you get back the clear color each time. Iterate with this and you’ll figure out where your oversight is.

Just recreated the font atlas problem on windows. Using GL 3.3 i dunno if thats relevant?

Well i had it as an RGB8UI texture in the past; so i thought it was still using 255, but looking at it again i’m using an RGB16UI texture and this:

vec4 flags = vec4(v_id, 65535 - v_id, v_id, 65535 - v_id) / float(65535);

Font atlas example:

Data shader example:

When i read from the data shader i’m getting correct values in the RGB fields; its only the alpha field that is messed up.

I already have every test disabled; and i’m rendering from an RGBA texture filled with calloc-ed data. So it should be much the same as your suggestion.

When i changed the data render to be your suggestion i realized that i remembered the issue wrong; so when i display that i do get black; when i renabled rendering i still get black. The issue in that one is that alpha is always read as 0 no matter what i write to it.