ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_gem_metal_lattice.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 iResolution ext.u0.zw
16#define time_f ext.u2.y
17
18/**
19 * @file ant_gem_metal_lattice.frag
20 * @brief Vulkan fragment shader: ant gem metal lattice.
21 */
22// ant_gem_metal_lattice
23// Metallic lattice grid with spectrum-reactive warping and prismatic color
24layout(location = 0) in vec2 tc;
25layout(location = 0) out vec4 color;
26layout(set = 0, binding = 0) uniform sampler2D samp;
27
28
29
30
31layout(set = 0, binding = 3) uniform sampler1D spectrum;
32
33/**
34 * @brief Evaluates metalSpectrum for this shader effect.
35 * @param t Input value for the calculation.
36 * @return Computed vec3 value.
37 */
38vec3 metalSpectrum(float t) {
39 return vec3(0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67))));
40}
41
42/**
43 * @brief Evaluates rot for this shader effect.
44 * @param a Input value for the calculation.
45 * @return Computed mat2 value.
46 */
47mat2 rot(float a) {
48 float s = sin(a), c = cos(a);
49 return mat2(c, -s, s, c);
50}
51
52/**
53 * @brief Executes the fragment shader entry point.
54 */
55void main(void) {
56 float bass = texture(spectrum, 0.04).r;
57 float mid = texture(spectrum, 0.22).r;
58 float hiMid = texture(spectrum, 0.40).r;
59 float treble = texture(spectrum, 0.58).r;
60 float air = texture(spectrum, 0.80).r;
61
62 vec2 uv = tc * 2.0 - 1.0;
63 uv.x *= iResolution.x / iResolution.y;
64
65 float r = length(uv);
66 float angle = atan(uv.y, uv.x);
67
68 // Rotating lattice driven by mid
69 vec2 latticeUV = rot(time_f * 0.3 + mid * 1.0) * uv;
70
71 // Grid scale reacts to bass
72 float gridScale = 6.0 + bass * 4.0;
73 vec2 grid = fract(latticeUV * gridScale) - 0.5;
74 vec2 gridID = floor(latticeUV * gridScale);
75
76 // Cross-shaped bars
77 float barWidth = 0.08 + treble * 0.05;
78 float hBar = smoothstep(barWidth, barWidth - 0.02, abs(grid.y));
79 float vBar = smoothstep(barWidth, barWidth - 0.02, abs(grid.x));
80 float lattice = max(hBar, vBar);
81
82 // Second rotated layer
83 vec2 latticeUV2 = rot(time_f * 0.3 + mid * 1.0 + 0.785) * uv;
84 vec2 grid2 = fract(latticeUV2 * gridScale * 0.7) - 0.5;
85 float hBar2 = smoothstep(barWidth * 0.7, barWidth * 0.7 - 0.02, abs(grid2.y));
86 float vBar2 = smoothstep(barWidth * 0.7, barWidth * 0.7 - 0.02, abs(grid2.x));
87 float lattice2 = max(hBar2, vBar2);
88
89 // Combined lattice
90 float finalLattice = max(lattice, lattice2 * 0.6);
91
92 // Texture through lattice cells
93 vec2 sampUV = tc + grid * 0.02 * (1.0 + mid);
94
95 // Chromatic split
96 float chroma = 0.008 + air * 0.02;
97 vec3 baseTex;
98 baseTex.r = texture(samp, sampUV + vec2(chroma, 0.0)).r;
99 baseTex.g = texture(samp, sampUV).g;
100 baseTex.b = texture(samp, sampUV - vec2(chroma, 0.0)).b;
101
102 // Metallic bar coloring
103 float barHash = fract(sin(dot(gridID, vec2(12.9898, 78.233))) * 43758.5453);
104 vec3 barColor = metalSpectrum(barHash + time_f * 0.15 + r * 0.5);
105
106 vec3 finalColor = mix(baseTex, barColor, finalLattice * (0.5 + hiMid * 0.4));
107
108 // Junction glow at intersections
109 float junction = hBar * vBar;
110 finalColor += metalSpectrum(time_f * 0.2 + r) * junction * (1.0 + bass * 2.0);
111
112 // Central glow
113 float center = exp(-r * (5.0 - amp_smooth * 3.0));
114 finalColor += vec3(1.0, 0.97, 0.93) * center * (1.5 + amp_peak * 2.0);
115
116 color = vec4(finalColor, 1.0);
117}
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
#define amp_smooth
#define amp_peak
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec3 metalSpectrum(float t)
Evaluates metalSpectrum for this shader effect.
float lattice(vec2 point, float bass, float middle, float high)
Evaluates lattice for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.