ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
psych_pattern.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file psych_pattern.frag
5 * @brief Vulkan fragment shader: psych pattern.
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;
22
23
24layout(set = 0, binding = 0) uniform sampler2D samp;
25
26/**
27 * @brief Evaluates xor RGB for this shader effect.
28 * @param icolor Input value for the calculation.
29 * @param isourcex Input value for the calculation.
30 * @return Computed vec4 value.
31 */
32vec4 xor_RGB(vec4 icolor, vec4 isourcex) {
33 ivec4 isource = ivec4(isourcex * 255);
34 ivec3 int_color;
35 for(int i = 0; i < 3; ++i) {
36 int_color[i] = int(255 * icolor[i]);
37 int_color[i] ^= isource[i];
38 if(int_color[i] > 255)
39 int_color[i] %= 255;
40 icolor[i] = float(int_color[i]) / 255.0;
41 }
42 icolor.a = 1.0;
43return icolor;
44}
45
46
47/**
48 * @brief Evaluates kaleido for this shader effect.
49 * @param uv Input value for the calculation.
50 * @return Computed float value.
51 */
52float kaleido(vec2 uv) {
53 uv = uv * 2.0 - 1.0;
54 float angle = atan(uv.y, uv.x) + time_f;
55 float radius = length(uv);
56 angle = mod(angle, 3.14159 / 4.0) * 8.0;
57 return abs(cos(angle * radius * 10.0 - time_f * 4.0));
58}
59
60/**
61 * @brief Evaluates colorCycle for this shader effect.
62 * @param t Input value for the calculation.
63 * @return Computed vec3 value.
64 */
65vec3 colorCycle(float t) {
66 return vec3(
67 sin(t * 2.0 + 0.0) * 0.5 + 0.5,
68 sin(t * 2.0 + 2.09439) * 0.5 + 0.5,
69 sin(t * 2.0 + 4.18879) * 0.5 + 0.5
70 );
71}
72
73/**
74 * @brief Executes the fragment shader entry point.
75 */
76void main() {
77 vec2 uv = tc - 0.5;
78 uv.x *= iResolution.x / iResolution.y;
79 float pattern = kaleido(uv);
80 vec3 col = colorCycle(pattern + time_f);
81 color = vec4(col, 1.0);
82 color = xor_RGB(color, texture(samp, tc));
83}
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
vec4 xor_RGB(vec4 a, vec4 b)
Evaluates xor RGB for this shader effect.
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
vec3 colorCycle(float t)
Evaluates colorCycle for this shader effect.