Wallpaper: added a bash script to compile all shaders
+ code cleanup
This commit is contained in:
parent
477d38d928
commit
3c7d03ada9
6 changed files with 75 additions and 52 deletions
36
Bin/shaders-compile.sh
Executable file
36
Bin/shaders-compile.sh
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Directory containing the source shaders.
|
||||||
|
SOURCE_DIR="Shaders/frag/"
|
||||||
|
|
||||||
|
# Directory where the compiled shaders will be saved.
|
||||||
|
DEST_DIR="Shaders/qsb/"
|
||||||
|
|
||||||
|
# Check if the source directory exists.
|
||||||
|
if [ ! -d "$SOURCE_DIR" ]; then
|
||||||
|
echo "Source directory $SOURCE_DIR not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the destination directory if it doesn't exist.
|
||||||
|
mkdir -p "$DEST_DIR"
|
||||||
|
|
||||||
|
# Loop through all files in the source directory ending with .frag
|
||||||
|
for shader in "$SOURCE_DIR"*.frag; do
|
||||||
|
# Check if a file was found (to handle the case of no .frag files).
|
||||||
|
if [ -f "$shader" ]; then
|
||||||
|
# Get the base name of the file (e.g., wp_fade).
|
||||||
|
shader_name=$(basename "$shader" .frag)
|
||||||
|
|
||||||
|
# Construct the output path for the compiled shader.
|
||||||
|
output_path="$DEST_DIR$shader_name.frag.qsb"
|
||||||
|
|
||||||
|
# Construct and run the qsb command.
|
||||||
|
qsb --qt6 -o "$output_path" "$shader"
|
||||||
|
|
||||||
|
# Print a message to confirm compilation.
|
||||||
|
echo "Compiled $shader to $output_path"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Shader compilation complete."
|
||||||
|
|
@ -12,14 +12,14 @@ Variants {
|
||||||
|
|
||||||
required property ShellScreen modelData
|
required property ShellScreen modelData
|
||||||
|
|
||||||
active: Settings.isLoaded && WallpaperService.getWallpaper(modelData.name)
|
active: Settings.isLoaded
|
||||||
|
|
||||||
sourceComponent: PanelWindow {
|
sourceComponent: PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Internal state management
|
// Internal state management
|
||||||
property bool firstWallpaper: true
|
property bool firstWallpaper: true
|
||||||
property string transitionType: 'fade'
|
property string transitionType: "fade"
|
||||||
property bool transitioning: false
|
property bool transitioning: false
|
||||||
property real transitionProgress: 0
|
property real transitionProgress: 0
|
||||||
property real edgeSmoothness: Settings.data.wallpaper.transitionEdgeSmoothness
|
property real edgeSmoothness: Settings.data.wallpaper.transitionEdgeSmoothness
|
||||||
|
|
@ -40,7 +40,6 @@ Variants {
|
||||||
property string servicedWallpaper: WallpaperService.getWallpaper(modelData.name)
|
property string servicedWallpaper: WallpaperService.getWallpaper(modelData.name)
|
||||||
onServicedWallpaperChanged: {
|
onServicedWallpaperChanged: {
|
||||||
if (servicedWallpaper && servicedWallpaper !== currentWallpaper.source) {
|
if (servicedWallpaper && servicedWallpaper !== currentWallpaper.source) {
|
||||||
|
|
||||||
// Set wallpaper immediately on startup
|
// Set wallpaper immediately on startup
|
||||||
if (firstWallpaper) {
|
if (firstWallpaper) {
|
||||||
firstWallpaper = false
|
firstWallpaper = false
|
||||||
|
|
@ -51,36 +50,25 @@ Variants {
|
||||||
// Get the transitionType from the settings
|
// Get the transitionType from the settings
|
||||||
transitionType = Settings.data.wallpaper.transitionType
|
transitionType = Settings.data.wallpaper.transitionType
|
||||||
|
|
||||||
if (transitionType == 'random') {
|
if (transitionType == "random") {
|
||||||
var index = Math.floor(Math.random() * allTransitions.length)
|
var index = Math.floor(Math.random() * allTransitions.length)
|
||||||
transitionType = allTransitions[index]
|
transitionType = allTransitions[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the transition type really exists
|
// Ensure the transition type really exists
|
||||||
if (transitionType !== "none" && !allTransitions.includes(transitionType)) {
|
if (transitionType !== "none" && !allTransitions.includes(transitionType)) {
|
||||||
transitionType = 'fade'
|
transitionType = "fade"
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.log("Background", "New wallpaper: ", servicedWallpaper, "On:", modelData.name, "Transition:", transitionType)
|
Logger.log("Background", "New wallpaper: ", servicedWallpaper, "On:", modelData.name, "Transition:",
|
||||||
|
transitionType)
|
||||||
|
|
||||||
switch (transitionType) {
|
switch (transitionType) {
|
||||||
case "none":
|
case "none":
|
||||||
setWallpaperImmediate(servicedWallpaper)
|
setWallpaperImmediate(servicedWallpaper)
|
||||||
break
|
break
|
||||||
case "wipe_left":
|
case "wipe":
|
||||||
wipeDirection = 0
|
wipeDirection = Math.random() * 4
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
|
||||||
break
|
|
||||||
case "wipe_right":
|
|
||||||
wipeDirection = 1
|
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
|
||||||
break
|
|
||||||
case "wipe_up":
|
|
||||||
wipeDirection = 2
|
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
|
||||||
break
|
|
||||||
case "wipe_down":
|
|
||||||
wipeDirection = 3
|
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
break
|
break
|
||||||
case "disc":
|
case "disc":
|
||||||
|
|
@ -89,7 +77,7 @@ Variants {
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
break
|
break
|
||||||
case "stripes":
|
case "stripes":
|
||||||
stripesCount = Math.round(Math.random() * 24 + 2)
|
stripesCount = Math.round(Math.random() * 24 + 6)
|
||||||
stripesAngle = Math.random() * 360
|
stripesAngle = Math.random() * 360
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
break
|
break
|
||||||
|
|
@ -139,7 +127,7 @@ Variants {
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: fadeShader
|
id: fadeShader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: transitionType === 'fade' || transitionType === 'none'
|
visible: transitionType === "fade" || transitionType === "none"
|
||||||
|
|
||||||
property variant source1: currentWallpaper
|
property variant source1: currentWallpaper
|
||||||
property variant source2: nextWallpaper
|
property variant source2: nextWallpaper
|
||||||
|
|
@ -151,7 +139,7 @@ Variants {
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: wipeShader
|
id: wipeShader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: transitionType.startsWith('wipe_')
|
visible: transitionType === "wipe"
|
||||||
|
|
||||||
property variant source1: currentWallpaper
|
property variant source1: currentWallpaper
|
||||||
property variant source2: nextWallpaper
|
property variant source2: nextWallpaper
|
||||||
|
|
@ -166,7 +154,7 @@ Variants {
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: discShader
|
id: discShader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: transitionType === 'disc'
|
visible: transitionType === "disc"
|
||||||
|
|
||||||
property variant source1: currentWallpaper
|
property variant source1: currentWallpaper
|
||||||
property variant source2: nextWallpaper
|
property variant source2: nextWallpaper
|
||||||
|
|
@ -183,7 +171,7 @@ Variants {
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: stripesShader
|
id: stripesShader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: transitionType === 'stripes'
|
visible: transitionType === "stripes"
|
||||||
|
|
||||||
property variant source1: currentWallpaper
|
property variant source1: currentWallpaper
|
||||||
property variant source2: nextWallpaper
|
property variant source2: nextWallpaper
|
||||||
|
|
@ -203,8 +191,10 @@ Variants {
|
||||||
property: "transitionProgress"
|
property: "transitionProgress"
|
||||||
from: 0.0
|
from: 0.0
|
||||||
to: 1.0
|
to: 1.0
|
||||||
duration: Settings.data.wallpaper.transitionDuration ?? 1000
|
// The stripes shader feels faster visually, we make it a bit slower here.
|
||||||
easing.type: Easing.InOutCubic //transitionType.startsWith('wipe_') ? Easing.InOutCubic : Easing.OutQuad
|
duration: transitionType == "stripes" ? Settings.data.wallpaper.transitionDuration
|
||||||
|
* 1.4 : Settings.data.wallpaper.transitionDuration
|
||||||
|
easing.type: Easing.InOutCubic
|
||||||
onFinished: {
|
onFinished: {
|
||||||
// Swap images after transition completes
|
// Swap images after transition completes
|
||||||
currentWallpaper.source = nextWallpaper.source
|
currentWallpaper.source = nextWallpaper.source
|
||||||
|
|
|
||||||
|
|
@ -249,8 +249,6 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reusable component for interval preset chips
|
// Reusable component for interval preset chips
|
||||||
|
|
|
||||||
|
|
@ -36,24 +36,12 @@ Singleton {
|
||||||
name: "Stripes"
|
name: "Stripes"
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
key: "wipe_left"
|
key: "wipe"
|
||||||
name: "Wipe Left"
|
name: "Wipe"
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
key: "wipe_right"
|
|
||||||
name: "Wipe Right"
|
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
key: "wipe_up"
|
|
||||||
name: "Wipe Up"
|
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
key: "wipe_down"
|
|
||||||
name: "Wipe Down"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All transition keys but filter out "random"
|
// All transition keys but filter out "none" and "random" so we are left with the real transitions
|
||||||
readonly property var allTransitions: Array.from({
|
readonly property var allTransitions: Array.from({
|
||||||
"length": transitionsModel.count
|
"length": transitionsModel.count
|
||||||
}, (_, i) => transitionsModel.get(i).key).filter(
|
}, (_, i) => transitionsModel.get(i).key).filter(
|
||||||
|
|
@ -154,7 +142,6 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Logger.log("Wallpaper", "setWallpaper on", screenName, ": ", path)
|
//Logger.log("Wallpaper", "setWallpaper on", screenName, ": ", path)
|
||||||
|
|
||||||
var wallpaperChanged = false
|
var wallpaperChanged = false
|
||||||
|
|
||||||
var monitor = getMonitorConfig(screenName)
|
var monitor = getMonitorConfig(screenName)
|
||||||
|
|
|
||||||
|
|
@ -65,16 +65,28 @@ void main() {
|
||||||
// Use absolute stripe position for consistent delay across all stripes
|
// Use absolute stripe position for consistent delay across all stripes
|
||||||
float normalizedStripePos = clamp(stripePos / stripes, 0.0, 1.0);
|
float normalizedStripePos = clamp(stripePos / stripes, 0.0, 1.0);
|
||||||
|
|
||||||
// Reduced delay factor and better scaling to match other shaders' timing
|
// Increased delay and better distribution
|
||||||
float maxDelay = 0.15; // Maximum delay for the last stripe
|
float maxDelay = 0.15;
|
||||||
float stripeDelay = normalizedStripePos * maxDelay;
|
float stripeDelay = normalizedStripePos * maxDelay;
|
||||||
|
|
||||||
// Ensure all stripes complete when progress reaches 1.0
|
// Better progress mapping that uses the full 0.0-1.0 range
|
||||||
// without making the overall animation appear faster
|
// Map progress so that:
|
||||||
float stripeProgress = clamp((ubuf.progress - stripeDelay) / (1.0 - maxDelay), 0.0, 1.0);
|
// - First stripe starts at progress = 0.0
|
||||||
|
// - Last stripe finishes at progress = 1.0
|
||||||
|
float stripeProgress;
|
||||||
|
if (ubuf.progress <= stripeDelay) {
|
||||||
|
stripeProgress = 0.0;
|
||||||
|
} else if (ubuf.progress >= (stripeDelay + (1.0 - maxDelay))) {
|
||||||
|
stripeProgress = 1.0;
|
||||||
|
} else {
|
||||||
|
// Scale the progress within the active window for this stripe
|
||||||
|
float activeStart = stripeDelay;
|
||||||
|
float activeEnd = stripeDelay + (1.0 - maxDelay);
|
||||||
|
stripeProgress = (ubuf.progress - activeStart) / (activeEnd - activeStart);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply smooth easing
|
// Use gentler easing curve
|
||||||
stripeProgress = smoothstep(0.0, 1.0, stripeProgress);
|
stripeProgress = stripeProgress * stripeProgress * (3.0 - 2.0 * stripeProgress); // Smootherstep instead of smoothstep
|
||||||
|
|
||||||
// Use the perpendicular coordinate for edge comparison
|
// Use the perpendicular coordinate for edge comparison
|
||||||
float yPos = perpCoord;
|
float yPos = perpCoord;
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue