Initial Commit, move from a symlink farm to yadm

This commit is contained in:
2024-05-14 16:41:00 +02:00
commit 957a4eb474
210 changed files with 29165 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#version 330
in vec2 texcoord;
uniform float opacity;
uniform bool invert_color;
uniform sampler2D tex;
vec4 window_shader() {
vec4 c = texelFetch(tex, ivec2(texcoord), 0);
{
// Change vec4(1.0, 1.0, 1.0, 1.0) to your desired color
vec4 vdiff = abs(vec4(0.0, 0.0, 0.0, 1.0) - c);
float diff = max(max(max(vdiff.r, vdiff.g), vdiff.b), vdiff.a);
// Change 0.8 to your desired opacity
if (diff < 0.001)
c *= 0;
}
if (invert_color)
c = vec4(vec3(c.a, c.a, c.a) - vec3(c), c.a);
c *= opacity;
vec4 default_post_processing(vec4 c);
return c;
}

View File

@@ -0,0 +1,65 @@
// The Nord colorscheme is used by default,
// but you can make your own by changing `colors`
uniform float opacity;
uniform float time;
uniform bool invert_color;
uniform sampler2D tex;
float sin_rand() {
return sin(gl_FragCoord.x + cos(gl_FragCoord.y));
}
float random(float seedChange) {
vec2 seed = gl_FragCoord.xy + sin(seedChange);
return fract(dot(vec2(sin(mod(seed.x / cos(seed.y), 5.0) * 10000.0)), vec2(1.1, 12.2)));
}
void main() {
vec4 c = texture2D(tex, gl_TexCoord[0].xy);
vec4 d = c;
vec3 colors[16];
colors[0 ] = vec3(0.286,0.302,0.392);
colors[1 ] = vec3(0.929,0.529,0.588);
colors[2 ] = vec3(0.651,0.855,0.584);
colors[3 ] = vec3(0.933,0.831,0.624);
colors[4 ] = vec3(0.541,0.678,0.957);
colors[5 ] = vec3(0.961,0.741,0.902);
colors[6 ] = vec3(0.545,0.835,0.792);
colors[7 ] = vec3(0.722,0.753,0.878);
colors[8 ] = vec3(0.357,0.376,0.471);
colors[9 ] = vec3(0.926,0.529,0.588);
colors[10] = vec3(0.651,0.855,0.584);
colors[11] = vec3(0.933,0.831,0.624);
colors[12] = vec3(0.541,0.678,0.957);
colors[13] = vec3(0.961,0.741,0.902);
colors[14] = vec3(0.545,0.835,0.792);
colors[15] = vec3(0.647,0.678,0.796);
float mindist = 100.0;
int minind = 0;
float mindist2 = 100.0;
int minind2 = 0;
for (int i = 0; i < 16; i++) {
float dist = length(c.xyz - colors[i]);
if (dist < mindist) {
mindist2 = mindist;
mindist = dist;
minind2 = minind;
minind = i;
}
}
float ratio = mindist / (mindist + mindist2);
float r = random(1.0) * 0.4 + 0.25;
if (r > ratio)
c.xyz = colors[minind];
else
c.xyz = colors[minind2];
c.xyz = mix(mix(colors[minind], colors[minind2], ratio), c.xyz, 0.5);
if (invert_color)
c = vec4(vec3(c.a, c.a, c.a) - vec3(c), c.a);
c *= opacity;
gl_FragColor = vec4(c);
}

View File

@@ -0,0 +1,22 @@
#version 330
in vec2 texcoord;
uniform float opacity;
uniform bool invert_color;
uniform sampler2D tex;
vec4 window_shader() {
vec4 c = texelFetch(tex, ivec2(texcoord), 0);
{
// Change vec4(1.0, 1.0, 1.0, 1.0) to your desired color
vec4 vdiff = abs(vec4(0.0, 0.0, 0.0, 1.0) - c);
float diff = max(max(max(vdiff.r, vdiff.g), vdiff.b), vdiff.a);
// Change 0.8 to your desired opacity
if (diff < 0.001)
c *= 0;
}
if (invert_color)
c = vec4(vec3(c.a, c.a, c.a) - vec3(c), c.a);
c *= opacity;
vec4 default_post_processing(vec4 c);
return c;
}

