ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
vhs.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file vhs.frag
5 * @brief Vulkan fragment shader: vhs.
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/**
27 * @brief Evaluates random for this shader effect.
28 * @param x Input value for the calculation.
29 * @return Computed float value.
30 */
31float random(float x) {
32 return fract(sin(x) * 43758.5453123);
33}
34
35/**
36 * @brief Executes the fragment shader entry point.
37 */
38void main(void) {
39 vec2 uv = tc;
40 float y = uv.y * iResolution.y;
41 float offset = sin(y * 10.0 + time_f * 5.0) * 0.005;
42
43 if (random(y + time_f * 10.0) < 0.1) {
44 offset += (random(y) - 0.5) * 0.02;
45 }
46
47 uv.x += offset;
48 vec4 texColor = texture(samp, uv);
49
50 float r = texture(samp, uv + vec2(0.002, 0.0)).r;
51 float g = texture(samp, uv).g;
52 float b = texture(samp, uv - vec2(0.002, 0.0)).b;
53
54 vec4 compositeColor = vec4(r, g, b, texColor.a);
55
56 vec4 vhsColor = mix(texColor, compositeColor, 0.5);
57
58 vhsColor.rgb = vhsColor.rgb * vec3(0.9, 0.85, 0.8) + vec3(0.1, 0.1, 0.15);
59 vhsColor.rgb = clamp(vhsColor.rgb, 0.0, 1.0);
60
61 color = vhsColor;
62}
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 iResolution
Definition 3high.frag:18
#define time_f
Definition 3high.frag:19
float random(vec2 st)
Evaluates random for this shader effect.