ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
damaged_vcr.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file damaged_vcr.frag
5 * @brief Vulkan fragment shader: damaged vcr.
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) out vec4 color;
21layout(location = 0) in vec2 tc;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26// Random functions for chaos
27/**
28 * @brief Evaluates rand for this shader effect.
29 * @param co Input value for the calculation.
30 * @return Computed float value.
31 */
32float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453); }
33/**
34 * @brief Evaluates rand1 for this shader effect.
35 * @param x Input value for the calculation.
36 * @return Computed float value.
37 */
38float rand1(float x) { return fract(sin(x) * 43758.5453); } // Fixed name collision
39
40/**
41 * @brief Evaluates brutalColorDistortion for this shader effect.
42 * @param col Input value for the calculation.
43 * @param uv Input value for the calculation.
44 * @param t Input value for the calculation.
45 * @return Computed vec3 value.
46 */
47vec3 brutalColorDistortion(vec3 col, vec2 uv, float t) {
48 // Channel separation madness
49 col.r = texture(samp, uv + vec2(sin(t*0.7)*0.03, cos(t*0.3)*0.02)).r;
50 col.g = texture(samp, uv + vec2(sin(t*0.5)*0.02, cos(t*0.4)*0.03)).g;
51 col.b = texture(samp, uv + vec2(sin(t*0.9)*0.04, cos(t*0.6)*0.01)).b;
52
53 // Random color channel swaps
54 if (mod(t, 3.0) > 2.0) col = col.bgr;
55 if (mod(t*0.7, 2.0) > 1.3) col = col.grb;
56
57 return col;
58}
59
60/**
61 * @brief Executes the fragment shader entry point.
62 */
63void main(void) {
64 vec2 uv = tc;
65 float t = time_f * 3.0;
66
67 // Extreme geometric distortion
68 uv.x += sin(uv.y * 50.0 + t * 10.0) * 0.1 * rand1(t);
69 uv.y += cos(uv.x * 40.0 + t * 8.0) * 0.08 * rand1(t+0.3);
70
71 // Tape stretch apocalypse
72 uv.x += sin(t * 5.0 + uv.y * 50.0) * 0.05;
73 uv.y += cos(t * 3.0 + uv.x * 60.0) * 0.03;
74
75 // Violent vertical/horizontal jitter
76 uv += vec2(rand1(t) - 0.5, rand1(t+0.5) - 0.5) * 0.1;
77
78 // CRT curvature distortion
79 vec2 crtUV = uv * 2.0 - 1.0;
80 crtUV *= 1.0 + pow(length(crtUV), 3.0) * 0.5;
81 uv = crtUV * 0.5 + 0.5;
82
83 // Severe tracking errors (split screen)
84 float split = step(0.5 + sin(t)*0.2, uv.x);
85 uv.y += split * (sin(t*2.0) * 0.1 * rand1(t));
86
87 // Burning VCR head effect
88 float scanLine = fract(t * 0.3);
89 if(abs(uv.y - scanLine) < 0.02) {
90 uv.x += (rand1(uv.y + t) - 0.5) * 0.3;
91 uv.y += sin(uv.x * 100.0) * 0.1;
92 }
93
94 // Total chromatic breakdown (FIXED texture sampling)
95 vec3 col = brutalColorDistortion(texture(samp, uv).rgb, uv, t);
96
97 // Tape damage zones (FIXED missing parenthesis)
98 float damageZone = step(0.9, rand(vec2(floor(uv.y * 20.0 + t * 0.5))));
99 col = mix(col, vec3(0.0), damageZone * 0.7);
100
101 // Static electricity bursts
102 float staticFlash = step(0.997, rand1(t * 0.1));
103 col += vec3(staticFlash * 2.0);
104
105 // Magnetic interference waves
106 col *= 0.7 + 0.3 * sin(uv.x * 300.0 + t * 10.0);
107
108 // Extreme noise pollution
109 vec3 noise = vec3(rand(uv * t), rand(uv * t + 0.3), rand(uv * t + 0.7)) * 0.8;
110 col += noise * smoothstep(0.3, 0.7, rand1(t * 0.3));
111
112 // Tape crease distortion
113 float crease = sin(uv.y * 30.0 + t * 5.0) * 0.1;
114 col *= 1.0 - smoothstep(0.3, 0.7, abs(crease));
115
116 // Overload red channel
117 col.r += sin(t * 5.0) * 0.3 + rand1(uv.x) * 0.2;
118
119 // VCR menu burn-through
120 float osd = step(0.98, rand1(uv.x * 10.0 + t * 0.1));
121 col = mix(col, vec3(0.0, 1.0, 0.0), osd * 0.3);
122
123 // Final output with scanline darkness
124 color = vec4(col, 1.0);
125 color *= 0.8 + 0.2 * sin(uv.y * 800.0 + t * 10.0);
126
127 // Add random full-screen flicker
128 color *= 0.7 + 0.3 * rand1(t * 0.1);
129
130 // Edge collapse
131 color *= smoothstep(0.0, 0.2, uv.y) * smoothstep(1.0, 0.8, uv.y);
132 color *= smoothstep(0.0, 0.1, uv.x) * smoothstep(1.0, 0.9, uv.x);
133}
float rand(vec2 co)
Evaluates rand for this shader effect.
Definition 3high.frag:40
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 noise(vec2 p)
Evaluates noise for this shader effect.
float rand1(float x)
Evaluates rand1 for this shader effect.
vec3 brutalColorDistortion(vec3 col, vec2 uv, float t)
Evaluates brutalColorDistortion for this shader effect.