ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
comb3-frac-mouse.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file comb3-frac-mouse.frag
5 * @brief Vulkan fragment shader: comb3-frac-mouse.
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 iMouse ext.mouse
18#define iResolution ext.u0.zw
19#define time_f ext.u2.y
20
21layout(location = 0) out vec4 color;
22layout(location = 0) in vec2 tc;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27
28/**
29 * @brief Evaluates pingPong for this shader effect.
30 * @param x Input value for the calculation.
31 * @param length Input value for the calculation.
32 * @return Computed float value.
33 */
34float pingPong(float x, float length) {
35 float modVal = mod(x, length * 2.0);
36 return modVal <= length ? modVal : length * 2.0 - modVal;
37}
38
39/**
40 * @brief Evaluates rotateUV for this shader effect.
41 * @param uv Input value for the calculation.
42 * @param angle Input value for the calculation.
43 * @param center Input value for the calculation.
44 * @return Computed vec2 value.
45 */
46vec2 rotateUV(vec2 uv, float angle, vec2 center) {
47 float s = sin(angle);
48 float c = cos(angle);
49 uv -= center;
50 uv = mat2(c, -s, s, c) * uv;
51 uv += center;
52 return uv;
53}
54
55/**
56 * @brief Evaluates reflectUV for this shader effect.
57 * @param uv Input value for the calculation.
58 * @param segments Input value for the calculation.
59 * @param center Input value for the calculation.
60 * @return Computed vec2 value.
61 */
62vec2 reflectUV(vec2 uv, float segments, vec2 center) {
63 float angle = atan(uv.y - center.y, uv.x - center.x);
64 float radius = length(uv - center);
65 float segmentAngle = 2.0 * 3.14159265359 / segments;
66 angle = mod(angle, segmentAngle);
67 angle = abs(angle - segmentAngle * 0.5);
68 return vec2(cos(angle), sin(angle)) * radius + center;
69}
70
71/**
72 * @brief Evaluates fractalZoom for this shader effect.
73 * @param uv Input value for the calculation.
74 * @param zoom Input value for the calculation.
75 * @param time Input value for the calculation.
76 * @param center Input value for the calculation.
77 * @return Computed vec2 value.
78 */
79vec2 fractalZoom(vec2 uv, float zoom, float time, vec2 center) {
80 for (int i = 0; i < 5; i++) {
81 uv = abs((uv - center) * zoom) - 0.5 + center;
82 uv = rotateUV(uv, sin(time * pingPong(time_f, 10.0)) * 0.1, center);
83 }
84 return uv;
85}
86
87/**
88 * @brief Executes the fragment shader entry point.
89 */
90void main() {
91 vec2 uv = tc * iResolution / vec2(iResolution.y);
92 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution) : vec2(0.5);
93 vec2 center = m * iResolution / vec2(iResolution.y);
94
95 vec4 originalTexture = texture(samp, tc);
96 vec2 kaleidoUV = reflectUV(uv, 6.0, center);
97 float zoom = 1.5 + 0.5 * sin(time_f * 0.5);
98 kaleidoUV = fractalZoom(kaleidoUV, zoom, time_f, center);
99 kaleidoUV = rotateUV(kaleidoUV, time_f * 0.2, center);
100
101 vec4 kaleidoColor = texture(samp, kaleidoUV);
102 float blendFactor = 0.6;
103 vec4 blendedColor = mix(kaleidoColor, originalTexture, blendFactor);
104 blendedColor.rgb *= 0.5 + 0.5 * sin(kaleidoUV.xyx + time_f);
105
106 color = sin(blendedColor * pingPong(time_f, 10.0));
107 vec4 t = texture(samp, tc);
108 color = color * t * 0.8;
109 color = sin(color * pingPong(time_f, 15.0));
110 color.a = 1.0;
111}
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
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
Definition aura2.frag:59
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.
vec2 kaleidoUV(vec2 uv, float segments, vec2 center, float aspect)
Evaluates kaleidoUV for this shader effect.