ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_033_zoom_pulse.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_033_zoom_pulse.comp
5 * @brief Vulkan compute shader: acidcam 033 zoom pulse.
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 iTime ext.u0.y
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 zoomPulse for this shader effect.
59 * @param p Input value for the calculation.
60 * @param size Input value for the calculation.
61 * @return Computed vec3 value.
62 */
63vec3 zoomPulse(ivec2 p, ivec2 size) {
64 vec2 center = vec2(size) * 0.5;
65 vec2 delta = vec2(p) - center;
66 float pulse = 1.0 + 0.12 * sin(iTime * 2.0);
67 float scale = mix(1.0, pulse, clamp(alpha, 0.0, 1.0));
68 return sampleSource(ivec2(center + delta / scale), size);
69}
70
71/**
72 * @brief Executes the compute shader entry point.
73 */
74void main() {
75 ivec2 p = ivec2(gl_GlobalInvocationID.xy);
76 ivec2 size = imageSize(outputImage);
77 if (any(greaterThanEqual(p, size)))
78 return;
79 vec3 color = zoomPulse(p, size);
80 imageStore(outputImage, p, vec4(clamp(color, 0.0, 1.0), 1.0));
81}
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.
vec2 pixelUv(ivec2 p, ivec2 size)
Evaluates pixelUv for this shader effect.
vec3 sampleSource(ivec2 p, ivec2 size)
Evaluates sampleSource for this shader effect.
vec3 zoomPulse(ivec2 p, ivec2 size)
Evaluates zoomPulse for this shader effect.
#define alpha
Definition color_g.frag:17