ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_019_hue_rotate.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_019_hue_rotate.comp
5 * @brief Vulkan compute shader: acidcam 019 hue rotate.
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 iTime ext.u0.y
18
19
20layout(local_size_x = 16, local_size_y = 16) in;
21layout(set = 0, binding = 5, rgba8) writeonly uniform image2D outputImage;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25/**
26 * @brief Evaluates clampPos for this shader effect.
27 * @param p Input value for the calculation.
28 * @param size Input value for the calculation.
29 * @return Computed ivec2 value.
30 */
31ivec2 clampPos(ivec2 p, ivec2 size) {
32 return clamp(p, ivec2(0), size - ivec2(1));
33}
34
35/**
36 * @brief Evaluates pixelUv for this shader effect.
37 * @param p Input value for the calculation.
38 * @param size Input value for the calculation.
39 * @return Computed vec2 value.
40 */
41vec2 pixelUv(ivec2 p, ivec2 size) {
42 return (vec2(clampPos(p, size)) + 0.5) / vec2(size);
43}
44
45/**
46 * @brief Evaluates sampleSource for this shader effect.
47 * @param p Input value for the calculation.
48 * @param size Input value for the calculation.
49 * @return Computed vec3 value.
50 */
51vec3 sampleSource(ivec2 p, ivec2 size) {
52 return textureLod(samp, pixelUv(p, size), 0.0).rgb;
53}
54
55/**
56 * @brief Evaluates hueRotate for this shader effect.
57 * @param color Input value for the calculation.
58 * @param angle Input value for the calculation.
59 * @return Computed vec3 value.
60 */
61vec3 hueRotate(vec3 color, float angle) {
62 vec3 axis = normalize(vec3(1.0));
63 float sine = sin(angle);
64 float cosine = cos(angle);
65 return clamp(color * cosine + cross(axis, color) * sine +
66 axis * dot(axis, color) * (1.0 - cosine),
67 0.0, 1.0);
68}
69
70/**
71 * @brief Executes the compute shader entry point.
72 */
73void main() {
74 ivec2 p = ivec2(gl_GlobalInvocationID.xy);
75 ivec2 size = imageSize(outputImage);
76 if (any(greaterThanEqual(p, size)))
77 return;
78 vec3 color = hueRotate(sampleSource(p, size), iTime * 0.7);
79 imageStore(outputImage, p, 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
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 hueRotate(vec3 color, float angle)
Evaluates hueRotate for this shader effect.