Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Alpha blending
Forum Update on Monday, May 27th 2025

Alpha blending

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yanner
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved