ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
blue_2.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file blue_2.frag
5 * @brief Vulkan fragment shader: blue 2.
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 ext.u1.y
18#define iMouse ext.mouse
19#define iResolution ext.u0.zw
20#define time_f ext.u2.y
21#define uamp ext.u1.y
22
23layout(location = 0) in vec2 tc;
24layout(location = 0) out vec4 color;
25
26layout(set = 0, binding = 0) uniform sampler2D samp;
27
28
29
30
31
32
33const float PI = 3.1415926535897932384626433832795;
34
35/**
36 * @brief Evaluates pingPong for this shader effect.
37 * @param x Input value for the calculation.
38 * @param length Input value for the calculation.
39 * @return Computed float value.
40 */
41float pingPong(float x, float length) {
42 float m = mod(x, length * 2.0);
43 return m <= length ? m : length * 2.0 - m;
44}
45
46
47/**
48 * @brief Evaluates sat for this shader effect.
49 * @param x Input value for the calculation.
50 * @return Computed float value.
51 */
52float sat(float x){return clamp(x,0.0,1.0);}
53
54/**
55 * @brief Executes the fragment shader entry point.
56 */
57void main(void){
58 vec2 uv = tc;
59 vec2 m = (iMouse.z>0.0||iMouse.w>0.0)? iMouse.xy/iResolution : vec2(0.5);
60 float v = 0.4 + amp*0.2;
61 float s = 0.22;
62 float width = 0.10;
63 float base = mod(time_f*v, s);
64 vec2 dir = normalize(uv - m + 1e-6);
65 float r = distance(uv, m);
66
67 float waveSum = 0.0;
68 for(int k=0;k<4;k++){
69 float rc = base + float(k)*s;
70 float a = (r - rc)/width;
71 waveSum += exp(-a*a);
72 }
73
74
75
76 vec2 duv = dir * sin(pingPong(waveSum * PI, 5.0)) * (0.015 + 0.015*uamp);
77 vec4 tex = texture(samp, uv + duv);
78
79 float blend = sat(waveSum * (0.45 + 0.55*uamp));
80 vec3 blue = mix(tex.rgb, vec3(0.06, 0.28, 1.0), blend);
81 color = vec4(blue, 1.0);
82}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
#define iMouse
Definition 3high.frag:17
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 uamp
Definition abc.frag:21
#define amp
Definition abc.frag:17
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
float sat(float x)
Evaluates sat for this shader effect.
Definition blue_2.frag:52
#define PI