View File

@@ -0,0 +1,65 @@
// The Nord colorscheme is used by default,
// but you can make your own by changing `colors`
uniform float opacity;
uniform float time;
uniform bool invert_color;
uniform sampler2D tex;
float sin_rand() {
return sin(gl_FragCoord.x + cos(gl_FragCoord.y));
}
float random(float seedChange) {
vec2 seed = gl_FragCoord.xy + sin(seedChange);
return fract(dot(vec2(sin(mod(seed.x / cos(seed.y), 5.0) * 10000.0)), vec2(1.1, 12.2)));
}
void main() {
vec4 c = texture2D(tex, gl_TexCoord[0].xy);
vec4 d = c;
vec3 colors[16];
colors[0 ] = vec3(0.18 ,0.204,0.251);
colors[1 ] = vec3(0.231,0.259,0.322);
colors[2 ] = vec3(0.263,0.298,0.369);
colors[3 ] = vec3(0.298,0.337,0.416);
colors[4 ] = vec3(0.847,0.871,0.914);
colors[5 ] = vec3(0.898,0.914,0.941);
colors[6 ] = vec3(0.925,0.937,0.957);
colors[7 ] = vec3(0.561,0.737,0.733);
colors[8 ] = vec3(0.533,0.753,0.816);
colors[9 ] = vec3(0.506,0.631,0.757);
colors[10] = vec3(0.369,0.506,0.675);
colors[11] = vec3(0.749,0.38 ,0.416);
colors[12] = vec3(0.816,0.529,0.439);
colors[13] = vec3(0.922,0.796,0.545);
colors[14] = vec3(0.639,0.745,0.549);
colors[15] = vec3(0.706,0.557,0.678);
float mindist = 100.0;
int minind = 0;
float mindist2 = 100.0;
int minind2 = 0;
for (int i = 0; i < 16; i++) {
float dist = length(c.xyz - colors[i]);
if (dist < mindist) {
mindist2 = mindist;
mindist = dist;
minind2 = minind;
minind = i;
}
}
float ratio = mindist / (mindist + mindist2);
float r = random(1.0) * 0.4 + 0.25;
if (r > ratio)
c.xyz = colors[minind];
else
c.xyz = colors[minind2];
c.xyz = mix(mix(colors[minind], colors[minind2], ratio), c.xyz, 0.5);
if (invert_color)
c = vec4(vec3(c.a, c.a, c.a) - vec3(c), c.a);
c *= opacity;
gl_FragColor = vec4(c);
}

392
.config/picom/picom.conf Normal file
View File

