Important: Please read the Qt Code of Conduct -

Qml blend modes

  • I'm trying to create an gui that has an animated "dark" background.
    I would like to draw rectangles (with text) in front of this background, but instead of writing text ON the rectangles, i would like to substract the text FROM the rectangle, so that i "punch" the letters in the rectangle, and if you look at the letters, you'll see hints of the backgrounds through it.

    See this overly photoshopped mockup from the internet to get what i mean:

    I tried using a OpacityMask to filter away the rectangle where the text would be, this doesnt work however, since i cant seem to get "the inverse" of the text, which would be needed for such an opacity mask.

    So in short, are there such things as blend modes in QML, where i can paint white text in "substraction" mode, leaving only transparency where i wrote the text?

  • Hmmm a way could be use a "ShaderEffectSource": to create a texture of the rectangle with your text and use this texture in a "ShaderEffect": Use a fragmentshader to replace all pixel with the same color as the text and replace this pixel with transparent pixels.

  • Im not really familiar with OpenGL, so i have no idea what kind of fragmentshader is required by this solution.

    Is it time for me to dig into more opgenGL / glsl, or is there some site that offers a lot of default shaders which i could use?

Log in to reply