ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
glitchf.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file glitchf.frag
5 * @brief Vulkan fragment shader: glitchf.
6 */
7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
8 vec4 mouse;
9 vec4 u0;
10 vec4 u1;
11 vec4 u2;
12 vec4 u3;
13 vec4 custom_uniforms[16];
14 vec4 audio_bands;
15 vec4 audio_history;
17#define iResolution ext.u0.zw
18#define time_f ext.u2.y
19
20layout(location = 0) in vec2 tc;
21layout(location = 0) out vec4 color;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates random for this shader effect.
28 * @param co Input value for the calculation.
29 * @return Computed float value.
30 */
31float random(vec2 co) {
32 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
33}
34
35/**
36 * @brief Executes the fragment shader entry point.
37 */
38void main() {
39 vec2 uv = tc;
40
41 float glitchStrength = 0.05 + 0.03 * sin(time_f * 3.0);
42 float glitchLine = step(0.5 + 0.1 * sin(time_f * 10.0), fract(uv.y * 10.0 + time_f * 5.0));
43 float displacement = glitchStrength * (random(uv + time_f) - 0.5);
44
45 vec2 distortedUV = uv;
46 distortedUV.x += displacement * glitchLine;
47
48 vec4 texColor = texture(samp, distortedUV);
49
50 vec2 offset = vec2(0.01 * sin(time_f * 15.0), 0.01 * cos(time_f * 10.0));
51 vec3 glitchRGB = vec3(
52 texture(samp, distortedUV + vec2(offset.x, 0.0)).r,
53 texture(samp, distortedUV + vec2(-offset.x, offset.y)).g,
54 texture(samp, distortedUV + vec2(0.0, -offset.y)).b
55 );
56
57 float strobe = step(0.5, fract(time_f * 10.0)) * 0.2;
58
59 color = vec4(mix(texColor.rgb, glitchRGB, glitchLine + strobe), texColor.a);
60}
61
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
ext
Definition 3high.frag:16
void main(void)
Executes the fragment shader entry point.
Definition 3high.frag:47
#define time_f
Definition 3high.frag:19
float random(vec2 st)
Evaluates random for this shader effect.