@@ -0,0 +1,392 @@
#################################
# Shadows #
#################################
# Enabled client-side shadows on windows. Note desktop windows
# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow,
# unless explicitly requested using the wintypes option.
shadow = true;
# The blur radius for shadows, in pixels. (defaults to 12)
shadow-radius = 5;
# The opacity of shadows. (0.0 - 1.0, defaults to 0.75)
shadow-opacity = .3
# The left offset for shadows, in pixels. (defaults to -15)
shadow-offset-x = 2;
# The top offset for shadows, in pixels. (defaults to -15)
shadow-offset-y = 2;
# Hex string color value of shadow (#000000 - #FFFFFF, defaults to #000000).
# shadow-color = "#000000"
# Specify a list of conditions of windows that should have no shadow.
shadow-exclude = [
"name = 'Notification'",
"class_g = 'polybar'",
"class_g = 'Conky'",
"class_g ?= 'Notify-osd'",
"class_g = 'Cairo-clock'",
"_GTK_FRAME_EXTENTS@:c",
# workaround for conky until it provides window properties:
"override_redirect = 1 && !WM_CLASS@:s",
"class_g ?= 'Dmenu'",
"class_g ?= 'Dunst'",
# disable shadows for hidden windows:
"_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'",
"_GTK_FRAME_EXTENTS@:c",
# disables shadows on sticky windows:
"_NET_WM_STATE@:32a *= '_NET_WM_STATE_STICKY'",
# disables shadows on i3 frames
"class_g ?= 'i3-frame'",
"class_g = 'Rofi'",
"class_g = 'Bspwm'",
"class_g ?= 'ulauncher'"
];
# Specify a X geometry that describes the region in which shadow should not
# be painted in, such as a dock window region. Use
# shadow-exclude-reg = "x10+0+0"
# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on.
#
# shadow-exclude-reg = ""
# Crop shadow of a window fully on a particular Xinerama screen to the screen.
# xinerama-shadow-crop = false
#################################
# Fading #
#################################
# Fade windows in/out when opening/closing and when opacity changes,
# unless no-fading-openclose is used.
fading = true;
# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028)
fade-in-step = 0.08;
# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03)
# fade-out-step = 0.03
fade-out-step = 0.05;
# The time between steps in fade step, in milliseconds. (> 0, defaults to 10)
# fade-delta = 10
# Specify a list of conditions of windows that should not be faded.
# fade-exclude = []
# Do not fade on window open/close.
# no-fading-openclose = false
# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc.
# no-fading-destroyed-argb = false
#################################
# Transparency / Opacity #
#################################
# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0)
#inactive-opacity = 0.5
# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default)
# frame-opacity = 1.0
# Let inactive opacity set by -i override the '_NET_WM_OPACITY' values of windows.
# inactive-opacity-override = true
inactive-opacity-override = false;
# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0)
#active-opacity = 1.0
# Dim inactive windows. (0.0 - 1.0, defaults to 0.0)
# inactive-dim = 0.0
# Specify a list of conditions of windows that should always be considered focused.
# focus-exclude = []
focus-exclude = [ "class_g = 'Cairo-clock'" ];
# Use fixed inactive dim value, instead of adjusting according to window opacity.
# inactive-dim-fixed = 1.0
# Specify a list of opacity rules, in the format `PERCENT:PATTERN`,
# like `50:name *= "Firefox"`. picom-trans is recommended over this.
# Note we don't make any guarantee about possible conflicts with other
# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows.
# example:
# opacity-rule = [ "80:class_g = 'URxvt'" ];
#
# opacity-rule = []
#################################
# Corners #
#################################
# Sets the radius of rounded window corners. When > 0, the compositor will
# round the corners of windows. Does not interact well with
# `transparent-clipping`.
corner-radius = 9
# Exclude conditions for rounded corners.
rounded-corners-exclude = [
"window_type = 'dock'",
"window_type = 'desktop'",
"class_g = 'Dunst'"
];
#################################
# Background-Blurring #
#################################
blur: {
method = "dual_kawase";
strength = 12;
background = false;
background-frame = false;
background-fixed = false;
}
# Specify the blur convolution kernel, with the following format:
# example:
# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1";
#
# blur-kern = ""
blur-kern = "3x3box";
opacity-rule = [
"85:class_g = 'Code'",
"88:class_g = 'discord'",
]
# Exclude conditions for background blur.
# blur-background-exclude = []
#blur-background-exclude = [
# "window_type = 'dock'",
# "window_type = 'desktop'",
# "_GTK_FRAME_EXTENTS@:c"
#];
#################################
# General Settings #
#################################
# Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers.
# daemon = false
# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`.
# `xrender` is the default one.
#
backend = "glx"
# Enable/disable VSync.
vsync = true;
# Enable remote control via D-Bus. See the *D-BUS API* section below for more details.
# dbus = false
# Try to detect WM windows (a non-override-redirect window with no
# child that has 'WM_STATE') and mark them as active.
#
# mark-wmwin-focused = false
mark-wmwin-focused = true;
# Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused.
# mark-ovredir-focused = false
mark-ovredir-focused = true;
# Try to detect windows with rounded corners and don't consider them
# shaped windows. The accuracy is not very high, unfortunately.
#
detect-rounded-corners = true;
# Detect '_NET_WM_OPACITY' on client windows, useful for window managers
# not passing '_NET_WM_OPACITY' of client windows to frame windows.
#
detect-client-opacity = true;
# Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window,
# rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy,
# provided that the WM supports it.
#
# use-ewmh-active-win = false
# Unredirect all windows if a full-screen opaque window is detected,
# to maximize performance for full-screen windows. Known to cause flickering
# when redirecting/unredirecting windows.
#
unredir-if-possible = false
# Delay before unredirecting the window, in milliseconds. Defaults to 0.
# unredir-if-possible-delay = 0
# Conditions of windows that shouldn't be considered full-screen for unredirecting screen.
# unredir-if-possible-exclude = []
# Use 'WM_TRANSIENT_FOR' to group windows, and consider windows
# in the same group focused at the same time.
#
detect-transient = true;
# Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same
# group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if
# detect-transient is enabled, too.
#
detect-client-leader = true;
# Resize damaged region by a specific number of pixels.
# A positive value enlarges it while a negative one shrinks it.
# If the value is positive, those additional pixels will not be actually painted
# to screen, only used in blur calculation, and such. (Due to technical limitations,
# with use-damage, those pixels will still be incorrectly painted to screen.)
# Primarily used to fix the line corruption issues of blur,
# in which case you should use the blur radius value here
# (e.g. with a 3x3 kernel, you should use `--resize-damage 1`,
# with a 5x5 one you use `--resize-damage 2`, and so on).
# May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly.
#
# resize-damage = 1
# Specify a list of conditions of windows that should be painted with inverted color.
# Resource-hogging, and is not well tested.
#
# invert-color-include = []
# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer.
# Might cause incorrect opacity when rendering transparent content (but never
# practically happened) and may not work with blur-background.
# My tests show a 15% performance boost. Recommended.
#
# glx-no-stencil = false
# GLX backend: Avoid rebinding pixmap on window damage.
# Probably could improve performance on rapid window content changes,
# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.).
# Recommended if it works.
#
# glx-no-rebind-pixmap = false
# Disable the use of damage information.
# This cause the whole screen to be redrawn everytime, instead of the part of the screen
# has actually changed. Potentially degrades the performance, but might fix some artifacts.
# The opposing option is use-damage
#
# no-use-damage = false
use-damage = true;
# Use X Sync fence to sync clients' draw calls, to make sure all draw
# calls are finished before picom starts drawing. Needed on nvidia-drivers
# with GLX backend for some users.
#
# xrender-sync-fence = false
# GLX backend: Use specified GLSL fragment shader for rendering window contents.
# See `compton-default-fshader-win.glsl` and `compton-fake-transparency-fshader-win.glsl`
# in the source tree for examples.
#
# glx-fshader-win = ""
# Use rules to set per-window shaders. Syntax is SHADER_PATH:PATTERN, similar
# to opacity-rule. SHADER_PATH can be "default". This overrides window-shader-fg.
#
window-shader-fg-rule = [
"black_to_transparent.frag:class_g = 'stalonetray'",
"black_to_transparent.frag:class_g = 'Minecraft 1.7.10'",
"black_to_transparent.frag:focused = true",
"black_to_transparent.frag:focused != true",
#"sphere.glsl:focused != true"
#"nordify.glsl:class_g = 'miru'"
]
# Force all windows to be painted with blending. Useful if you
# have a glx-fshader-win that could turn opaque pixels transparent.
#
# force-win-blend = false
# Do not use EWMH to detect fullscreen windows.
# Reverts to checking if a window is fullscreen based only on its size and coordinates.
#
# no-ewmh-fullscreen = false
# Dimming bright windows so their brightness doesn't exceed this set value.
# Brightness of a window is estimated by averaging all pixels in the window,
# so this could comes with a performance hit.
# Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0)
#
# max-brightness = 1.0
# Make transparent windows clip other windows like non-transparent windows do,
# instead of blending on top of them.
#
# transparent-clipping = false
# Set the log level. Possible values are:
# "trace", "debug", "info", "warn", "error"
# in increasing level of importance. Case doesn't matter.
# If using the "TRACE" log level, it's better to log into a file
# using *--log-file*, since it can generate a huge stream of logs.
#
# log-level = "debug"
log-level = "warn";
# Set the log file.
# If *--log-file* is never specified, logs will be written to stderr.
# Otherwise, logs will to written to the given file, though some of the early
# logs might still be written to the stderr.
# When setting this option from the config file, it is recommended to use an absolute path.
#
# log-file = "/path/to/your/log/file"
# Show all X errors (for debugging)
# show-all-xerrors = false
# Write process ID to a file.
# write-pid-path = "/path/to/your/log/file"
# Window type settings
#
# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard:
# "unknown", "desktop", "dock", "toolbar", "menu", "utility",
# "splash", "dialog", "normal", "dropdown_menu", "popup_menu",
# "tooltip", "notification", "combo", and "dnd".
#
# Following per window-type options are available: ::
#
# fade, shadow:::
# Controls window-type-specific shadow and fade settings.
#
# opacity:::
# Controls default opacity of the window type.
#
# focus:::
# Controls whether the window of this type is to be always considered focused.
# (By default, all window types except "normal" and "dialog" has this on.)
#
# full-shadow:::
# Controls whether shadow is drawn under the parts of the window that you
# normally won't be able to see. Useful when the window has parts of it
# transparent, and you want shadows in those areas.
#
# redir-ignore:::
# Controls whether this type of windows should cause screen to become
# redirected again after been unredirected. If you have unredir-if-possible
# set, and doesn't want certain window to cause unnecessary screen redirection,
# you can set this to `true`.
#
wintypes:
{
tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; };
dock = { shadow = false; }
dnd = { shadow = false; }
popup_menu = { opacity = 0.8; }
dropdown_menu = { opacity = 0.8; }
};

