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