Alpha blending viewport texture - colour problem

Godot Version

4.2

Question

I’m having trouble blending a viewport texture over another image using its alpha. The colour at alpha 1 looks right and at alpha 0, but where it is blending the alpha its brightness is off. here’s the setup:

I have a mesh (a curved mesh strip) with 50% grey colour and an alpha transparency texture. so far so good

next I render it with a subviewport and camera3d, and send the viewport texture to a colorrect shader in another viewport. The goal in this test case is to overlay it over the exact same colour. if all works well it should look like just a grey square

above is the canvasitem render result applied to a quad. as you can see the areas where alpha is 1 look the same, as do alpha 0, but the transition areas are dark :frowning:

is something wrong with my blending formula? if I try a version of the formula where I don’t multiply the colour by alpha, this time it looks too bright

any advice appreciated

here’s what the mesh looks like that I render in the first viewport