ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_048_xor_grid.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_048_xor_grid.comp
5 * @brief Vulkan compute shader: acidcam 048 xor grid.
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 alpha ext.u0.x
18#define iFrame int(ext.u2.x)
19
20
21layout(local_size_x = 16, local_size_y = 16) in;
22layout(set = 0, binding = 5, rgba8) writeonly uniform image2D outputImage;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27const float INV_255 = 1.0 / 255.0;
28
29/**
30 * @brief Evaluates clampPos for this shader effect.
31 * @param p Input value for the calculation.
32 * @param size Input value for the calculation.
33 * @return Computed ivec2 value.
34 */
35ivec2 clampPos(ivec2 p, ivec2 size) {
36 return clamp(p, ivec2(0), size - ivec2(1));
37}
38
39/**
40 * @brief Evaluates pixelUv for this shader effect.
41 * @param p Input value for the calculation.
42 * @param size Input value for the calculation.
43 * @return Computed vec2 value.
44 */
45vec2 pixelUv(ivec2 p, ivec2 size) {
46 return (vec2(clampPos(p, size)) + 0.5) / vec2(size);
47}
48
49/**
50 * @brief Evaluates sampleSource for this shader effect.
51 * @param p Input value for the calculation.
52 * @param size Input value for the calculation.
53 * @return Computed vec3 value.
54 */
55vec3 sampleSource(ivec2 p, ivec2 size) {
56 return textureLod(samp, pixelUv(p, size), 0.0).rgb;
57}
58
59/**
60 * @brief Evaluates toU8 for this shader effect.
61 * @param color Input value for the calculation.
62 * @return Computed uvec3 value.
63 */
64uvec3 toU8(vec3 color) {
65 return uvec3(clamp(color * 255.0 + 0.5, 0.0, 255.0));
66}
67
68/**
69 * @brief Evaluates toRGB for this shader effect.
70 * @param color Input value for the calculation.
71 * @return Computed vec3 value.
72 */
73vec3 toRGB(uvec3 color) {
74 return vec3(color) * INV_255;
75}
76
77/**
78 * @brief Evaluates sampleSourceU8 for this shader effect.
79 * @param p Input value for the calculation.
80 * @param size Input value for the calculation.
81 * @return Computed uvec3 value.
82 */
83uvec3 sampleSourceU8(ivec2 p, ivec2 size) {
84 return toU8(sampleSource(p, size));
85}
86
87/**
88 * @brief Evaluates effectBlockSize for this shader effect.
89 * @return Computed int value.
90 */
92 return max(int(round(mix(2.0, 64.0, clamp(alpha, 0.0, 1.0)))), 1);
93}
94
95/**
96 * @brief Evaluates effectDirection for this shader effect.
97 * @return Computed int value.
98 */
100 return ((iFrame / 8) & 1) == 0 ? 1 : -1;
101}
102
103/**
104 * @brief Evaluates xorGrid for this shader effect.
105 * @param p Input value for the calculation.
106 * @param size Input value for the calculation.
107 * @return Computed vec3 value.
108 */
109vec3 xorGrid(ivec2 p, ivec2 size) {
110 int block = effectBlockSize();
111 ivec2 origin = (p / block) * block;
112 uvec3 first = sampleSourceU8(p, size);
113 uvec3 second = sampleSourceU8(origin + ivec2(iFrame, effectDirection()), size);
114 return toRGB((first ^ second) & uvec3(255u));
115}
116
117/**
118 * @brief Executes the compute shader entry point.
119 */
120void main() {
121 ivec2 p = ivec2(gl_GlobalInvocationID.xy);
122 ivec2 size = imageSize(outputImage);
123 if (any(greaterThanEqual(p, size)))
124 return;
125 vec3 color = xorGrid(p, size);
126 imageStore(outputImage, p, vec4(clamp(color, 0.0, 1.0), 1.0));
127}
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
ivec2 clampPos(ivec2 p, ivec2 size)
Evaluates clampPos for this shader effect.
int effectBlockSize()
Evaluates effectBlockSize for this shader effect.
vec2 pixelUv(ivec2 p, ivec2 size)
Evaluates pixelUv for this shader effect.
vec3 sampleSource(ivec2 p, ivec2 size)
Evaluates sampleSource for this shader effect.
const float INV_255
uvec3 toU8(vec3 color)
Evaluates toU8 for this shader effect.
vec3 toRGB(uvec3 color)
Evaluates toRGB for this shader effect.
uvec3 sampleSourceU8(ivec2 p, ivec2 size)
Evaluates sampleSourceU8 for this shader effect.
int effectDirection()
Evaluates effectDirection for this shader effect.
vec3 xorGrid(ivec2 p, ivec2 size)
Evaluates xorGrid for this shader effect.
#define iFrame
Definition auraXi1.frag:18
#define alpha
Definition color_g.frag:17