ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_cache_spectrum8_tremor_storm.frag
Go to the documentation of this file.
1#version 450
2
3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
4 vec4 mouse;
5 vec4 u0;
6 vec4 u1;
7 vec4 u2;
8 vec4 u3;
9 vec4 custom_uniforms[16];
10 vec4 audio_bands;
11 vec4 audio_history;
13#define amp_peak ext.u2.w
14#define amp_smooth ext.u3.w
15#define history_head int(ext.u3.x)
16#define iResolution ext.u0.zw
17#define iTime ext.u0.y
18#define spectrum_history_head int(ext.audio_history.x)
19#define spectrum_history_size int(ext.audio_history.y)
20
21/**
22 * @file ant_cache_spectrum8_tremor_storm.frag
23 * @brief Vulkan fragment shader: ant cache spectrum8 tremor storm.
24 */
25// ant_cache_spectrum8_tremor_storm
26// Holographic fringe x tremor2 sine quake distortion driven by spectrum bands
27// Audio history (spectrum0..7) + Frame cache history (samp,samp1..samp8) - EXTREME
28layout(location = 0) in vec2 tc;
29layout(location = 0) out vec4 color;
30layout(set = 0, binding = 0) uniform sampler2D samp;
31layout(set = 0, binding = 2) uniform sampler2DArray history;
32
33#ifndef SIZE
34#define SIZE 8
35#endif
36#ifndef CACHE_HISTORY_LAYER
37#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
38#endif
39layout(set = 0, binding = 3) uniform sampler1D spectrum0;
40layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
41
42
43#ifndef SPECTRUM_HISTORY_LAYER
44#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
45#endif
46
47
48
49
50
51const float TAU = 6.28318530718;
52
53/**
54 * @brief Evaluates specHist for this shader effect.
55 * @param i Input value for the calculation.
56 * @param f Input value for the calculation.
57 * @return Computed float value.
58 */
59float specHist(int i, float f) {
60 if (i == 0) return texture(spectrum0, f).r;
61 if (i == 1) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(1)))).r;
62 if (i == 2) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(2)))).r;
63 if (i == 3) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(3)))).r;
64 if (i == 4) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(4)))).r;
65 if (i == 5) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(5)))).r;
66 if (i == 6) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(6)))).r;
67 return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(7)))).r;
68}
69
70/**
71 * @brief Evaluates cacheHist for this shader effect.
72 * @param i Input value for the calculation.
73 * @param uv Input value for the calculation.
74 * @return Computed vec4 value.
75 */
76vec4 cacheHist(int i, vec2 uv) {
77 if (i == 0) return texture(samp, uv);
78 if (i == 1) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(0))));
79 if (i == 2) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(1))));
80 if (i == 3) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(2))));
81 if (i == 4) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(3))));
82 if (i == 5) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(4))));
83 if (i == 6) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(5))));
84 if (i == 7) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(6))));
85 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(7))));
86}
87
88/**
89 * @brief Evaluates palette for this shader effect.
90 * @param t Input value for the calculation.
91 * @param d Input value for the calculation.
92 * @return Computed vec3 value.
93 */
94vec3 palette(float t, vec3 d) {
95 return 0.5 + 0.5 * cos(TAU * (vec3(1.0) * t + d));
96}
97
98/**
99 * @brief Evaluates pingPong for this shader effect.
100 * @param t Input value for the calculation.
101 * @param maxT Input value for the calculation.
102 * @return Computed float value.
103 */
104float pingPong(float t, float maxT) {
105 return abs(mod(t, 2.0 * maxT) - maxT);
106}
107
108/**
109 * @brief Evaluates tremor for this shader effect.
110 * @param uv Input value for the calculation.
111 * @param freq Input value for the calculation.
112 * @param amp Input value for the calculation.
113 * @param phase Input value for the calculation.
114 * @return Computed vec2 value.
115 */
116vec2 tremor(vec2 uv, float freq, float amp, float phase) {
117 float x = sin(uv.y * freq + iTime * 5.0 + phase) * amp;
118 float y = cos(uv.x * freq + iTime * 5.0 + phase) * amp;
119 return uv + vec2(x, y);
120}
121
122/**
123 * @brief Executes the fragment shader entry point.
124 */
125void main() {
126 float aspect = iResolution.x / iResolution.y;
127 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
128
129 vec3 acc = vec3(0.0);
130 for (int i = 0; i < 8; i++) {
131 float h = specHist(i, 0.05 + float(i) * 0.06);
132 float h2 = specHist(i, 0.55);
133 float bass = specHist(i, 0.04);
134
135 float intervalFactor = pingPong(iTime, 2.0) / 2.0;
136 float ampQ = (0.015 + bass * 0.08) * intervalFactor;
137 vec2 suv = tremor(tc, 18.0 + h * 50.0, ampQ, float(i) * 0.7);
138
139 // Holographic fringe
140 float ang = float(i) * 0.4 + h2 * 3.0;
141 vec2 dir = vec2(cos(ang), sin(ang));
142 float fringe = sin(dot(uv, dir) * (40.0 + h * 80.0) + iTime * (1.0 + h * 4.0));
143 fringe = pow(fringe * 0.5 + 0.5, 4.0);
144 suv += dir * fringe * 0.06 * (1.0 + bass * 3.0);
145
146 vec3 c;
147 c.r = cacheHist(i, fract(suv) + vec2(h * 0.1, 0.0)).r;
148 c.g = cacheHist(i, fract(suv)).g;
149 c.b = cacheHist(i, fract(suv) - vec2(h * 0.1, 0.0)).b;
150
151 vec3 tint = palette(float(i) * 0.13 + h * 4.0, vec3(0.0, 0.33, 0.66));
152 acc += (c + tint * fringe * 0.6) * (1.0 + h * 5.0 + bass * 4.0) * pow(0.82, float(i));
153 }
154 acc /= 3.0;
155 acc *= 1.3 + amp_peak * 1.4;
156 color = vec4(clamp(acc, 0.0, 1.0), 1.0);
157}
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 amp
Definition abc.frag:17
#define CACHE_HISTORY_LAYER(index)
vec3 palette(float phase)
Evaluates palette for this shader effect.
#define SPECTRUM_HISTORY_LAYER(index)
#define amp_peak
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
float specHist(int i, float f)
Evaluates specHist for this shader effect.
vec4 cacheHist(int i, vec2 uv)
Evaluates cacheHist for this shader effect.
vec2 tremor(vec2 uv, float freq, float amp, float phase)
Evaluates tremor for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
#define TAU