ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
composite_vhs.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file composite_vhs.frag
5 * @brief Vulkan fragment shader: composite 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 rand for this shader effect.
28 * @param p Input value for the calculation.
29 * @return Computed float value.
30 */
31float rand(vec2 p) {
32 return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
33}
34
35/**
36 * @brief Evaluates compositeEffect for this shader effect.
37 * @param uv Input value for the calculation.
38 * @return Computed vec3 value.
39 */
40vec3 compositeEffect(vec2 uv) {
41 vec2 cuv = uv * 2.0 - 1.0;
42 float r2 = dot(cuv, cuv);
43 cuv *= 1.0 + 0.25 * r2;
44 uv = cuv * 0.5 + 0.5;
45
46 float vJitter = (rand(vec2(time_f * 3.17, 0.0)) - 0.5) * 0.01;
47 uv.y = clamp(uv.y + vJitter, 0.0, 1.0);
48
49 uv.x += sin(uv.y * 180.0 + time_f * 4.0) * 0.002;
50
51 float lineDrift = sin(time_f * 0.7) * 0.01;
52 uv.y = clamp(uv.y + lineDrift, 0.0, 1.0);
53
54 vec2 uvR = uv + vec2(0.0025, 0.0);
55 vec2 uvB = uv - vec2(0.0025, 0.0);
56
57 vec3 srcR = texture(samp, uvR).rgb;
58 vec3 srcG = texture(samp, uv).rgb;
59 vec3 srcB = texture(samp, uvB).rgb;
60
61 vec3 col;
62 col.r = srcR.r;
63 col.g = srcG.g;
64 col.b = srcB.b;
65
66 vec3 ghost = texture(samp, uv + vec2(0.006, 0.0)).rgb;
67 col = mix(col, ghost, 0.15);
68
69 float scanline = 0.7 + 0.3 * sin(uv.y * iResolution.y * 3.14159);
70 col *= scanline;
71
72 float fineNoise = rand(uv * iResolution.xy + time_f * 37.0);
73 float coarseNoise = rand(vec2(0.0, floor(uv.y * iResolution.y * 0.5) + time_f * 5.0));
74 float noise = fineNoise * 0.04 + coarseNoise * 0.06;
75 col += noise;
76
77 float band = step(0.97, fract(uv.y * 80.0 + time_f * 0.5));
78 col *= 1.0 - band * 0.5;
79
80 float dist = distance(uv, vec2(0.5));
81 float vignette = clamp(1.0 - dist * 1.4, 0.0, 1.0);
82 col *= vignette;
83
84 col = pow(col, vec3(0.85));
85
86 return col;
87}
88
89/**
90 * @brief Executes the fragment shader entry point.
91 */
92void main(void) {
93 vec2 uv = tc;
94 vec3 col = compositeEffect(uv);
95 color = vec4(col, 1.0);
96}
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 iResolution
Definition 3high.frag:18
#define time_f
Definition 3high.frag:19
float noise(vec2 p)
Evaluates noise for this shader effect.
vec3 compositeEffect(vec2 uv)
Evaluates compositeEffect for this shader effect.
Definition comp_inc.frag:31
float scanline(vec2 uv)
Evaluates scanline for this shader effect.