Make glpaper work

This commit is contained in:
Nathan McCarty 2022-04-19 19:00:41 -04:00
parent 0c7b7df6f0
commit 760759714f
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
3 changed files with 86 additions and 4 deletions

View File

@ -0,0 +1,73 @@
#ifdef GL_ES
precision mediump float;
#endif
#ifdef GLSLVIEWER
uniform float u_time;
uniform vec2 u_resolution;
#endif
#ifndef GLSLVIEWER
uniform float time;
uniform vec2 resolution;
#endif
// Control variables
const float scale_factor = 0.55;
const float squish_factor = 3.0;
const float time_factor = -0.025;
const float dim_factor = 0.2;
vec4 simpleAlphaCompositing (vec4 source, vec4 backdrop) {
float final_alpha = source.a + backdrop.a * (1.0 - source.a);
return vec4(
(source.rgb * source.a + backdrop.rgb * backdrop.a * (1.0 - source.a)) / final_alpha,
final_alpha
);
}
vec4 getColor(vec4 input_color, float speed, float freq, float amp, vec2 uv, float phase_offset) {
#ifdef GLSLVIEWER
float time = u_time;
#endif
float y = uv.y + (time * time_factor * speed);
float d = uv.x - amp * scale_factor * sin(phase_offset + y * squish_factor * freq);
float value = clamp((0.01 / (d * d)) * dim_factor, 0.0, 1.0);
input_color.a = value;
return input_color;
}
void main( void ) {
#ifdef GLSLVIEWER
float time = u_time;
vec2 resolution = u_resolution;
#endif
vec2 uv = (gl_FragCoord.xy * 2. - resolution) / resolution.y;
float tmp_x = uv.x;
float tmp_y = uv.y;
uv.x = tmp_y;
uv.y = tmp_x;
vec4 background = vec4((24.0/255.0), (73.0/255.0), (86.0/255.0), 0.0);
vec4 colors[3];
colors[0] = vec4((250.0/255.0), (87.0/255.0), (80.0/255.0), 0.0);
colors[1] = vec4((117.0/255.0),(185.0/255.0),(56.0/255.0), 0.0);
colors[2] = vec4((70.0/255.0),(149.0/255.0),(247.0/255.0),0.0);
// Relative travel speeds
vec3 speeds = vec3(1.0, 1.2, 0.8);
// Relative frequency
vec3 freqs = vec3(1.0, 1.2, 0.8);
// Relative amplitude
vec3 amps = vec3(1.0, 1.5, 0.5);
// Generate the color maps
for (int i = 0; i < 3; i++) {
colors[i] = getColor(colors[i], speeds[i], freqs[i], amps[i], uv, 0.0);
background.a += colors[i].a;
}
// Mix the colors
background.a = 1.0 - clamp(background.a, 0.0, 1.0);
vec4 color = simpleAlphaCompositing(colors[0], vec4(0.0, 0.0, 0.0, 1.0));
color = simpleAlphaCompositing(colors[1], color);
color = simpleAlphaCompositing(colors[2], color);
vec4 result = simpleAlphaCompositing(background, color);
gl_FragColor = result;
}

View File

@ -44,6 +44,12 @@
subpixel = "rgb";
};
};
startup = [
# GLPaper
{ command = "glpaper DP-1 ${../custom-files/sway/selen.frag} --fork"; }
{ command = "glpaper DP-3 ${../custom-files/sway/selen.frag} --fork"; }
{ command = "glpaper HDMI-A-1 ${../custom-files/sway/selen.frag} --fork"; }
];
};
# Mako output configuration
programs.mako = {

View File

@ -148,11 +148,14 @@
# Clpy entire output to clipboard
"${modifer}+Alt+x" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy output";
};
# Startup applications
startup = [
# Albert, the launcher
{ command = "albert"; }
# Mako, the notification daemon
{ command = "mako"; }
];
};
extraConfig = ''
exec albert
exec mako
'';
};
# Mako for notifications
programs.mako = {