ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
auraXi1.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file auraXi1.frag
5 * @brief Vulkan fragment shader: auraXi1.
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 amp ext.u1.y
18#define iFrame int(ext.u2.x)
19#define iMouse ext.mouse
20#define iMouseClick ext.mouse.xy
21#define iResolution ext.u0.zw
22#define iSampleRate ext.u2.z
23#define iTime ext.u0.y
24#define time_f ext.u2.y
25#define uamp ext.u1.y
26
27layout(location = 0) out vec4 color;
28layout(location = 0) in vec2 tc;
29layout(set = 0, binding = 0) uniform sampler2D samp;
30
31
32
33
34
35
36
37
38
39
40const float PI = 3.1415926535897932384626433832795;
41
42/**
43 * @brief Evaluates pingPong for this shader effect.
44 * @param x Input value for the calculation.
45 * @param length Input value for the calculation.
46 * @return Computed float value.
47 */
48float pingPong(float x, float length){
49 float m = mod(x, length*2.0);
50 return m <= length ? m : length*2.0 - m;
51}
52
53/**
54 * @brief Evaluates luma for this shader effect.
55 * @param c Input value for the calculation.
56 * @return Computed float value.
57 */
58float luma(vec3 c){ return dot(c, vec3(0.299, 0.587, 0.114)); }
59
60/**
61 * @brief Evaluates hue for this shader effect.
62 * @param t Input value for the calculation.
63 * @return Computed vec3 value.
64 */
65vec3 hue(float t){
66 return clamp(vec3(abs(t*6.0-3.0)-1.0, 2.0-abs(t*6.0-2.0), 2.0-abs(t*6.0-4.0)),0.0,1.0);
67}
68
69/**
70 * @brief Evaluates rotateUV for this shader effect.
71 * @param uv Input value for the calculation.
72 * @param angle Input value for the calculation.
73 * @param c Input value for the calculation.
74 * @param aspect Input value for the calculation.
75 * @return Computed vec2 value.
76 */
77vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect){
78 float s = sin(angle), cc = cos(angle);
79 vec2 p = uv - c;
80 p.x *= aspect;
81 p = mat2(cc, -s, s, cc) * p;
82 p.x /= aspect;
83 return p + c;
84}
85
86/**
87 * @brief Evaluates rippleDisplace for this shader effect.
88 * @param uv Input value for the calculation.
89 * @param center Input value for the calculation.
90 * @param aspect Input value for the calculation.
91 * @param t Input value for the calculation.
92 * @param drive Input value for the calculation.
93 * @return Computed vec2 value.
94 */
95vec2 rippleDisplace(vec2 uv, vec2 center, float aspect, float t, float drive){
96 vec2 d = uv - center;
97 float dist = length(d);
98 vec2 dir = d / max(dist, 1e-6);
99 float baseWave = 0.05;
100 float baseAmp = 0.02;
101 float speed = 2.0;
102 float texLum = luma(texture(samp, uv).rgb);
103 float waveLength = baseWave * (0.8 + 0.6*texLum);
104 float amplitude = baseAmp * (0.7 + 0.8*drive);
105 float ripple = sin((dist / max(waveLength,1e-4) - t * speed) * 6.2831853);
106 ripple *= smoothstep(0.95, 0.15, dist);
107 return uv + dir * ripple * amplitude;
108}
109
110/**
111 * @brief Evaluates spiralTwist for this shader effect.
112 * @param uv Input value for the calculation.
113 * @param center Input value for the calculation.
114 * @param aspect Input value for the calculation.
115 * @param t Input value for the calculation.
116 * @param drive Input value for the calculation.
117 * @return Computed vec2 value.
118 */
119vec2 spiralTwist(vec2 uv, vec2 center, float aspect, float t, float drive){
120 vec2 p = uv - center;
121 p.x *= aspect;
122 float r = length(p)+1e-6;
123 float a = atan(p.y, p.x);
124 float swirl = (0.7 + 0.6*drive) / (1.0 + 8.0*r);
125 float spin = (0.35 + 0.25*drive) * t;
126 a += spin + swirl;
127 float pull = 0.12 / (1.0 + 6.0*r);
128 r = max(r - pull, 0.0);
129 vec2 q = vec2(cos(a), sin(a)) * r;
130 q.x /= aspect;
131 return q + center;
132}
133
134/**
135 * @brief Evaluates spiralEcho for this shader effect.
136 * @param uv Input value for the calculation.
137 * @param center Input value for the calculation.
138 * @param aspect Input value for the calculation.
139 * @param t Input value for the calculation.
140 * @param drive Input value for the calculation.
141 * @return Computed vec3 value.
142 */
143vec3 spiralEcho(vec2 uv, vec2 center, float aspect, float t, float drive){
144 const int TAPS = 6;
145 vec3 acc = vec3(0.0);
146 float wsum = 0.0;
147 for(int i=0;i<TAPS;i++){
148 float k = float(i);
149 float radScale = 1.0 + 0.09*k;
150 float timeLag = 0.1*k;
151 vec2 u = spiralTwist(uv, center, aspect, t - timeLag, drive);
152 u = rotateUV(u, (0.15+0.05*drive)*k, center, aspect);
153 vec3 s = texture(samp, fract(u / radScale)).rgb;
154 float w = 1.0 / (1.0 + 0.8*k);
155 acc += s * w;
156 wsum += w;
157 }
158 return acc / max(wsum, 1e-6);
159}
160
161/**
162 * @brief Executes the fragment shader entry point.
163 */
164void main(void){
165 vec2 mouseN = iMouse.xy / iResolution;
166 vec2 clickN = iMouseClick / iResolution;
167 bool hasClick = max(iMouseClick.x, iMouseClick.y) > 0.0;
168 vec2 center = (iMouse.z > 0.5) ? mouseN : (hasClick ? clickN : vec2(0.5));
169 float t = time_f + iTime*0.75 + float(iFrame)*0.0005;
170 float aMix = clamp(amp*0.7 + uamp*0.3, 0.0, 20.0);
171 float drive = clamp(aMix*0.10, 0.0, 3.0);
172 float aspect = iResolution.x / iResolution.y;
173 vec2 uvRipple = rippleDisplace(tc, center, aspect, t, drive);
174 vec3 echoCol = spiralEcho(uvRipple, center, aspect, t, drive);
175 vec2 m = (iMouse.z > 0.0) ? (iMouse.xy / iResolution.xy) : vec2(0.5);
176 float a = time_f*0.6;
177 vec2 dir = normalize(vec2(cos(a), sin(a)));
178 float span = 0.25 + 0.15*sin(time_f*0.7);
179 vec2 startP = m - dir*span;
180 vec2 endP = m + dir*span;
181 vec2 ab = endP - startP;
182 float L = max(length(ab), 1e-4);
183 vec2 u = ab / L;
184 float gradT = clamp(dot(tc - startP, u) / L, 0.0, 1.0);
185 vec3 c0 = hue(fract(time_f*0.1));
186 vec3 c1 = hue(fract(time_f*0.1 + 0.5));
187 vec3 grad = mix(c0, c1, gradT);
188 vec3 tex = texture(samp, uvRipple).rgb;
189 vec3 mixed = mix(tex, echoCol, 0.6);
190 mixed = mix(mixed, mixed * grad, clamp(amp, 0.0, 1.0));
191 mixed = pow(abs(sin(mixed * (1.5 + 0.5*uamp))), vec3(1.0));
192 mixed = clamp(mixed * (1.3 + 0.3*drive), 0.0, 1.0);
193 color = vec4(mixed, 1.0);
194}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
#define iMouse
Definition 3high.frag:17
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
#define uamp
Definition abc.frag:21
#define amp
Definition abc.frag:17
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl for this shader effect.
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
Definition aura2.frag:59
vec2 rippleDisplace(vec2 uv, vec2 center, float aspect, float t, float drive)
Evaluates rippleDisplace for this shader effect.
Definition auraXi1.frag:95
vec3 hue(float t)
Evaluates hue for this shader effect.
Definition auraXi1.frag:65
vec2 spiralTwist(vec2 uv, vec2 center, float aspect, float t, float drive)
Evaluates spiralTwist for this shader effect.
Definition auraXi1.frag:119
#define iMouseClick
Definition auraXi1.frag:20
float luma(vec3 c)
Evaluates luma for this shader effect.
Definition auraXi1.frag:58
vec3 spiralEcho(vec2 uv, vec2 center, float aspect, float t, float drive)
Evaluates spiralEcho for this shader effect.
Definition auraXi1.frag:143
#define iFrame
Definition auraXi1.frag:18
#define PI
vec2 spin(vec2 p, float a)
Evaluates spin for this shader effect.