ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-update-quartz-tsunami.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file code-update-quartz-tsunami.frag
5 * @brief Vulkan fragment shader: code-update-quartz-tsunami.
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// Refractive crystalline ocean with angular breakers and rainbow foam.
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 P for this shader effect.
32 * @param x Input value for the calculation.
33 * @return Computed vec3 value.
34 */
35vec3 P(float x) {
36 return .5 + .5 * cos(T * (x + vec3(.52, .25, .05)));
37}
38/**
39 * @brief Evaluates W for this shader effect.
40 * @param p Input value for the calculation.
41 * @return Computed float value.
42 */
43float W(vec2 p) {
44 return sin(p.x * 11. + sin(p.y * 5. + iTime) * 2.) +
45 sin(p.y * 15. - iTime * 1.4 + sin(p.x * 4.) * 2.) * .6;
46}
47/**
48 * @brief Executes the fragment shader entry point.
49 */
50void main() {
51 float b = texture(spectrum, .03).r, m = texture(spectrum, .19).r, t = texture(spectrum, .57).r,
52 a = texture(spectrum, .85).r;
53 float A = iResolution.x / iResolution.y;
54 vec2 p = (tc - .5) * vec2(A, 1);
55 p.y += p.x * p.x * (.25 + b * .15);
56 float e = .002, f = W(p);
57 vec2 g = vec2(W(p + vec2(e, 0)) - W(p - vec2(e, 0)), W(p + vec2(0, e)) - W(p - vec2(0, e))) /
58 (2. * e);
59 vec2 uv = tc + g * (.0015 + .003 * m);
60 float ca = .001 + .006 * t;
61 vec3 c = vec3(texture(samp, uv + g * ca).r, texture(samp, uv).g, texture(samp, uv - g * ca).b);
62 float facet = pow(1. - abs(fract(f * 1.7) - .5) * 2., 8.);
63 float foam = pow(smoothstep(.6, 1., f * .5 + .5), 8.);
64 vec3 crystal = P(f * .08 + p.x * .2 + iTime * .025);
65 c = mix(c, c * crystal, .45);
66 c += crystal * facet * (.22 + a * .5) + vec3(.65, .85, 1) * foam * (.55 + 2. * b);
67 c *= .88 + .32 * amp_smooth;
68 c = mix(c, 1. - c, smoothstep(.96, 1., amp_peak));
69 color = vec4(1. - exp(-max(c, 0.) * 1.35), 1);
70}
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 crystal(float t)
Evaluates crystal for this shader effect.
vec3 P(float x)
Evaluates P for this shader effect.
float W(vec2 p)
Evaluates W for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.