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. How to write customQML Text shader using distance field?
Forum Updated to NodeBB v4.3 + New Features

How to write customQML Text shader using distance field?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 205 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.
  • E Offline
    E Offline
    Espoo
    wrote on last edited by
    #1

    As I know, Qml Text use distance field technique to render text. I wish i had direct acess to that distance field texture to achieve custom Text effect ,(I know that i can use layer mechanism and render Text to texture and then apply some effect but that's not what I want to achieve). How to do that?

            Text{
                id:test_text
                x:parent.width
                text: "Hello World!!"
                font.family: "Helvetica"
                font.bold: true
                font.pixelSize :parent.height*0.65
                color: "black"
                anchors.verticalCenter: parent.verticalCenter
    
    
                ShaderEffect {
                    property variant source: ShaderEffectSource { sourceItem: test_text; hideSource: false }
                    anchors.fill: parent
    
                    fragmentShader: "
    
                        uniform sampler2D source;
                        varying highp vec2 qt_TexCoord0;
    
                        void main(void)
                        {
                            if(texture2D(source, qt_TexCoord0).a < 0.5)
                                gl_FragColor = vec4(1.0,1.0,0.0,0.000);
                        }
                    "
                }
            }
    
    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