ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
xor_code_chromatic_weave.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file xor_code_chromatic_weave.frag
5 * @brief Vulkan fragment shader: xor code chromatic weave.
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 bytes for this shader effect.
28 * @param c Input value for the calculation.
29 * @return Computed uvec3 value.
30 */
31uvec3 bytes(vec3 c) {
32 return uvec3(clamp(floor(c * 255.0 + 0.5), 0.0, 255.0));
33}
34
35/**
36 * @brief Evaluates xorColor for this shader effect.
37 * @param a Input value for the calculation.
38 * @param b Input value for the calculation.
39 * @return Computed vec3 value.
40 */
41vec3 xorColor(vec3 a, vec3 b) {
42 return vec3((bytes(a) ^ bytes(b)) & uvec3(255u)) / 255.0;
43}
44
45/**
46 * @brief Evaluates spectrum for this shader effect.
47 * @param t Input value for the calculation.
48 * @return Computed vec3 value.
49 */
50vec3 spectrum(float t) {
51 return 0.55 + 0.45 * cos(6.2831853 * (t + vec3(0.0, 0.27, 0.63)));
52}
53
54/**
55 * @brief Executes the fragment shader entry point.
56 */
57void main(void) {
58 float aspect = max(iResolution.x, 1.0) / max(iResolution.y, 1.0);
59 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
60 float warp = sin(p.y * 18.0 + time_f * 2.0) * 0.035;
61 float weft = cos(p.x * 21.0 - time_f * 1.6) * 0.035;
62 vec2 uvA = tc + vec2(warp, weft);
63 vec2 uvB = tc + vec2(weft, -warp);
64
65 vec3 a = texture(samp, uvA).rgb;
66 vec3 b = texture(samp, uvB).gbr;
67 float overUnder = step(0.0, sin(p.x * 28.0) * sin(p.y * 28.0));
68 vec3 woven = xorColor(a, b * (1.2 + overUnder * 1.3));
69
70 float thread = pow(abs(sin(p.x * 28.0 + p.y * 28.0 - time_f * 3.0)), 10.0);
71 vec3 tintA = spectrum(p.x * 0.3 + time_f * 0.03);
72 vec3 tintB = spectrum(p.y * 0.3 - time_f * 0.025 + 0.4);
73 vec3 tint = mix(tintA, tintB, overUnder);
74 vec3 result = mix(mix(a, woven, 0.55), woven * tint * 1.3, 0.38);
75 result += tint * thread * 0.38;
76 color = vec4(clamp(result, 0.0, 1.0), texture(samp, tc).a);
77}
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
uvec3 bytes(vec3 c)
Evaluates bytes for this shader effect.
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.
vec3 xorColor(vec3 a, vec3 b)
Evaluates xorColor for this shader effect.