ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_mir.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_mir.frag
5 * @brief Vulkan fragment shader: frac mir.
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_high ext.audio_bands.z
18#define amp_low ext.audio_bands.x
19#define amp_mid ext.audio_bands.y
20#define amp_peak ext.u2.w
21#define amp_rms ext.u3.z
22#define amp_smooth ext.u3.w
23#define iResolution ext.u0.zw
24#define iamp ext.u1.z
25#define time_f ext.u2.y
26
27layout(location = 0) out vec4 color;
28layout(location = 0) in vec2 tc;
29
30
31layout(set = 0, binding = 0) uniform sampler2D samp;
32
33
34
35
36
37
38
39
40/**
41 * @brief Evaluates kaleidoscope for this shader effect.
42 * @param uv Input value for the calculation.
43 * @param segments Input value for the calculation.
44 * @return Computed vec2 value.
45 */
46vec2 kaleidoscope(vec2 uv, float segments) {
47 float angle = atan(uv.y, uv.x);
48 float radius = length(uv);
49 angle = mod(angle, 2.0 * 3.14159265359 / segments);
50 return vec2(cos(angle), sin(angle)) * radius;
51}
52
53/**
54 * @brief Evaluates fractalSpiral for this shader effect.
55 * @param uv Input value for the calculation.
56 * @return Computed float value.
57 */
58float fractalSpiral(vec2 uv) {
59 float scale = 1.0;
60 float intensity = 0.0;
61 float rotation = time_f * 0.5;
62 for (int i = 0; i < 8; i++) {
63 uv = mat2(cos(rotation), -sin(rotation), sin(rotation), cos(rotation)) * uv;
64 uv = abs(uv) / dot(uv, uv) - 0.5;
65 intensity += 1.0 / scale * sin(uv.x * 10.0 + uv.y * 10.0 + time_f);
66 scale *= 1.8;
67 }
68 return intensity;
69}
70
71/**
72 * @brief Evaluates blendMaterials for this shader effect.
73 * @param texColor Input value for the calculation.
74 * @param fractalColor Input value for the calculation.
75 * @param uv Input value for the calculation.
76 * @return Computed vec3 value.
77 */
78vec3 blendMaterials(vec3 texColor, vec3 fractalColor, vec2 uv) {
79 float fresnel = pow(1.0 - dot(normalize(uv), vec2(0.0, 0.0)), 2.0);
80 vec3 specularHighlight = vec3(1.0) * pow(max(0.0, fractalColor.r), 20.0);
81 return mix(texColor, fractalColor + specularHighlight, fresnel);
82}
83
84/**
85 * @brief Evaluates pingPong for this shader effect.
86 * @param x Input value for the calculation.
87 * @param length Input value for the calculation.
88 * @return Computed float value.
89 */
90float pingPong(float x, float length) {
91 return length - abs(mod(x, 2.0 * length) - length);
92}
93
94/**
95 * @brief Executes the fragment shader entry point.
96 */
97void main() {
98 vec2 uv = tc * 2.0 - 1.0;
99 uv.x *= iResolution.x / iResolution.y;
100 float segments = 6.0 + mod(time_f, 10.0);
101 uv = kaleidoscope(uv, segments);
102 float fractalValue = fractalSpiral(uv * 2.0);
103 vec3 fractalColor = vec3(fractalValue * 0.8, fractalValue * 0.6, fractalValue * 0.4);
104 vec3 texColor = texture(samp, uv * 0.5 + 0.5).rgb;
105 vec3 blendedColor = blendMaterials(texColor, fractalColor, uv);
106 blendedColor += vec3(0.3);
107 blendedColor.r += sin(uv.x * 2.0 + time_f) * 0.2;
108 blendedColor.g += sin(uv.y * 2.0 + time_f * 0.5) * 0.2;
109 blendedColor.b += sin((uv.x + uv.y) * 0.5 + time_f) * 0.2;
110
111 // --- Audio Reactivity: direct output modulation ---
112 float _ab = clamp(amp_peak, 0.0, 1.0);
113 float _abass = clamp(amp_low, 0.0, 1.0);
114 blendedColor *= 1.0 + _ab * 0.6;
115 blendedColor = mix(blendedColor, blendedColor * vec3(1.0 + _abass * 0.3, 1.0 - _abass * 0.15, 1.0 + clamp(amp_high, 0.0, 1.0) * 0.25), _ab);
116 // --- End Audio Reactivity ---
117
118 color = vec4(blendedColor, 1.0);
119 color = mix(color, texture(samp, tc), 0.5);
120 float time_t = pingPong(time_f, 5.0) + 1.5;
121 color = color * sin(vec4(blendedColor, 1.0) * time_t);
122 color.a = 1.0;
123}
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
vec2 kaleidoscope(vec2 point, float sides)
Evaluates kaleidoscope for this shader effect.
#define amp_low
#define amp_high
#define amp_peak
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec4 fractalColor(vec2 uv)
Evaluates fractalColor for this shader effect.
Definition deeps1.frag:66
vec3 blendMaterials(vec3 texColor, vec3 fractalColor, vec2 uv)
Evaluates blendMaterials for this shader effect.
Definition frac_mir.frag:78
float fractalSpiral(vec2 uv)
Evaluates fractalSpiral for this shader effect.
Definition frac_mir.frag:58
mat2 rotation(float angle)
Evaluates rotation for this shader effect.