Alpha blending



  • Hello,

    I am trying to pass color values as attributes to fragment shader in order to implement a custom geometry gradient with alpha blending using QSGSimpleMaterial and QSGSimpleMaterialShader. The problem is that where there is low opacity the resulting color goes to white. I suspect this is because the alpha blending is not happening correctly but the color at a fragment is getting added to the destination color and gets saturated to white. How can I prevent this? Is there a way to access the destination color or the background color (not gl_Fragcolor) in the fragment shader somehow to be able to change the alpha blending? My code looks like this...

    vertice shader:

    attribute highp vec4 pos;
    attribute highp vec4 color;

    uniform highp mat4 qt_Matrix;
    varying highp vec4 vC;

    void main(void)
    {
    gl_Position = qt_Matrix * pos;
    vC = color;
    }

    fragment shader:

    uniform lowp float qt_Opacity;

    varying highp vec4 vC;

    void main(void)
    {
    gl_FragColor = vC * qt_Opacity;
    }

    Any help appreciated, thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.