diff --git a/package/contents/ui/Shaders/Abstract_Liquid.frag b/package/contents/ui/Shaders/Abstract_Liquid.frag new file mode 100644 index 0000000..7d00075 --- /dev/null +++ b/package/contents/ui/Shaders/Abstract_Liquid.frag @@ -0,0 +1,143 @@ +// URL: shadertoy.com/view/ctd3z4 +// By: SentientCymatic + +#version 450 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + float iTime; + float iTimeDelta; + float iFrameRate; + float iSampleRate; + int iFrame; + vec4 iDate; + vec4 iMouse; + vec3 iResolution; + float iChannelTime[4]; + vec3 iChannelResolution[4]; +} ubuf; + +layout(binding = 1) uniform sampler2D iChannel0; +layout(binding = 1) uniform sampler2D iChannel1; +layout(binding = 1) uniform sampler2D iChannel2; +layout(binding = 1) uniform sampler2D iChannel3; + +vec2 fragCoord = vec2(qt_TexCoord0.x, 1.0 - qt_TexCoord0.y) * ubuf.iResolution.xy; + +// either rename them in the frag or add this (probably costs some performance) + +int iFrame = ubuf.iFrame; +float iTime = ubuf.iTime; +float iTimeDelta = ubuf.iTimeDelta; +vec3 iResolution = ubuf.iResolution; +vec4 iMouse = ubuf.iMouse; + +// these must be modified as you cant do that with arrays afaik: +float iChannelTime[4]; +vec3 iChannelResolution[4]; + +// original shader starts here + +vec2 hash2( float n ){return fract(sin(vec2(n,n+1.0))*vec2(432.14159,528.14159));} + +const vec2 randConst = vec2(432.14159, 528.14159); +const float randMultiplier = 3.14159; +float rand(const vec2 co) { + return fract(sin(co.x * randConst.x + co.y * randConst.y) * randMultiplier);} + +float custom_smoothstep(float edge0, float edge1, float x) { + float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); + return t * t * (3.0 - 2.0 * t);} + +float noise(in vec2 x){ + vec2 p = floor(x); + vec2 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + vec2 n = p + vec2(2.5, -2.5); + float a = mix(rand(n), rand(n + vec2(1.0, 0.0)), f.x); + float b = mix(rand(n + vec2(0.0, 1.0)), rand(n + vec2(1.0, 1.0)), f.x); + return mix(a, b, f.y);} + +vec2 turbulence(vec2 p, float t, float scale){ + float sum = 0.1; + float freq = scale; + float smoothness; + vec2 noise_coord; + for (int i = 0; i < 5; i++){ + smoothness = custom_smoothstep(0.0, 10.0, float(i)); + noise_coord = vec2(p + t * 0.25) + vec2(cos(float(i) * 0.5), sin(float(i) * 0.5)) * smoothness; + sum += abs(noise(noise_coord)) / freq; + freq *= 0.25;} + return vec2(sum, sum) * 0.1;} + +mat2 mtx = mat2( 0.87, 0.5, -0.5, 0.87 ); + +float fbm( vec2 p ){ + float f = 0.05; + f += 0.950000*noise( p ); p = mtx*p*3.0; + f += 0.200000*noise( p ); p = mtx*p*2.0; + f += 0.100000*noise( p ); p = mtx*p*2.0; + f += 0.050000*noise( p ); p = mtx*p*2.0; + f += 0.025000*noise( p ); p = mtx*p*1.0; + f += 0.005000*noise( p ); + p = mtx*p*2.0; + f += 0.004*noise( p ); + p = mtx*p*2.0; + f += 0.002*noise( p ); + return f/0.95000;} + +float pattern(in vec2 p, in float t, in vec2 uv, out vec2 q, out vec2 r, out vec2 g) { + float s = dot(uv + 0.5, uv + 0.5); + float iMelty = 50.0, iFlowing = 10.0; + float l = custom_smoothstep(0.0, iMelty, sin(t * iFlowing)); + q = mix(vec2(fbm(p + vec2(t * 1. + sin(t), t * 0.2 + cos(t))), + fbm(p + vec2(t * 0.5 + sin(t + 0.5), t * 0.5 + cos(t + 1.5)))), + vec2(fbm(p), fbm(p + vec2(10.5, 1.5))), + l); + r = mix(vec2(fbm(p + 3.14159 * q + vec2(t * 0.25 + sin(t * 0.25), t * 0.25 + cos(t * 0.50)) + vec2(1.5, 10.5)), + fbm(p + 2.0 * q + vec2(t * 0.5 + sin(t * 0.3), t * 0.4 + cos(t * 0.9)) + vec2(8.5, 4.8))), + vec2(fbm(p + 5.0 * q + vec2(t) + vec2(33.66, 66.33)), fbm(p + 4. * q + vec2(t) + vec2(8.5, 2.5))), + l); + g = mix(vec2(fbm(p + 2.0 * r + vec2(t * 0.5 + sin(t * 0.5), t * 0.5 + cos(t * 0.75)) + vec2(2.5, 5)), + fbm(p + 1.5 * r + vec2(t * 0.75 + sin(t * 0.25), t * 0.5 + cos(t * 0.5)) + vec2(5, 2.5))), + vec2(fbm(p + 2.5 * r + vec2(t * 5.0) + vec2(2, 5)), fbm(p + 2. * r + vec2(t * 11.0) + vec2(5, 2.5))), + l); + vec2 v = turbulence(p * 0.1, t * 0.1, 20.); + vec2 m = vec2(fbm(p * 0.5 + vec2(t * 0.9, t * 0.9) + v * 0.5), + fbm(p * 0.5 + vec2(t * 0.9, t * 0.9) + v * 0.5)); + return mix(fbm(p + 2.5 * g + vec2(-t * 0.75 + sin(t * 0.5), -t * 0.5 + cos(t * 0.25)) + v * 2.5 + m * 0.25), + fbm(p + 5.0 * g + vec2(-t * 5.0) + v * 2.5), + l);} + +void mainImage(out vec4 fragColor, in vec2 fragCoord){ + float iSmoke = 0.005; + float iSpeed = 0.250; + vec2 uv = fragCoord / iResolution.xy; + vec2 q, r, g; + float noise = pattern(fragCoord * vec2(iSmoke), iTime * iSpeed, uv, q, r, g); + vec3 col = mix(vec3(0.2, 0.4, 0.2), vec3(0.0, 0.25, 0.5), custom_smoothstep(0.1, 1.0, noise)); + col = mix(col, vec3(0.4, 0.2, 0.2), dot(q, q) * 1.5); + col = mix(col, vec3(0.2, 0.4, 0.0), 0.25 * g.y * g.y); + col = mix(col, vec3(0.4, 0.2, 0.2), custom_smoothstep(0.2, 0.5, 1.0 * r.g * r.g)); + col = mix(col, vec3(0.2, 0.4, 0.6), 0.5 * g.x); + float timeScale = .25; + float xDrift = sin(uv.x * 3.14159 + iTime * timeScale); + float yDrift = cos(uv.y * 3.14159 + iTime * timeScale); + vec3 drift = vec3(xDrift, yDrift, -xDrift - yDrift) * .1; + col += drift; + col = mix(col, vec3(1), custom_smoothstep(0., 1., noise) * custom_smoothstep(0., 10., noise)); + col *= noise * 2.; + fragColor = vec4(col, 1.);} + +// original shader ends here + +// add this at the end +void main() { + vec4 color = vec4(0.0); + mainImage(color, fragCoord); + fragColor = color; +} diff --git a/package/contents/ui/Shaders6/Abstract_Liquid.frag.qsb b/package/contents/ui/Shaders6/Abstract_Liquid.frag.qsb new file mode 100644 index 0000000..8f3288b Binary files /dev/null and b/package/contents/ui/Shaders6/Abstract_Liquid.frag.qsb differ diff --git a/package/contents/ui/config.qml b/package/contents/ui/config.qml index 23f2df8..071285e 100644 --- a/package/contents/ui/config.qml +++ b/package/contents/ui/config.qml @@ -13,7 +13,26 @@ Kirigami.FormLayout { property alias formLayout: root // required by parent property alias cfg_pauseMode: pauseModeCombo.currentIndex property bool cfg_isPaused: runningCombo.checked - + property int cfg_selectedShaderIndex: -1 + property string cfg_iChannel0: wallpaper.configuration.iChannel0 + property string cfg_iChannel1: wallpaper.configuration.iChannel1 + property string cfg_iChannel2: wallpaper.configuration.iChannel2 + property string cfg_iChannel3: wallpaper.configuration.iChannel3 + property bool cfg_iChannel0_flag: wallpaper.configuration.iChannel0_flag + property bool cfg_iChannel1_flag: wallpaper.configuration.iChannel1_flag + property bool cfg_iChannel2_flag: wallpaper.configuration.iChannel2_flag + property bool cfg_iChannel3_flag: wallpaper.configuration.iChannel3_flag + property string cfg_selectedShaderPath: wallpaper.configuration.selectedShaderPath + property double cfg_shaderSpeed: wallpaper.configuration.shaderSpeed + property double cfg_mouseSpeedBias: wallpaper.configuration.mouseSpeedBias + property bool cfg_mouseAllowed: wallpaper.configuration.mouseAllowed + property bool cfg_infoPlasma6Preview_dismissed: wallpaper.configuration.infoPlasma6Preview_dismissed + property bool cfg_warningResources_dismissed: wallpaper.configuration.warningResources_dismissed + property bool cfg_emergencyHelp_dismissed: wallpaper.configuration.emergencyHelp_dismissed + property bool cfg_infoiChannelSettings_dismissed: wallpaper.configuration.infoiChannelSettings_dismissed + property bool cfg_checkActiveScreen: wallpaper.configuration.checkActiveScreen + property bool cfg_running: wallpaper.configuration.running + RowLayout { Kirigami.FormData.label: i18nd("online.knowmad.shaderwallpaper", "Select shader:"); ComboBox { @@ -36,15 +55,16 @@ Kirigami.FormLayout { } textRole: "fileBaseName" - currentIndex: wallpaper.configuration.selectedShaderIndex + currentIndex: cfg_selectedShaderIndex displayText: currentIndex === -1 ? "Custom Shader" : currentText.replace("_"," ").charAt(0).toUpperCase() + currentText.replace("_"," ").slice(1) onCurrentTextChanged: { - wallpaper.configuration.selectedShaderIndex = currentIndex; - if (wallpaper.configuration.selectedShaderIndex === -1) { + cfg_selectedShaderIndex = currentIndex; + if (cfg_selectedShaderIndex === -1) { return }; wallpaper.configuration.selectedShaderPath = Qt.resolvedUrl("./Shaders6/"+model.get(currentIndex, "fileName")); + cfg_selectedShaderPath = Qt.resolvedUrl("./Shaders6/"+model.get(currentIndex, "fileName")); } } @@ -81,10 +101,10 @@ Kirigami.FormLayout { CheckBox { id: activeScreenOnlyCheckbx Kirigami.FormData.label: i18nd("@checkbox:screen_filter", "Filter:") - checked: wallpaper.configuration.checkActiveScreen + checked: cfg_checkActiveScreen text: i18n("Only check for windows in active screen") onCheckedChanged: { - wallpaper.configuration.checkActiveScreen = checked + cfg_checkActiveScreen = checked } } // use Item instead to remove the line @@ -97,10 +117,11 @@ Kirigami.FormLayout { Kirigami.FormData.label: i18nd("online.knowmad.shaderwallpaper", cfg_isPaused ? "Playing" : "Paused"); CheckBox { id: runningCombo - checked: wallpaper.configuration.running + checked: cfg_running text: i18n("Play/Pause the shader") onCheckedChanged: { wallpaper.configuration.running = checked + cfg_running = checked } } } @@ -114,17 +135,18 @@ Kirigami.FormLayout { to: 10.0 id: speedSlider stepSize: 0.01 - value: wallpaper.configuration.shaderSpeed ? wallpaper.configuration.shaderSpeed : 1.0 + value: cfg_shaderSpeed ? cfg_shaderSpeed : 1.0 onValueChanged: { shaderSpeedField.text = String(value.toFixed(2)); wallpaper.configuration.shaderSpeed = shaderSpeedField.text; + cfg_shaderSpeed = shaderSpeedField.text; } } } ColumnLayout { TextField { id: shaderSpeedField - text: wallpaper.configuration.shaderSpeed ? String(wallpaper.configuration.shaderSpeed.toFixed(2)) : "1.00" + text: cfg_shaderSpeed ? String(cfg_shaderSpeed.toFixed(2)) : "1.00" inputMethodHints: Qt.NumberInput Layout.preferredWidth: Kirigami.Units.gridUnit * 3 onEditingFinished: { @@ -137,6 +159,7 @@ Kirigami.FormLayout { text = inputValue.toFixed(2); speedSlider.value = inputValue; wallpaper.configuration.shaderSpeed = inputValue; + cfg_shaderSpeed = inputValue; } Keys.onPressed: { if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { @@ -162,9 +185,10 @@ Kirigami.FormLayout { icon.name: checked? "followmouse-symbolic" : "hidemouse-symbolic" text: i18nd("@button:toggle_use_mouse", checked? "Enabled" : "Disabled") checkable: true - checked: wallpaper.configuration.mouseAllowed + checked: cfg_mouseAllowed onClicked: { - wallpaper.configuration.mouseAllowed = !wallpaper.configuration.mouseAllowed + wallpaper.configuration.mouseAllowed = !cfg_mouseAllowed; + cfg_mouseAllowed = !cfg_mouseAllowed; } ToolTip.visible: hovered ToolTip.text: qsTr("Enabling this will allow the shader to interact with the cursor but will prevent interaction with desktop elements") @@ -172,7 +196,7 @@ Kirigami.FormLayout { } RowLayout { - visible: wallpaper.configuration.mouseAllowed + visible: cfg_mouseAllowed Kirigami.FormData.label: i18nd("online.knowmad.shaderwallpaper", "Mouse bias:"); ColumnLayout { Slider { @@ -181,17 +205,18 @@ Kirigami.FormLayout { to: 10.0 id: mouseBiasSlider stepSize: 0.01 - value: wallpaper.configuration.mouseSpeedBias ? wallpaper.configuration.mouseSpeedBias : 1.0 + value: cfg_mouseSpeedBias ? cfg_mouseSpeedBias : 1.0 onValueChanged: { mouseBiasField.text = String(value.toFixed(2)); - wallpaper.configuration.mouseSpeedBias = mouseBiasField.text; + wallpaper.configuration.mouseBias = mouseBiasField.text; + cfg_mouseSpeedBias = mouseBiasField.text; } } } ColumnLayout { TextField { id: mouseBiasField - text: wallpaper.configuration.mouseSpeedBias ? String(wallpaper.configuration.mouseSpeedBias.toFixed(2)) : "1.00" + text: cfg_mouseSpeedBias ? String(cfg_mouseSpeedBias.toFixed(2)) : "1.00" inputMethodHints: Qt.NumberInput Layout.preferredWidth: Kirigami.Units.gridUnit * 3 onEditingFinished: { @@ -203,7 +228,8 @@ Kirigami.FormLayout { } text = inputValue.toFixed(2); mouseBiasSlider.value = inputValue; - wallpaper.configuration.mouseSpeedBias = inputValue; + wallpaper.configuration.mouseBias = inputValue; + cfg_mouseSpeedBias = inputValue; } Keys.onPressed: { if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { @@ -229,9 +255,9 @@ Kirigami.FormLayout { type: Kirigami.MessageType.Info text: qsTr("Different shaders use different iChannels!\nPlay with the settings below!") showCloseButton: true - visible: !wallpaper.configuration.infoiChannelSettings_dismissed + visible: !cfg_infoiChannelSettings_dismissed onVisibleChanged: { - wallpaper.configuration.infoiChannelSettings_dismissed = true; + cfg_infoiChannelSettings_dismissed = true; } } // iChannel0 @@ -240,26 +266,26 @@ Kirigami.FormLayout { CheckBox { id: iChannel0_flag width: 35 - checked: wallpaper.configuration.iChannel0_flag + checked: cfg_iChannel0_flag onCheckedChanged: { - wallpaper.configuration.iChannel0_flag = checked - wallpaper.configuration.iChannel0 = iChannel0Field.text; + cfg_iChannel0_flag = checked + cfg_iChannel0 = iChannel0Field.text; } } TextField { id: iChannel0Field placeholderText: "path to iChannel0" - text: wallpaper.configuration.iChannel0 + text: cfg_iChannel0 visible: iChannel0_flag.checked onEditingFinished: { - wallpaper.configuration.iChannel0 = iChannel0Field.text; - ich0_thumbnail.source = wallpaper.configuration.iChannel0 + cfg_iChannel0 = iChannel0Field.text; + ich0_thumbnail.source = cfg_iChannel0 } } Image { id: ich0_thumbnail - source: wallpaper.configuration.iChannel0 + source: cfg_iChannel0 fillMode: Image.PreserveAspectFit visible: iChannel0_flag.checked && iChannel0Field.text !== "" Layout.preferredWidth: 36 @@ -281,26 +307,26 @@ Kirigami.FormLayout { CheckBox { id: iChannel1_flag width: 35 - checked: wallpaper.configuration.iChannel1_flag + checked: cfg_iChannel1_flag onCheckedChanged: { - wallpaper.configuration.iChannel1_flag = checked - wallpaper.configuration.iChannel1 = iChannel1Field.text; + cfg_iChannel1_flag = checked + cfg_iChannel1 = iChannel1Field.text; } } TextField { id: iChannel1Field placeholderText: "path to iChannel1" - text: wallpaper.configuration.iChannel1 + text: cfg_iChannel1 visible: iChannel1_flag.checked onEditingFinished: { - wallpaper.configuration.iChannel1 = iChannel1Field.text; - ich1_thumbnail.source = wallpaper.configuration.iChannel1 + cfg_iChannel1 = iChannel1Field.text; + ich1_thumbnail.source = cfg_iChannel1 } } Image { id: ich1_thumbnail - source: wallpaper.configuration.iChannel1 + source: cfg_iChannel1 fillMode: Image.PreserveAspectFit visible: iChannel1_flag.checked && iChannel1Field.text !== "" Layout.preferredWidth: 36 @@ -322,26 +348,26 @@ Kirigami.FormLayout { CheckBox { id: iChannel2_flag width: 35 - checked: wallpaper.configuration.iChannel2_flag + checked: cfg_iChannel2_flag onCheckedChanged: { - wallpaper.configuration.iChannel2_flag = checked - wallpaper.configuration.iChannel2 = iChannel2Field.text; + cfg_iChannel2_flag = checked + cfg_iChannel2 = iChannel2Field.text; } } TextField { id: iChannel2Field placeholderText: "path to iChannel2" - text: wallpaper.configuration.iChannel2 + text: cfg_iChannel2 visible: iChannel2_flag.checked onEditingFinished: { - wallpaper.configuration.iChannel2 = iChannel2Field.text; - ich2_thumbnail.source = wallpaper.configuration.iChannel2 + cfg_iChannel2 = iChannel2Field.text; + ich2_thumbnail.source = cfg_iChannel2 } } Image { id: ich2_thumbnail - source: wallpaper.configuration.iChannel2 + source: cfg_iChannel2 fillMode: Image.PreserveAspectFit visible: iChannel2_flag.checked && iChannel2Field.text !== "" Layout.preferredWidth: 36 @@ -363,26 +389,26 @@ Kirigami.FormLayout { CheckBox { id: iChannel3_flag width: 35 - checked: wallpaper.configuration.iChannel3_flag + checked: cfg_iChannel3_flag onCheckedChanged: { - wallpaper.configuration.iChannel3_flag = checked - wallpaper.configuration.iChannel3 = iChannel3Field.text; + cfg_iChannel3_flag = checked + cfg_iChannel3 = iChannel3Field.text; } } TextField { id: iChannel3Field placeholderText: "path to iChannel3" - text: wallpaper.configuration.iChannel3 + text: cfg_iChannel3 visible: iChannel3_flag.checked onEditingFinished: { - wallpaper.configuration.iChannel3 = iChannel3Field.text; - ich3_thumbnail.source = wallpaper.configuration.iChannel3 + cfg_iChannel3 = iChannel3Field.text; + ich3_thumbnail.source = cfg_iChannel3 } } Image { id: ich3_thumbnail - source: wallpaper.configuration.iChannel3 + source: cfg_iChannel3 fillMode: Image.PreserveAspectFit visible: iChannel3_flag.checked && iChannel3Field.text !== "" Layout.preferredWidth: 36 @@ -410,9 +436,9 @@ Kirigami.FormLayout { type: Kirigami.MessageType.Positive text: qsTr("This is an early preview!\nOfficial release will have more many more features :)") showCloseButton: true - visible: !wallpaper.configuration.infoPlasma6Preview_dismissed + visible: !cfg_infoPlasma6Preview_dismissed onVisibleChanged: { - wallpaper.configuration.infoPlasma6Preview_dismissed = true; + cfg_infoPlasma6Preview_dismissed = true; } } @@ -422,9 +448,9 @@ Kirigami.FormLayout { type: Kirigami.MessageType.Warning text: qsTr("Some shaders might consume more power than others, beware!") showCloseButton: true - visible: !wallpaper.configuration.warningResources_dismissed + visible: !cfg_warningResources_dismissed onVisibleChanged: { - wallpaper.configuration.warningResources_dismissed = true; + cfg_warningResources_dismissed = true; } } @@ -488,8 +514,8 @@ Kirigami.FormLayout { visible: false currentFolder: `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/.local/share/plasma/wallpapers/online.knowmad.shaderwallpaper/contents/ui/Shaders6/` onAccepted: { - wallpaper.configuration.selectedShaderIndex = -1; - wallpaper.configuration.selectedShaderPath = selectedFile; + cfg_selectedShaderIndex = -1; + cfg_selectedShaderPath = selectedFile; } } @@ -503,7 +529,7 @@ Kirigami.FormLayout { title: i18nd("@dialog_title:choose_ichannel", "Choose an Image") currentFolder: `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/.local/share/plasma/wallpapers/online.knowmad.shaderwallpaper/contents/ui/Resources/` onAccepted: { - wallpaper.configuration.iChannel0 = selectedFile + cfg_iChannel0 = selectedFile } } @@ -516,7 +542,7 @@ Kirigami.FormLayout { currentFolder: `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/.local/share/plasma/wallpapers/online.knowmad.shaderwallpaper/contents/ui/Resources/` onAccepted: { - wallpaper.configuration.iChannel1 = selectedFile + cfg_iChannel1 = selectedFile } } @@ -528,7 +554,7 @@ Kirigami.FormLayout { title: i18nd("@dialog_title:choose_ichannel", "Choose an Image") currentFolder: `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/.local/share/plasma/wallpapers/online.knowmad.shaderwallpaper/contents/ui/Resources/` onAccepted: { - wallpaper.configuration.iChannel2 = selectedFile + cfg_iChannel2 = selectedFile } } FileDialog { @@ -539,7 +565,7 @@ Kirigami.FormLayout { title: i18nd("@dialog_title:choose_ichannel", "Choose an Image") currentFolder: `${StandardPaths.writableLocation(StandardPaths.HomeLocation)}/.local/share/plasma/wallpapers/online.knowmad.shaderwallpaper/contents/ui/Resources/` onAccepted: { - wallpaper.configuration.iChannel3 = selectedFile + cfg_iChannel3 = selectedFile } } Kirigami.OverlaySheet {