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