ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_gem_metal_chrome.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_chrome.frag
20 * @brief Vulkan fragment shader: ant gem metal chrome.
21 */
22// ant_gem_metal_chrome
23// Chrome reflection distortion with spectrum-driven warp and metallic sheen
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 treble = texture(spectrum, 0.58).r;
59 float air = texture(spectrum, 0.80).r;
60
61 vec2 uv = tc * 2.0 - 1.0;
62 uv.x *= iResolution.x / iResolution.y;
63
64 float r = length(uv);
65 float angle = atan(uv.y, uv.x);
66
67 // Chrome warp: reflection-like distortion driven by bass
68 vec2 warp = uv;
69 warp = rot(sin(r * 6.0 - time_f * 2.0) * (0.3 + bass * 0.5)) * warp;
70 warp += sin(warp.yx * (5.0 + mid * 8.0) + time_f) * (0.05 + treble * 0.04);
71
72 // Map warped coords back to texture space
73 vec2 sampUV = warp * 0.5 + 0.5;
74
75 // Chromatic aberration: chrome splits light
76 float chroma = 0.01 + air * 0.03 + amp_peak * 0.02;
77 vec3 baseTex;
78 baseTex.r = texture(samp, sampUV + vec2(chroma, 0.0)).r;
79 baseTex.g = texture(samp, sampUV).g;
80 baseTex.b = texture(samp, sampUV - vec2(chroma, 0.0)).b;
81
82 // Chrome reflectivity: desaturate and boost contrast
83 float luma = dot(baseTex, vec3(0.299, 0.587, 0.114));
84 vec3 chrome = mix(vec3(luma), baseTex, 0.3 + mid * 0.4);
85 chrome = pow(chrome, vec3(0.8)); // boost highlights
86
87 // Metallic rainbow edge
88 float edge = abs(sin(r * (15.0 + bass * 10.0) - time_f * 3.0));
89 vec3 rainbow = metalSpectrum(angle / 6.28318 + time_f * 0.2 + r);
90 chrome = mix(chrome, chrome * rainbow, edge * (0.3 + treble * 0.3));
91
92 // Central glow
93 float lightRadius = 5.0 - amp_smooth * 3.5;
94 float center = exp(-r * max(lightRadius, 0.5));
95 vec3 coreGlow = vec3(1.0, 0.98, 0.95) * center * (1.5 + amp_peak * 2.0);
96
97 vec3 finalColor = chrome + coreGlow;
98 finalColor *= 0.9 + amp_smooth * 0.3;
99
100 color = vec4(finalColor, 1.0);
101}
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 chrome(float t)
Evaluates chrome for this shader effect.
vec3 metalSpectrum(float t)
Evaluates metalSpectrum for this shader effect.
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
float luma(vec3 c)
Evaluates luma for this shader effect.
Definition auraXi1.frag:58
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.