372
.config/picom/sphere.glsl Normal file
View File

@@ -0,0 +1,372 @@
#version 430
#define PI 3.14159265
// These shaders work by using a pinhole camera and raycasting
// The window 3d objects will always be (somewhat) centered at (0, 0, 0)
struct pinhole_camera
{
float focal_offset; // Distance along the Z axis between the camera
// center and the focal point. Use negative values
// so the image doesn't flip
// This kinda works like FOV in games
// Transformations
// Use these to modify the coordinate system of the camera plane
vec3 rotations; // Rotations in radians around each axis
// The camera plane rotates around
// its center point, not the origin
vec3 translations; // Translations in pixels along each axis
vec3 deformations; // Deforms the camera. Higher values on each axis
// means the window will be squashed in that axis
// ---------------------------------------------------------------//
// "Aftervalues"
// These will be set later with setup_camera(), leave them as 0
vec3 base_x;
vec3 base_y;
vec3 base_z;
vec3 center_point;
vec3 focal_point;
};
in vec2 texcoord; // texture coordinate of the fragment
uniform sampler2D tex; // texture of the window
uniform float time; // Time in miliseconds.
float time_cyclic = mod(time/10000,2); // Like time, but in seconds and resets to
// 0 when it hits 2. Useful for using it in
// periodic functions like cos and sine
// Time variables can be used to change transformations over time
ivec2 window_size = textureSize(tex, 0); // Size of the window
float window_diagonal = length(window_size); // Diagonal of the window
//
int wss = min(window_size.x, window_size.y); // Window smallest side, useful when squaring windows
// Try to keep focal offset and translations proportional to window_size components
// or window_diagonal as you see fit
pinhole_camera camera =
pinhole_camera(-window_size.y/2, // Focal offset
vec3(0,0,0), // Rotations
vec3(0,0,0), // Translations
vec3(1,1,1), // Deformations
// Leave the rest as 0
vec3(0),
vec3(0),
vec3(0),
vec3(0),
vec3(0));
// Here are some presets you can use
// Moves the camera up and down
pinhole_camera bobbing =
pinhole_camera(-window_size.y/2,
vec3(0,0,0),
vec3(0,cos(time_cyclic*PI)*window_size.y/16,-window_size.y/4),
vec3(1,1,1),
vec3(0),
vec3(0),
vec3(0),
vec3(0),
vec3(0));
// Rotates camera around the origin
// Makes the window rotate around the Y axis from the camera's POV
// (if the window is centered)
pinhole_camera rotate_around_origin =
pinhole_camera(-wss,
vec3(PI/6*sin(2*time_cyclic*PI),-time_cyclic*PI-PI/2,0),
vec3(cos(time_cyclic*PI)*wss,
wss/2*sin(2*time_cyclic*PI),
sin(time_cyclic*PI)*wss),
vec3(1,1,1),
vec3(0),
vec3(0),
vec3(0),
vec3(0),
vec3(0));
// Rotate camera around its center
pinhole_camera rotate_around_itself =
pinhole_camera(-wss,
vec3(0,-time_cyclic*PI-PI/2,0),
vec3(0,0,-wss),
vec3(1,1,1),
vec3(0),
vec3(0),
vec3(0),
vec3(0),
vec3(0));
// Here you can select the preset to use
pinhole_camera window_cam = rotate_around_origin;
ivec2 window_center = ivec2(window_size.x/2, window_size.y/2);
// Default window post-processing:
// 1) invert color
// 2) opacity / transparency
// 3) max-brightness clamping
// 4) rounded corners
vec4 default_post_processing(vec4 c);
// Sets up a camera by applying transformations and
// calculating xyz vector basis
pinhole_camera setup_camera(pinhole_camera camera)
{
// Apply translations
camera.center_point += camera.translations;
// Apply rotations
// We initialize our vector basis as normalized vectors
// in each axis * our deformations vector
camera.base_x = vec3(camera.deformations.x, 0, 0);
camera.base_y = vec3(0, camera.deformations.y, 0);
camera.base_z = vec3(0, 0, camera.deformations.z);
// Then we rotate them around following our rotations vector:
// First save these values to avoid redundancy
float cosx = cos(camera.rotations.x);
float cosy = cos(camera.rotations.y);
float cosz = cos(camera.rotations.z);
float sinx = sin(camera.rotations.x);
float siny = sin(camera.rotations.y);
float sinz = sin(camera.rotations.z);
// Declare a buffer vector we will use to apply multiple changes at once
vec3 tmp = vec3(0);
// Rotations for base_x:
tmp = camera.base_x;
// X axis:
tmp.y = camera.base_x.y * cosx - camera.base_x.z * sinx;
tmp.z = camera.base_x.y * sinx + camera.base_x.z * cosx;
camera.base_x = tmp;
// Y axis:
tmp.x = camera.base_x.x * cosy + camera.base_x.z * siny;
tmp.z = -camera.base_x.x * siny + camera.base_x.z * cosy;
camera.base_x = tmp;
// Z axis:
tmp.x = camera.base_x.x * cosz - camera.base_x.y * sinz;
tmp.y = camera.base_x.x * sinz + camera.base_x.y * cosz;
camera.base_x = tmp;
// Rotations for base_y:
tmp = camera.base_y;
// X axis:
tmp.y = camera.base_y.y * cosx - camera.base_y.z * sinx;
tmp.z = camera.base_y.y * sinx + camera.base_y.z * cosx;
camera.base_y = tmp;
// Y axis:
tmp.x = camera.base_y.x * cosy + camera.base_y.z * siny;
tmp.z = -camera.base_y.x * siny + camera.base_y.z * cosy;
camera.base_y = tmp;
// Z axis:
tmp.x = camera.base_y.x * cosz - camera.base_y.y * sinz;
tmp.y = camera.base_y.x * sinz + camera.base_y.y * cosz;
camera.base_y = tmp;
// Rotations for base_z:
tmp = camera.base_z;
// X axis:
tmp.y = camera.base_z.y * cosx - camera.base_z.z * sinx;
tmp.z = camera.base_z.y * sinx + camera.base_z.z * cosx;
camera.base_z = tmp;
// Y axis:
tmp.x = camera.base_z.x * cosy + camera.base_z.z * siny;
tmp.z = -camera.base_z.x * siny + camera.base_z.z * cosy;
camera.base_z = tmp;
// Z axis:
tmp.x = camera.base_z.x * cosz - camera.base_z.y * sinz;
tmp.y = camera.base_z.x * sinz + camera.base_z.y * cosz;
camera.base_z = tmp;
// Now that we have our transformed 3d orthonormal base
// we can calculate our focal point
camera.focal_point = camera.center_point + camera.base_z * camera.focal_offset;
// Return our set up camera
return camera;
}
// Gets a pixel from the end of a ray projected to an axis
vec4 get_pixel_from_projection(float t, pinhole_camera camera, vec3 focal_vector)
{
// If the point we end up in is behind our camera, don't "render" it
if (t < 1)
{
return vec4(0);
}
// Then we multiply our focal vector by t and add our focal point to it
// to end up in a point inside the window plane
vec3 intersection = focal_vector * t + camera.focal_point;
// Save necessary coordinates
vec2 cam_coords = intersection.xy;
// Square window trickery
if (window_size.x > window_size.y)
{
cam_coords.x /= window_size.y/float(window_size.x);
cam_coords.xy += window_center.xy;
}
else if (window_size.x < window_size.y)
{
cam_coords.y /= window_size.x/float(window_size.y);
cam_coords.xy += window_center.xy;
}
// If pixel is outside of our window region
// return a dimmed pixel with the window's border color
if (cam_coords.x >=window_size.x-1 ||
cam_coords.y >=window_size.y-1 ||
cam_coords.x <=0 || cam_coords.y <=0)
{
cam_coords.x = 0;
cam_coords.y = window_center.y;
vec4 pixel = texelFetch(tex, ivec2(cam_coords), 0);
pixel *= 0.5;
return pixel;
}
// Fetch the pixel
vec4 pixel = texelFetch(tex, ivec2(cam_coords), 0);
return pixel;
}
// Combines colors using alpha
// Got this from https://stackoverflow.com/questions/64701745/how-to-blend-colours-with-transparency
// Not sure how it works honestly lol
vec4 alpha_composite(vec4 color1, vec4 color2)
{
float ar = color1.w + color2.w - (color1.w * color2.w);
float asr = color2.w / ar;
float a1 = 1 - asr;
float a2 = asr * (1 - color1.w);
float ab = asr * color1.w;
vec4 outcolor;
outcolor.xyz = color1.xyz * a1 + color2.xyz * a2 + color2.xyz * ab;
outcolor.w = ar;
return outcolor;
}
// Gets a pixel through the camera using coords as coordinates in
// the camera plane
vec4 get_pixel_through_camera(vec2 coords, pinhole_camera camera)
{
// Offset coords
coords -= window_center;
// Find the pixel 3d position using the camera vector basis
vec3 pixel_3dposition = camera.center_point
+ coords.x * camera.base_x
+ coords.y * camera.base_y;
// Get the vector going from the focal point to the pixel in 3d sapace
vec3 focal_vector = pixel_3dposition - camera.focal_point;
// Following the sphere EQ (with Y axis as center)
// x^2 + y^2 + z^2 = r^2
float r = min(window_size.x, window_size.y)/(PI/2);
// Then there's a line going from our focal point to the cylinder
// which we can describe as:
// x(t) = focal_point.x + focal_vector.x * t
// y(t) = focal_point.y + focal_vector.y * t
// z(t) = focal_point.z + focal_vector.z * t
// We substitute x, y and z with x(t) and z(t) in the cylinder EQ
// Solving for t we get a cuadratic EQ which we solve with the
// cuadratic formula:
// We calculate focal vector and focal point values squared
// to avoid redundancy
vec3 fvsqr;
vec3 fpsqr;
fvsqr.x = pow(focal_vector.x,2);
fvsqr.y = pow(focal_vector.y,2);
fvsqr.z = pow(focal_vector.z,2);
fpsqr.x = pow(camera.focal_point.x,2);
fpsqr.y = pow(camera.focal_point.y,2);
fpsqr.z = pow(camera.focal_point.z,2);
// Coeficients of our EQ
float a = fvsqr.x + fvsqr.y + fvsqr.z;
float b = 2*(camera.focal_point.x*focal_vector.x
+camera.focal_point.y*focal_vector.y
+camera.focal_point.z*focal_vector.z);
float c = fpsqr.x + fpsqr.y + fpsqr.z - pow(r,2);
// If there are no real roots, then there's no intersection and we
// return an empty pixel
float formulasqrt = pow(b,2)-4*a*c;
if (formulasqrt < 0)
{
return vec4(0);
}
vec2 t[2]; // A float should be used for this instead, but the shader
// isn't rendered correctly when I use a float
// Cursed, but it works
// Solve with general formula
t[0].x = (-b + sqrt(formulasqrt))/(2*a);
t[1].x = (-b - sqrt(formulasqrt))/(2*a);
t[0].y = 0;
t[1].y = 0;
// Bubble sort to know which intersections happen first
for (int i = 0; i < t.length(); i++)
{
for (int j = 0; j < t.length(); j++)
{
if (t [j].x > t[j+1].x)
{
vec2 tmp = t[j];
t[j] = t[j+1];
t[j+1] = tmp;
}
}
}
// Then we go through each one of the intersections in order
// and mix pixels together using alpha
vec4 blended_pixels = vec4(0);
for (int i = 0; i < t.length(); i++)
{
// We get the pixel through projection
vec4 projection_pixel = get_pixel_from_projection(t[i].x,
camera,
focal_vector);
if (projection_pixel.w > 0.0)
{
// Blend the pixel using alpha
blended_pixels = alpha_composite(projection_pixel, blended_pixels);
}
}
return blended_pixels;
}
// Main function
vec4 window_shader() {
pinhole_camera transformed_cam = setup_camera(window_cam);
return(get_pixel_through_camera(texcoord, transformed_cam));
}

View File

@@ -0,0 +1,33 @@
#version 130
#extension GL_ARB_shading_language_420pack: enable
#define CYCLE 5000 // The amount of miliseconds it takes to do a full "loop" around all the colors.
uniform float opacity;
uniform bool invert_color;
uniform sampler2D tex;
uniform float time;
float get_decimal_part(float f) {
return f - int(f);
}
float snap0(float f) {
return (f < 0) ? 0 : f;
}
void main() {
vec4 c = texture2D(tex, gl_TexCoord[0].xy);
float f = get_decimal_part(time / CYCLE);
gl_FragColor.a = 1;
float p[3] = {
snap0(0.33 - abs(f - 0.33)) * 4,
snap0(0.33 - abs(f - 0.66)) * 4,
snap0(0.33 - abs(f - 1.00)) * 4 + snap0(0.33 - abs(f - 0.0)) * 4
};
gl_FragColor.r = p[0] * c.r + p[1] * c.g + p[2] * c.b;
gl_FragColor.g = p[2] * c.r + p[0] * c.g + p[1] * c.b;
gl_FragColor.b = p[1] * c.r + p[2] * c.g + p[0] * c.b;
}