From 91ac5771c40d756f08d070c17637aac51f96bb2f Mon Sep 17 00:00:00 2001 From: Digital Artifex <7929434+DigitalArtifex@users.noreply.github.com> Date: Fri, 8 Aug 2025 01:57:28 -0400 Subject: [PATCH] Added setting to invert channel buffer data --- package/contents/config/main.xml | 16 ++++++++++++++ package/contents/ui/KomplexModel.qml | 13 +----------- package/contents/ui/ShaderChannel.qml | 21 +++++++++++++++++++ .../ui/ShaderChannelConfiguration.qml | 10 +++++++++ package/contents/ui/ShaderToyModel.qml | 12 +++++++++++ package/contents/ui/config.qml | 6 +++++- 6 files changed, 65 insertions(+), 13 deletions(-) diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index 92fec2d..54923cc 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -61,6 +61,10 @@ true + + + true + 1.0 @@ -89,6 +93,10 @@ true + + + true + 1.0 @@ -117,6 +125,10 @@ true + + + true + 1.0 @@ -145,6 +157,10 @@ false + + + true + 1.0 diff --git a/package/contents/ui/KomplexModel.qml b/package/contents/ui/KomplexModel.qml index 37de619..81a92c5 100644 --- a/package/contents/ui/KomplexModel.qml +++ b/package/contents/ui/KomplexModel.qml @@ -119,18 +119,6 @@ Item } } - // Setup the connection to shader pack model for updates - Connections - { - target: shaderPackModel - - function onJsonChanged() - { - // Parse the JSON configuration and set the properties of the ShaderChannel - // mainItem.parsePack(shaderPackModel.json); - } - } - // Load the default shader pack configuration on component completion Component.onCompleted: { @@ -175,6 +163,7 @@ Item var result = Qt.createQmlObject(`ShaderChannel { z: 0 + invert: ${channel.invert || true} iTimeScale: ${channel.time_scale || 1.0} iResolutionScale: ${channel.resolution_scale || 1.0} visible: false diff --git a/package/contents/ui/ShaderChannel.qml b/package/contents/ui/ShaderChannel.qml index f991da2..c050072 100644 --- a/package/contents/ui/ShaderChannel.qml +++ b/package/contents/ui/ShaderChannel.qml @@ -69,6 +69,8 @@ Item property var iDate property real iTimeScale: 1 // This is used to scale the time for the shader, allowing for slow motion or fast forward effects per channel + property bool invert + property var iChannelResolution: [Qt.vector3d(channel.width * iResolutionScale, channel.height * iResolutionScale, 1), Qt.vector3d(channel.width * iResolutionScale, channel.height * iResolutionScale, 1), Qt.vector3d(channel.width * iResolutionScale, channel.height * iResolutionScale, 1)] QtObject @@ -78,6 +80,7 @@ Item property vector4d iMouse: Qt.vector4d(channel.iMouse.x * channel.mouseBias, channel.iMouse.y * channel.mouseBias, channel.iMouse.z, channel.iMouse.w) property real iTime: 0 property real lastITime: 0 + property real angle: channel.invert ? 180 : 0 } onITimeChanged: @@ -140,6 +143,23 @@ Item // } // } ] + + transform: Rotation + { + id: channelRotation + origin.x: channel.width / 2 + origin.y: channel.height / 2 + + // For vertical flipping, we need to transform the x axis + axis + { + x: 1 + y: 0 + z: 0 + } + + angle: data.angle + } } //The image channel will be the default channel type for backwards compatability @@ -149,6 +169,7 @@ Item Image { + id: image anchors.fill: parent source: Qt.resolvedUrl(channel.source) fillMode: channel.fillMode diff --git a/package/contents/ui/ShaderChannelConfiguration.qml b/package/contents/ui/ShaderChannelConfiguration.qml index 281c20d..1468c20 100644 --- a/package/contents/ui/ShaderChannelConfiguration.qml +++ b/package/contents/ui/ShaderChannelConfiguration.qml @@ -62,6 +62,7 @@ Item property alias tmp_resolution_scale: resolutionScaleSlider.value property alias tmp_resolution_x: resolutionXEdit.value property alias tmp_resolution_y: resolutionYEdit.value + property alias tmp_invert: channelInvertedCheckBox.checked property bool tmp_enabled: tmp_source !== "" property Palette palette @@ -72,6 +73,7 @@ Item property int resolution_x property int resolution_y property bool enabled + property bool invert id: window @@ -304,6 +306,12 @@ Item } } + CheckBox + { + id: channelInvertedCheckBox + text: i18n("Invert Channel Data") + } + RowLayout { Layout.alignment: Qt.AlignTop @@ -567,6 +575,7 @@ Item resolution_x = tmp_resolution_x resolution_y = tmp_resolution_y enabled = tmp_enabled + invert = tmp_invert // Emit the accepted signal and reset the selection window.accepted() @@ -616,6 +625,7 @@ Item tmp_resolution_scale = resolution_scale tmp_resolution_x = resolution_x tmp_resolution_y = resolution_y + tmp_invert = invert tmp_type = type updateCurrentSelection() diff --git a/package/contents/ui/ShaderToyModel.qml b/package/contents/ui/ShaderToyModel.qml index 9611df5..fcbacf2 100644 --- a/package/contents/ui/ShaderToyModel.qml +++ b/package/contents/ui/ShaderToyModel.qml @@ -89,6 +89,9 @@ Item type: wallpaper.configuration.iChannel0_flag ? wallpaper.configuration.iChannel0_type : 0 source: wallpaper.configuration.iChannel0_flag ? Qt.resolvedUrl(wallpaper.configuration.iChannel0) : "" + + // ShaderToy seems to start at bottom left for 0,0 + invert: wallpaper.configuration.iChannel0_inverted } ShaderChannel @@ -103,6 +106,9 @@ Item type: wallpaper.configuration.iChannel1_flag ? wallpaper.configuration.iChannel1_type : 0 source: wallpaper.configuration.iChannel1_flag ? Qt.resolvedUrl(wallpaper.configuration.iChannel1) : "" + + // ShaderToy seems to start at bottom left for 0,0 + invert: wallpaper.configuration.iChannel1_inverted ? wallpaper.configuration.iChannel1_inverted : true } ShaderChannel @@ -117,6 +123,9 @@ Item type: wallpaper.configuration.iChannel2_flag ? wallpaper.configuration.iChannel2_type : 0 source: wallpaper.configuration.iChannel2_flag ? Qt.resolvedUrl(wallpaper.configuration.iChannel2) : "" + + // ShaderToy seems to start at bottom left for 0,0 + invert: wallpaper.configuration.iChannel2_inverted ? wallpaper.configuration.iChannel2_inverted : true } ShaderChannel @@ -133,6 +142,9 @@ Item type: wallpaper.configuration.iChannel3_flag ? wallpaper.configuration.iChannel3_type : 0 source: wallpaper.configuration.iChannel3_flag ? Qt.resolvedUrl(wallpaper.configuration.iChannel3) : "" + + // ShaderToy seems to start at bottom left for 0,0 + invert: wallpaper.configuration.iChannel3_inverted ? wallpaper.configuration.iChannel3_inverted : true } // The output channel that combines all the input channels and displays the final shader output diff --git a/package/contents/ui/config.qml b/package/contents/ui/config.qml index 87beab5..aca1ccf 100644 --- a/package/contents/ui/config.qml +++ b/package/contents/ui/config.qml @@ -71,6 +71,10 @@ Kirigami.FormLayout property alias cfg_iChannel2_resolution_y: shaderChannelConfig2.resolution_y property alias cfg_iChannel3_resolution_x: shaderChannelConfig3.resolution_x property alias cfg_iChannel3_resolution_y: shaderChannelConfig3.resolution_y + property alias cfg_iChannel0_inverted: shaderChannelConfig0.invert + property alias cfg_iChannel1_inverted: shaderChannelConfig1.invert + property alias cfg_iChannel2_inverted: shaderChannelConfig2.invert + property alias cfg_iChannel3_inverted: shaderChannelConfig3.invert property alias cfg_shaderSpeed: speedSlider.value property alias cfg_mouseSpeedBias: mouseBiasSlider.value property alias cfg_mouseAllowed: mouseEnableButton.checked @@ -773,7 +777,7 @@ Kirigami.FormLayout } textRole: "fileBaseName" - currentIndex: root.cfg_shader_package + currentIndex: root.cfg_shader_package_index displayText: currentIndex === -1 ? "Custom File" : currentText.replace("_", " ").charAt(0).toUpperCase() + currentText.replace("_", " ").slice(1) onCurrentTextChanged: