ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_036_noise_block_displacement.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_036_noise_block_displacement.comp
5 * @brief Vulkan compute shader: acidcam 036 noise block displacement.
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 hash12 for this shader effect.
29 * @param value Input value for the calculation.
30 * @return Computed float value.
31 */
32float hash12(vec2 value) {
33 return fract(sin(dot(value, vec2(127.1, 311.7))) * 43758.5453);
34}
35
36/**
37 * @brief Evaluates source at for this shader effect.
38 * @param position Input value for the calculation.
39 * @param size Input value for the calculation.
40 * @return Computed vec3 value.
41 */
42vec3 source_at(ivec2 position, ivec2 size) {
43 position = clamp(position, ivec2(0), size - 1);
44 return textureLod(samp, (vec2(position) + 0.5) / vec2(size), 0.0).rgb;
45}
46
47/**
48 * @brief Executes the compute shader entry point.
49 */
50void main() {
51 ivec2 position = ivec2(gl_GlobalInvocationID.xy);
52 ivec2 size = imageSize(outputImage);
53 if (any(greaterThanEqual(position, size)))
54 return;
55
56 float strength = clamp(alpha, 0.0, 1.0);
57 ivec2 block_size = ivec2(max(4, int(mix(32.0, 8.0, strength))),
58 max(2, int(mix(14.0, 4.0, strength))));
59 ivec2 block = position / block_size;
60 float frame_step = floor(float(iFrame) / 3.0);
61 float random_value = hash12(vec2(block) + vec2(frame_step, -frame_step * 0.37));
62 float block_gate = step(1.0 - 0.72 * strength, random_value);
63
64 int horizontal_shift = int((hash12(vec2(block.y, frame_step)) - 0.5) *
65 float(size.x) * 0.30 * strength);
66 int vertical_shift = int((hash12(vec2(block.x, frame_step + 17.0)) - 0.5) *
67 24.0 * strength);
68 ivec2 displaced = position + ivec2(horizontal_shift, vertical_shift) * int(block_gate);
69 vec3 source = source_at(position, size);
70 vec3 shifted = source_at(displaced, size);
71
72 float static_noise = hash12(vec2(position) + frame_step * vec2(13.0, 7.0));
73 vec3 digital_noise = vec3(static_noise,
74 hash12(vec2(position.yx) + frame_step * 11.0),
75 1.0 - static_noise);
76 float noise_gate = block_gate * step(0.84, hash12(vec2(block) + 41.0));
77 vec3 color = mix(source, shifted.brg, block_gate * (0.45 + 0.55 * strength));
78 color = mix(color, digital_noise, noise_gate * 0.70);
79 imageStore(outputImage, position, vec4(clamp(color, 0.0, 1.0), 1.0));
80}
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
vec3 source_at(vec2 position, ivec2 size)
Evaluates source at 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
#define strength
Definition ol.frag:16