Created
April 12, 2025 13:21
-
-
Save akella/6cd2fc01862bc8623111486d210d79c7 to your computer and use it in GitHub Desktop.
glitch effect from hatom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec3 addGlitchEffect(vec3 render, vec2 uv, vec4 mouseFluid) { | |
vec2 st = uv; | |
vec2 offset = vec2(0.); | |
float strength = uFluidStrength*0.7-uLetterBox*0.3; | |
addFisheyeEffect(st, strength*0.5); | |
vec2 glitchUv = st*vec2(3., 6.)-uTime*0.01; | |
glitchUv = floor(glitchUv*15.)/15.; | |
glitchUv *= vec2(0.08, 0.1); | |
vec2 glitchUv2 = st*vec2(2., 5.)+uTime*0.03; | |
glitchUv2 = floor(glitchUv2*vec2(10., 15.))/vec2(10., 15.); | |
glitchUv2 *= vec2(0.1, 0.13); | |
vec3 noise = texture2D(tNoise3, glitchUv).rgb; | |
vec3 noise2 = texture2D(tNoise3, glitchUv2).rgb; | |
noise = mix(noise, noise2, step(sin(noise.b*20.), 0.3)); | |
float b = mix(20., 40., noise.g); | |
float a = floor(noise.r*b)/b; | |
offset.x = a-0.5; | |
vec3 firstColor = texture2D(tDiffuse, st).rgb; | |
vec3 hsv = rgb2hsv(firstColor); | |
float t = step(0.4, sin(hsv.b*10.)); | |
t += step(hsv.g, 0.35)+smoothstep(0.6, 0.7, length(uv-0.5+sin(noise.bg*10.-strength)*0.4)); | |
float m = length(floor(((uv-0.5)*vec2(0.7, 2.)+(noise.rg-0.5)*3.)*vec2(11., 30.))/vec2(11., 30.)+sin(uTime+noise2.rg-0.5)*(noise.gb-0.5)*0.5); | |
t *= step(mix(1.2, 1.1, strength), m); | |
t += step((sin(noise2.r*10.+uTime*mix(1.5, -1.5, step(noise2.g, 0.5)))+1.)*2., mix(0., 0.1, step(m, 0.2))); | |
t *= strength; | |
t += mouseFluid.b*0.03*uLetterBox; | |
t += smoothstep(0.7, 0.8, length(uv-0.5+sin(noise.bg*20.-uTime)*0.3))*mix(0.1, 1., step(hsv.g, mix(0.35, 0.3, sin(uTime*4.))))*uLetterBox; | |
vec3 color; | |
color.r = texture2D(tDiffuse, st+offset*t*0.98+0.001*strength).r; | |
color.g = texture2D(tDiffuse, st+offset*t*1.).g; | |
color.b = texture2D(tDiffuse, st+offset*t*1.02-0.001*strength).b; | |
vec3 colorDiff = vec3(color-firstColor); | |
t *= length(step(vec3(0.01), abs(colorDiff))); | |
color = pow(color, vec3(mix(1., 1.2, uLetterBox)))*mix(1., 3., uLetterBox); | |
vec3 luma = vec3(0.299, 0.587, 0.114); | |
float v = dot(color, luma); | |
vec3 glitchColor = color; | |
#ifdef FOCUS_NUM | |
#if FOCUS_NUM == 1 | |
#elif FOCUS_NUM == 2 | |
vec3 color1 = vec3(0.757, 1., 0.071); | |
vec3 color2 = vec3(0.0); | |
glitchColor = mix(color1, color2, step(v, 0.5)); | |
#elif FOCUS_NUM == 3 | |
glitchColor = 1.-rgb2hsv(normalize(color)); | |
#elif FOCUS_NUM == 4 | |
#elif FOCUS_NUM == 5 | |
glitchColor = vec3(rgb2hsv(glitchColor).g); | |
#endif | |
#endif | |
color = mix(color, glitchColor, uLetterBox); | |
color = mix(render, color, t*uFluidStrength); | |
return color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment