Skip to content

Commit

Permalink
color glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
lostjared committed Jun 28, 2024
1 parent 1354465 commit dc400f5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 14 deletions.
62 changes: 62 additions & 0 deletions filters/color_glitch_dark.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#version 330

in vec2 tc;
out vec4 color;
uniform sampler2D samp;
uniform float time_f;
uniform vec2 iResolution;

vec3 rgb2hsb(vec3 c) {
vec4 K = vec4(0.0, -1.0/3.0, 2.0/3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsb2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0/3.0, 1.0/3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

vec4 xor_RGB(vec4 icolor, vec4 source) {
ivec3 int_color;
ivec4 isource = ivec4(source * 255);
for(int i = 0; i < 3; ++i) {
int_color[i] = int(255 * icolor[i]);
int_color[i] = int_color[i]^isource[i];
if(int_color[i] > 255)
int_color[i] = int_color[i]%255;
icolor[i] = float(int_color[i])/255;
}
return icolor;
}


void main() {
vec2 uv = tc;
vec4 texColor = texture(samp, uv);
vec2 texelSize = 1.0 / iResolution;
vec3 result = vec3(0.0);
float weight[5];
weight[0] = 0.227027;
weight[1] = 0.1945946;
weight[2] = 0.1216216;
weight[3] = 0.054054;
weight[4] = 0.016216;
for (int i = -4; i <= 4; i++) {
result += texture(samp, uv + vec2(float(i) * texelSize.x, 0.0)).rgb * weight[abs(i)];
}
for (int j = -4; j <= 4; j++) {
result += texture(samp, uv + vec2(0.0, float(j) * texelSize.y)).rgb * weight[abs(j)];
}
vec3 hsb = rgb2hsb(result / 2.0);
hsb.x += time_f * 0.1;
hsb.y = 0.5;
hsb.z = 0.9;
vec3 rgb = hsb2rgb(hsb);
color = vec4(rgb * 0.8 + 0.2, texColor.a);
color = xor_RGB(sin(color * time_f) + 0.5, texture(samp, tc));
}
1 change: 1 addition & 0 deletions filters/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,4 @@ rainbow_cd_strobe.glsl
rainbow_cd_spin.glsl
rainbow_cd_curtain.glsl
pastel.glsl
color_glitch_dark.glsl
18 changes: 4 additions & 14 deletions filters/pastel.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,24 @@ vec3 hsb2rgb(vec3 c) {
void main() {
vec2 uv = tc;
vec4 texColor = texture(samp, uv);

vec2 texelSize = 1.0 / iResolution;
vec3 result = vec3(0.0);

// Gaussian blur kernel weights
float weight[5];
weight[0] = 0.227027;
weight[1] = 0.1945946;
weight[2] = 0.1216216;
weight[3] = 0.054054;
weight[4] = 0.016216;

// Apply Gaussian blur horizontally
for (int i = -4; i <= 4; i++) {
result += texture(samp, uv + vec2(float(i) * texelSize.x, 0.0)).rgb * weight[abs(i)];
}

// Apply Gaussian blur vertically
for (int j = -4; j <= 4; j++) {
result += texture(samp, uv + vec2(0.0, float(j) * texelSize.y)).rgb * weight[abs(j)];
}

vec3 hsb = rgb2hsb(result / 2.0); // Adjusted for combining horizontal and vertical blur
hsb.x += time_f * 0.1; // Shift hue over time
hsb.y = 0.5; // Reduce saturation for pastel effect
hsb.z = 0.9; // Increase brightness for pastel effect

vec3 hsb = rgb2hsb(result / 2.0);
hsb.x += time_f * 0.1;
hsb.y = 0.5;
hsb.z = 0.9;
vec3 rgb = hsb2rgb(hsb);

color = vec4(rgb, texColor.a);
}

0 comments on commit dc400f5

Please sign in to comment.