ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
random_soul.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file random_soul.frag
5 * @brief Vulkan fragment shader: random soul.
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 iResolution ext.u0.zw
18#define time_f ext.u2.y
19
20layout(location = 0) in vec2 tc;
21layout(location = 0) out vec4 color;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates pingPong for this shader effect.
28 * @param x Input value for the calculation.
29 * @param len Input value for the calculation.
30 * @return Computed float value.
31 */
32float pingPong(float x, float len){float m=mod(x,len*2.0);return m<=len?m:len*2.0-m;}
33/**
34 * @brief Evaluates h for this shader effect.
35 * @param n Input value for the calculation.
36 * @return Computed float value.
37 */
38float h(float n){return fract(sin(n)*43758.5453123);}
39/**
40 * @brief Evaluates h2 for this shader effect.
41 * @param n Input value for the calculation.
42 * @return Computed vec2 value.
43 */
44vec2 h2(float n){return vec2(h(n),h(n+1.23));}
45
46/**
47 * @brief Evaluates rainbow for this shader effect.
48 * @param t Input value for the calculation.
49 * @return Computed vec3 value.
50 */
51vec3 rainbow(float t){
52 t=fract(t);
53 float r=abs(t*6.0-3.0)-1.0;
54 float g=2.0-abs(t*6.0-2.0);
55 float b=2.0-abs(t*6.0-4.0);
56 return clamp(vec3(r,g,b),0.0,1.0);
57}
58
59/**
60 * @brief Executes the fragment shader entry point.
61 */
62void main(){
63 vec2 res=iResolution;
64 vec2 uv=tc*2.0-1.0;
65 uv.y*=res.y/res.x;
66
67 float t=time_f*0.25;
68 float seg=floor(t);
69 float a=fract(t);
70 vec2 p0=-0.5+h2(seg)*1.0;
71 vec2 p1=-0.5+h2(seg+1.0)*1.0;
72 a=a*a*(3.0-2.0*a);
73 vec2 swirlC=mix(p0,p1,a);
74
75 vec2 d=uv-swirlC;
76 float r=length(d);
77 float k=0.85;
78 float s=0.45;
79 float theta=k*exp(-r*2.5)*(1.0+0.5*sin(time_f*0.6));
80 float ct=cos(theta);
81 float st=sin(theta);
82 vec2 rot=vec2(d.x*ct-d.y*st,d.x*st+d.y*ct)+swirlC;
83
84 float angle=atan(uv.y,uv.x)+time_f*20.0;
85 vec3 rain=rainbow(angle/(2.0*3.1415926535));
86
87 float bulge_strength=0.2;
88 float distortion=pow(length(rot),2.0)*bulge_strength;
89 vec2 distorted=rot*(1.0+distortion);
90
91 vec2 tex=distorted*0.5+0.5;
92 vec4 base=texture(samp,tex);
93 vec3 blend=mix(base.rgb,rain,0.5);
94
95 color=vec4(sin(blend*time_f),base.a);
96}
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
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.