ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_gem_metal_ember.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_ember.frag
20 * @brief Vulkan fragment shader: ant gem metal ember.
21 */
22// ant_gem_metal_ember
23// Glowing metallic embers with heat distortion and spectrum-driven flicker
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 ember for this shader effect.
44 * @param t Input value for the calculation.
45 * @return Computed vec3 value.
46 */
47vec3 ember(float t) {
48 vec3 a = vec3(0.6, 0.15, 0.02);
49 vec3 b = vec3(0.4, 0.25, 0.08);
50 vec3 c = vec3(1.0, 0.8, 0.4);
51 vec3 d = vec3(0.0, 0.15, 0.25);
52 return a + b * cos(6.28318 * (c * t + d));
53}
54
55/**
56 * @brief Evaluates hash for this shader effect.
57 * @param p Input value for the calculation.
58 * @return Computed float value.
59 */
60float hash(vec2 p) {
61 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
62}
63
64/**
65 * @brief Evaluates noise for this shader effect.
66 * @param p Input value for the calculation.
67 * @return Computed float value.
68 */
69float noise(vec2 p) {
70 vec2 i = floor(p);
71 vec2 f = fract(p);
72 vec2 u = f * f * (3.0 - 2.0 * f);
73 return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
74 mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);
75}
76
77/**
78 * @brief Executes the fragment shader entry point.
79 */
80void main(void) {
81 float bass = texture(spectrum, 0.04).r;
82 float mid = texture(spectrum, 0.22).r;
83 float hiMid = texture(spectrum, 0.40).r;
84 float treble = texture(spectrum, 0.58).r;
85 float air = texture(spectrum, 0.80).r;
86
87 vec2 uv = tc * 2.0 - 1.0;
88 uv.x *= iResolution.x / iResolution.y;
89
90 float r = length(uv);
91 float angle = atan(uv.y, uv.x);
92
93 // Heat shimmer distortion driven by mid
94 float heatNoise = noise(uv * 8.0 + vec2(0.0, -time_f * 3.0));
95 vec2 heatWarp = vec2(heatNoise - 0.5, heatNoise - 0.5) * (0.02 + mid * 0.04);
96
97 // Ripple from base shader
98 float ripple = sin(angle * 8.0 + time_f) * (0.03 + bass * 0.05);
99 ripple += sin(r * 15.0 - time_f * 4.0) * (0.02 + treble * 0.03);
100
101 // Chromatic split
102 float shift = ripple * 0.3 + air * 0.01;
103 vec2 warpedTC = tc + heatWarp;
104 vec3 baseTex;
105 baseTex.r = texture(samp, warpedTC + vec2(shift, 0.0)).r;
106 baseTex.g = texture(samp, warpedTC).g;
107 baseTex.b = texture(samp, warpedTC - vec2(shift, 0.0)).b;
108
109 // Ember particles
110 vec2 grid = floor(uv * 15.0);
111 float particle = hash(grid + floor(time_f * 2.0));
112 float isEmber = step(0.92 - bass * 0.1, particle);
113 vec2 cell = fract(uv * 15.0) - 0.5;
114 float emberGlow = isEmber * exp(-length(cell) * 8.0);
115
116 // Ember color from heat palette
117 vec3 emberColor = ember(particle + time_f * 0.5 + bass);
118 vec3 particles = emberColor * emberGlow * (3.0 + hiMid * 4.0);
119
120 // Metallic wave overlay
121 float wave = sin(r * (20.0 + mid * 10.0) - time_f * 4.0 + ripple * 8.0);
122 vec3 metalWave = metalSpectrum(r + time_f * 0.2) * smoothstep(0.5, 1.0, wave) * 0.3;
123
124 // Central glow
125 float lightRadius = 5.0 - amp_smooth * 3.0;
126 float center = exp(-r * max(lightRadius, 0.5));
127 vec3 coreGlow = vec3(1.0, 0.85, 0.6) * center * (1.5 + amp_peak * 2.5);
128
129 vec3 finalColor = baseTex + metalWave + particles + coreGlow;
130 finalColor += ripple * wave * (1.0 + bass * 2.0);
131
132 color = vec4(finalColor, 1.0);
133}
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
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
float hash(vec2 p)
Evaluates hash for this shader effect.
float noise(vec2 p)
Evaluates noise for this shader effect.
vec3 metalSpectrum(float t)
Evaluates metalSpectrum for this shader effect.
vec3 ember(float t)
Evaluates ember for this shader effect.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.