diff --git a/src/MediaFX/qml/effects/LumaMixer.qml b/src/MediaFX/qml/effects/LumaMixer.qml index 7edce94..4d4b044 100644 --- a/src/MediaFX/qml/effects/LumaMixer.qml +++ b/src/MediaFX/qml/effects/LumaMixer.qml @@ -20,6 +20,8 @@ MediaMixer { id: root default required property Item luma + property real transitionWidth: root.width + readonly property real timeMulTransitionWidthPlusOne: root.time * transitionWidth + 1.0 fragmentShader: "qrc:/shaders/qml/effects/luma.frag.qsb" state: "default" diff --git a/src/MediaFX/qml/effects/luma.frag b/src/MediaFX/qml/effects/luma.frag index f41e15f..8b78a88 100644 --- a/src/MediaFX/qml/effects/luma.frag +++ b/src/MediaFX/qml/effects/luma.frag @@ -19,6 +19,8 @@ layout(std140, binding = 0) uniform buf { mat4 qt_Matrix; float qt_Opacity; float time; + float transitionWidth; + float timeMulTransitionWidthPlusOne; }; layout(binding = 1) uniform sampler2D source; layout(binding = 2) uniform sampler2D dest; @@ -27,10 +29,19 @@ void main() { vec4 sp = texture(source, qt_TexCoord0); vec4 dp = texture(dest, qt_TexCoord0); vec4 lp = texture(luma, qt_TexCoord0); - vec4 m = clamp((lp * time), vec4(0.0), vec4(1.0)); + + + vec4 m = clamp((lp * vec4(transitionWidth) - vec4(transitionWidth)) + vec4(timeMulTransitionWidthPlusOne), vec4(0.0), vec4(1.0)); + fragColor = mix(sp, dp, m) * qt_Opacity; + + +/* + float m = clamp((lp.r * transitionWidth - transitionWidth) + (timeMulTransitionWidthPlusOne), 0.0, 1.0); fragColor = mix(sp, dp, m) * qt_Opacity; - fragColor = vec4(lp.rgb, 1.0); - fragColor = vec4(mix(sp.rgb, dp.rgb, m.rgb), 1.0) * qt_Opacity; +*/ + + //fragColor = vec4(lp.rgb, 1.0); + //fragColor = vec4(mix(sp.rgb, dp.rgb, m.rgb), 1.0) * qt_Opacity; //fragColor = vec4(1.0, 0.0, 0.0, 1.0); /*XXX diff --git a/tests/qml/MediaMixerHarness.qml b/tests/qml/MediaMixerHarness.qml deleted file mode 100644 index 5a42047..0000000 --- a/tests/qml/MediaMixerHarness.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick -import QtQuick.Shapes -import QtQuick.Layouts -import QtQuick.Controls - -// Invoke using qml tool as "qml MediaMixerHarness.qml -- [] -// qsb is specified relative to MediaMixerHarness.qml - -Item { - height: 400 - width: 400 - - ColumnLayout { - anchors.fill: parent - - MediaMixer { - Layout.fillHeight: true - Layout.fillWidth: true - dest: destItem - fragmentShader: Qt.application.arguments.length >= 4 ? Qt.resolvedUrl(Qt.application.arguments[3]) : "" - source: sourceItem - time: time.value - vertexShader: Qt.application.arguments.length >= 5 ? Qt.resolvedUrl(Qt.application.arguments[4]) : "" - } - Slider { - id: time - - Layout.fillWidth: true - from: 0 - to: 1 - value: 0.5 - } - } - Rectangle { - id: sourceItem - - anchors.fill: parent - color: "lightblue" - layer.enabled: true - visible: false - - Shape { - anchors.fill: parent - - ShapePath { - fillColor: "orange" - fillRule: ShapePath.WindingFill - scale: Qt.size(sourceItem.width / 160, sourceItem.height / 160) - strokeColor: "darkgray" - strokeWidth: 3 - - PathPolyline { - path: [Qt.point(80, 0), Qt.point(130, 160), Qt.point(0, 55), Qt.point(160, 55), Qt.point(30, 160), Qt.point(80, 0),] - } - } - } - } - Rectangle { - id: destItem - - anchors.fill: parent - color: "yellow" - layer.enabled: true - visible: false - - Shape { - id: qt - - anchors.fill: parent - - ShapePath { - fillColor: "green" - scale: Qt.size(destItem.width / 200, destItem.height / 200) - strokeColor: "darkGray" - strokeWidth: 3 - - PathAngleArc { - centerX: 100 - centerY: 100 - radiusX: 100 - radiusY: 100 - sweepAngle: 360 - } - } - } - } -} diff --git a/tools/viewer/main.cpp b/tools/viewer/main.cpp index 16c76ae..c4115dd 100644 --- a/tools/viewer/main.cpp +++ b/tools/viewer/main.cpp @@ -47,6 +47,7 @@ int main(int argc, char* argv[]) QUrl url(args.at(0)); QQuickView quickView(url); + quickView.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); // qCritical() << quickView.errors(); quickView.show(); diff --git a/tools/viewer/qml/MediaMixerHarness.qml b/tools/viewer/qml/MediaMixerHarness.qml index 5971ca4..a590d0c 100644 --- a/tools/viewer/qml/MediaMixerHarness.qml +++ b/tools/viewer/qml/MediaMixerHarness.qml @@ -7,7 +7,7 @@ import MediaFX Item { id: root - default property alias mixer: mixerContainer.children + default property alias mixer: mixerContainer.data height: 400 state: "default"