ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-update-velvet-inferno.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file code-update-velvet-inferno.frag
5 * @brief Vulkan fragment shader: code-update-velvet-inferno.
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_peak ext.u2.w
18#define amp_smooth ext.u3.w
19#define iResolution ext.u0.zw
20#define iTime ext.u0.y
21
22// Slow folded flame with velvety shadows, ember threads, and jewel-tone heat.
23layout(location = 0) in vec2 tc;
24layout(location = 0) out vec4 color;
25layout(set = 0, binding = 0) uniform sampler2D samp;
26layout(set = 0, binding = 3) uniform sampler1D spectrum;
27
28
29const float T = 6.28318530718;
30/**
31 * @brief Evaluates H for this shader effect.
32 * @param p Input value for the calculation.
33 * @return Computed float value.
34 */
35float H(vec2 p) {
36 return fract(sin(dot(p, vec2(91.7, 233.1))) * 43758.5);
37}
38/**
39 * @brief Evaluates N for this shader effect.
40 * @param p Input value for the calculation.
41 * @return Computed float value.
42 */
43float N(vec2 p) {
44 vec2 i = floor(p), f = fract(p);
45 f = f * f * (3. - 2. * f);
46 return mix(mix(H(i), H(i + vec2(1, 0)), f.x), mix(H(i + vec2(0, 1)), H(i + 1.), f.x), f.y);
47}
48/**
49 * @brief Evaluates F for this shader effect.
50 * @param p Input value for the calculation.
51 * @return Computed float value.
52 */
53float F(vec2 p) {
54 float f = 0., w = .5;
55 for (int i = 0; i < 5; i++) {
56 f += w * N(p);
57 p = mat2(1.6, -1.2, 1.2, 1.6) * p + 3.1;
58 w *= .5;
59 }
60 return f;
61}
62/**
63 * @brief Evaluates P for this shader effect.
64 * @param x Input value for the calculation.
65 * @return Computed vec3 value.
66 */
67vec3 P(float x) {
68 return .45 + .55 * cos(T * (x + vec3(.02, .12, .48)));
69}
70/**
71 * @brief Executes the fragment shader entry point.
72 */
73void main() {
74 float b = texture(spectrum, .03).r, m = texture(spectrum, .22).r, t = texture(spectrum, .6).r,
75 a = texture(spectrum, .87).r;
76 float A = iResolution.x / iResolution.y;
77 vec2 p = (tc - .5) * vec2(A, 1);
78 float flame = F(vec2(p.x * 3. + sin(p.y * 5.) * .4, p.y * 3. - iTime * (.5 + b)));
79 float shape = smoothstep(.72, .15, abs(p.x) * (1.2 + p.y) - flame * .28 + .08);
80 vec2 uv = tc + vec2(sin(flame * T), -flame) * (.012 + .018 * m);
81 float ca = .004 + .02 * t;
82 vec3 c = vec3(texture(samp, uv + ca).r, texture(samp, uv).g, texture(samp, uv - ca).b) *
83 (.35 + .45 * shape);
84 float thread = pow(.5 + .5 * sin(flame * 24. - p.y * 18. + iTime * 2.), 14.) * shape;
85 c += P(flame * .35 - p.y * .4 + iTime * .03) *
86 (shape * (.28 + b * .4) + thread * (.55 + 1.5 * a));
87 c *= .9 + .32 * amp_smooth;
88 c = mix(c, 1. - c, smoothstep(.96, 1., amp_peak));
89 color = vec4(1. - exp(-max(c, 0.) * 1.35), 1);
90}
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 amp_smooth
#define amp_peak
vec3 P(float x)
Evaluates P for this shader effect.
float H(vec2 p)
Evaluates H for this shader effect.
float F(vec2 p)
Evaluates F for this shader effect.
float N(vec2 p)
Evaluates N for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.