Hi,
I found some interesting code online about recursive shaders. It was not to difficult to build a mobile app with it but my app is not getting approved. The issue is that it is not going to sleep when the phone is.
To send it to sleep I tried to build in an active property and binding the shader to it but that does not help.
ShaderEffect {
id: inputItem
property variant source: ShaderEffectSource { sourceItem: sourceArea; smooth: false }
property variant recursiveSource: recursiveSource
property real ledWidthPercent: ledScreen.ledWidth/ledScreen.width
anchors.fill: sourceArea
visible: false
enabled: root.active
fragmentShader: "
varying mediump vec2 qt_TexCoord0;
uniform highp float qt_Opacity;
uniform highp float ledWidthPercent;
uniform lowp sampler2D source;
uniform lowp sampler2D recursiveSource;
void main() {
highp vec4 pix;
if (qt_TexCoord0.x > (1.0 - ledWidthPercent)) {
pix = texture2D(source, qt_TexCoord0);
} else {
highp vec2 pos = vec2(qt_TexCoord0.x+ledWidthPercent, qt_TexCoord0.y);
pix = texture2D(recursiveSource, pos) * (1.0-ledWidthPercent*2.0);
}
gl_FragColor = pix * qt_Opacity;
}
"
}
ShaderEffectSource {
id: recursiveSource
sourceItem: inputItem
hideSource: true
visible: false
live: root.updateFrequency == 1//false
recursive: true
smooth: false
enabled: root.active
}
ShaderEffect {
id: inputItem
property variant source: ShaderEffectSource { sourceItem: sourceArea; smooth: false }
property variant recursiveSource: recursiveSource
property real ledWidthPercent: ledScreen.ledWidth/ledScreen.width
anchors.fill: sourceArea
visible: false
enabled: root.active
fragmentShader: "
varying mediump vec2 qt_TexCoord0;
uniform highp float qt_Opacity;
uniform highp float ledWidthPercent;
uniform lowp sampler2D source;
uniform lowp sampler2D recursiveSource;
void main() {
highp vec4 pix;
if (qt_TexCoord0.x > (1.0 - ledWidthPercent)) {
pix = texture2D(source, qt_TexCoord0);
} else {
highp vec2 pos = vec2(qt_TexCoord0.x+ledWidthPercent, qt_TexCoord0.y);
pix = texture2D(recursiveSource, pos) * (1.0-ledWidthPercent*2.0);
}
gl_FragColor = pix * qt_Opacity;
}
"
}
ShaderEffectSource {
id: recursiveSource
sourceItem: inputItem
hideSource: true
visible: false
live: root.updateFrequency == 1//false
recursive: true
smooth: false
enabled: root.active
}
To copy to clipboard, switch view to plain text mode
Can someone help me to understand how this code works and how I can pause it?
Thanks
Bookmarks