How to Flip Left/Right an qml Item in shader?
Unsolved
General and Desktop
-
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.