Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qml blend modes

    QML and Qt Quick
    2
    3
    1484
    Loading More Posts
    • 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.
    • N
      NotAnUser last edited by

      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:
      http://i.ytimg.com/vi/o5ztBii2_wA/maxresdefault.jpg

      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?

      1 Reply Last reply Reply Quote 0
      • D
        dasRicardo last edited by

        Hmmm a way could be use a "ShaderEffectSource":http://qt-project.org/doc/qt-5/qml-qtquick-shadereffectsource.html to create a texture of the rectangle with your text and use this texture in a "ShaderEffect":http://qt-project.org/doc/qt-5/qml-qtquick-shadereffect.html. Use a fragmentshader to replace all pixel with the same color as the text and replace this pixel with transparent pixels.

        **Sorry for my english :)

        PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

        1 Reply Last reply Reply Quote 0
        • N
          NotAnUser last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post