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