ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
inthesky.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file inthesky.frag
5 * @brief Vulkan fragment shader: inthesky.
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
22layout(location = 0) out vec4 color;
23layout(location = 0) in vec2 tc;
24layout(set = 0, binding = 0) uniform sampler2D samp;
25
26
27
28
29
30/**
31 * @brief Evaluates pp for this shader effect.
32 * @param x Input value for the calculation.
33 * @param len Input value for the calculation.
34 * @return Computed float value.
35 */
36float pp(float x, float len){float m=mod(x,len*2.0);return m<=len?m:len*2.0-m;}
37
38/**
39 * @brief Evaluates rot for this shader effect.
40 * @param uv Input value for the calculation.
41 * @param a Input value for the calculation.
42 * @param c Input value for the calculation.
43 * @param asp Input value for the calculation.
44 * @return Computed vec2 value.
45 */
46vec2 rot(vec2 uv, float a, vec2 c, float asp){
47 float s=sin(a),co=cos(a);
48 vec2 p=uv-c; p.x*=asp;
49 p=mat2(co,-s,s,co)*p;
50 p.x/=asp; return p+c;
51}
52
53/**
54 * @brief Evaluates reflectUV for this shader effect.
55 * @param uv Input value for the calculation.
56 * @param seg Input value for the calculation.
57 * @param c Input value for the calculation.
58 * @param asp Input value for the calculation.
59 * @return Computed vec2 value.
60 */
61vec2 reflectUV(vec2 uv, float seg, vec2 c, float asp){
62 vec2 p=uv-c; p.x*=asp;
63 float ang=atan(p.y,p.x);
64 float r=length(p);
65 float stepA=6.28318530718/seg;
66 ang=mod(ang,stepA);
67 ang=abs(ang-stepA*0.5);
68 vec2 q=vec2(cos(ang),sin(ang))*r; q.x/=asp;
69 return q+c;
70}
71
72/**
73 * @brief Evaluates fractalZoom for this shader effect.
74 * @param uv Input value for the calculation.
75 * @param zoom Input value for the calculation.
76 * @param t Input value for the calculation.
77 * @param c Input value for the calculation.
78 * @param asp Input value for the calculation.
79 * @return Computed vec2 value.
80 */
81vec2 fractalZoom(vec2 uv, float zoom, float t, vec2 c, float asp){
82 vec2 p=uv;
83 for(int i=0;i<5;i++){
84 p=abs((p-c)*zoom)-0.5+c;
85 p=rot(p,t*0.1,c,asp);
86 }
87 return p;
88}
89
90/**
91 * @brief Executes the fragment shader entry point.
92 */
93void main(){
94 float asp=iResolution.x/iResolution.y;
95 vec2 m0=(iMouse.z>0.5)?(iMouse.xy/iResolution):vec2(0.5);
96 vec2 center=vec2(0.5)+(m0-vec2(0.5))*(1.0+amp*0.5*sin(time_f));
97 vec2 uv=tc;
98 uv += (uv-center)*0.05*amp*sin(time_f*1.3);
99
100 vec4 originalTexture=texture(samp,uv);
101
102 float seg=6.0+floor(amp*2.0*sin(time_f*0.7));
103 vec2 kUV=reflectUV(uv,seg,center,asp);
104 float zoom=1.5+0.5*sin(time_f*0.5)+0.2*amp*sin(time_f*1.7);
105 kUV=fractalZoom(kUV,zoom,time_f,center,asp);
106 kUV=rot(kUV,time_f*0.2*(1.0+0.6*amp),center,asp);
107
108 vec4 kaleidoColor=texture(samp,clamp(kUV,0.0,1.0));
109 float blendFactor=0.6;
110 vec4 blendedColor=mix(kaleidoColor,originalTexture,blendFactor);
111
112 blendedColor.rgb*=0.5+0.5*sin(vec3(kUV.x,kUV.y,kUV.x)+time_f*(1.0+0.5*amp));
113
114 vec4 t0=texture(samp,uv);
115 vec4 c0=sin(blendedColor*pp(time_f*(1.0+0.3*amp),10.0));
116 vec4 c1=c0*t0*(0.8+0.15*amp);
117 color=sin(c1*pp(time_f*(1.0+0.2*amp),15.0));
118 color.a=1.0;
119}
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 amp
Definition abc.frag:17
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect)
Evaluates reflectUV for this shader effect.
Definition aura2.frag:76
vec2 fractalZoom(vec2 uv, float zoom, float time, vec2 center)
Evaluates fractalZoom for this shader effect.
float pp(float x, float len)
Evaluates pp for this shader effect.
Definition inthesky.frag:36