ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_038_block_shuffle.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_038_block_shuffle.comp
5 * @brief Vulkan compute shader: acidcam 038 block shuffle.
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
27/**
28 * @brief Evaluates clampPos for this shader effect.
29 * @param p Input value for the calculation.
30 * @param size Input value for the calculation.
31 * @return Computed ivec2 value.
32 */
33ivec2 clampPos(ivec2 p, ivec2 size) {
34 return clamp(p, ivec2(0), size - ivec2(1));
35}
36
37/**
38 * @brief Evaluates pixelUv for this shader effect.
39 * @param p Input value for the calculation.
40 * @param size Input value for the calculation.
41 * @return Computed vec2 value.
42 */
43vec2 pixelUv(ivec2 p, ivec2 size) {
44 return (vec2(clampPos(p, size)) + 0.5) / vec2(size);
45}
46
47/**
48 * @brief Evaluates sampleSource for this shader effect.
49 * @param p Input value for the calculation.
50 * @param size Input value for the calculation.
51 * @return Computed vec3 value.
52 */
53vec3 sampleSource(ivec2 p, ivec2 size) {
54 return textureLod(samp, pixelUv(p, size), 0.0).rgb;
55}
56
57/**
58 * @brief Evaluates effectBlockSize for this shader effect.
59 * @return Computed int value.
60 */
62 return max(int(round(mix(2.0, 64.0, clamp(alpha, 0.0, 1.0)))), 1);
63}
64
65/**
66 * @brief Evaluates effectDirection for this shader effect.
67 * @return Computed int value.
68 */
70 return ((iFrame / 8) & 1) == 0 ? 1 : -1;
71}
72
73/**
74 * @brief Evaluates hash12 for this shader effect.
75 * @param p Input value for the calculation.
76 * @return Computed float value.
77 */
78float hash12(vec2 p) {
79 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
80}
81
82/**
83 * @brief Evaluates blockShuffle for this shader effect.
84 * @param p Input value for the calculation.
85 * @param size Input value for the calculation.
86 * @return Computed vec3 value.
87 */
88vec3 blockShuffle(ivec2 p, ivec2 size) {
89 int block = effectBlockSize();
90 ivec2 base = (p / block) * block;
91 vec2 key = vec2(base) + vec2(float(iFrame), float(effectDirection()) * 19.0);
92 ivec2 offset = ivec2(int(hash12(key + vec2(4.1, 1.7)) * float(block)),
93 int(hash12(key + vec2(2.3, 8.8)) * float(block)));
94 return sampleSource(base + offset + (p - base), size);
95}
96
97/**
98 * @brief Executes the compute shader entry point.
99 */
100void main() {
101 ivec2 p = ivec2(gl_GlobalInvocationID.xy);
102 ivec2 size = imageSize(outputImage);
103 if (any(greaterThanEqual(p, size)))
104 return;
105 vec3 color = blockShuffle(p, size);
106 imageStore(outputImage, p, vec4(clamp(color, 0.0, 1.0), 1.0));
107}
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.
int effectDirection()
Evaluates effectDirection for this shader effect.
vec3 blockShuffle(ivec2 p, ivec2 size)
Evaluates blockShuffle for this shader effect.
float hash12(vec2 p)
Evaluates hash12 for this shader effect.
#define iFrame
Definition auraXi1.frag:18
#define alpha
Definition color_g.frag:17