Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to Flip Left/Right an qml Item in shader?
QtWS25 Last Chance

How to Flip Left/Right an qml Item in shader?

Scheduled Pinned Locked Moved Unsolved General and Desktop
quickshaderfliphorizontal
1 Posts 1 Posters 893 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.
  • D Offline
    D Offline
    dhuta
    wrote on 18 Mar 2016, 06:23 last edited by dhuta
    #1

    As asked above, the problem is that my fixed version shader (from Qt5.4.2 example called tweetsearch, which is up/down flip) does not work well for the second source item.

    my version just change some shader code:

    fragmentShader: "
            uniform lowp float qt_Opacity;
            uniform sampler2D sourceA;
            uniform sampler2D sourceB;
            uniform highp float delta;
            varying highp vec2 qt_TexCoord0;
            void main() {
    //                highp vec4 tex = vec4(qt_TexCoord0.x, qt_TexCoord0.y * 2.0,      qt_TexCoord0.x, (qt_TexCoord0.y-0.5) * 2.0);
    
                // TODO: How?
                highp vec4 tex = vec4(qt_TexCoord0.x * 8.0, qt_TexCoord0.y, (qt_TexCoord0.x + 1.0), (qt_TexCoord0.y-0.5) * 2.0);
    
                highp float shade = clamp(delta*2.0, 0.5, 1.0);
                highp vec4 col;
                if (qt_TexCoord0.x < 0.5) {
                    col = texture2D(sourceA, tex.xy) * (shade);
                } else {
                    col = texture2D(sourceB, tex.wz) * (1.5 - shade);
                    col.w = 0.50;
                }
                gl_FragColor = col * qt_Opacity;
            }
        "
        property real h: width
        vertexShader: "
        uniform highp float delta;
        uniform highp float factor;
        uniform highp float h;
        uniform highp mat4 qt_Matrix;
        attribute highp vec4 qt_Vertex;
        attribute highp vec2 qt_MultiTexCoord0;
        varying highp vec2 qt_TexCoord0;
        void main() {
            highp vec4 pos = qt_Vertex;
            if (qt_MultiTexCoord0.x == 0.0)
                pos.y += factor * (1. - delta) * (qt_MultiTexCoord0.y * -2.0 + 1.0);
            else if (qt_MultiTexCoord0.x == 1.0)
                pos.y += factor * (delta) * (qt_MultiTexCoord0.y * -2.0 + 1.0);
            else
                pos.x = delta * h;
            gl_Position = qt_Matrix * pos;
            qt_TexCoord0 = qt_MultiTexCoord0;
        }"
    

    Could anyone help me out? Thanks.

    1 Reply Last reply
    0

    1/1

    18 Mar 2016, 06:23

    • Login

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