2022-11-20 03:47:27 +01:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
layout (input_attachment_index = 0, binding = 0) uniform subpassInput in_color;
|
|
|
|
|
|
|
|
layout(location = 0) in vec2 uv;
|
|
|
|
layout(location = 0) out vec4 out_color;
|
|
|
|
|
2023-10-17 12:21:08 +02:00
|
|
|
float linear_channel_to_srgb(float x) {
|
2022-11-20 03:47:27 +01:00
|
|
|
return max(min(x * 12.92, 0.04045), 1.055 * pow(x, 1. / 2.4) - 0.055);
|
|
|
|
}
|
|
|
|
|
2023-10-17 12:21:08 +02:00
|
|
|
vec4 linear_color_to_srgb(vec4 color) {
|
|
|
|
if (color.a == 0) {
|
|
|
|
return vec4(0);
|
|
|
|
}
|
|
|
|
color.rgb /= color.a;
|
|
|
|
color.rgb = vec3(
|
|
|
|
linear_channel_to_srgb(color.r),
|
|
|
|
linear_channel_to_srgb(color.g),
|
|
|
|
linear_channel_to_srgb(color.b)
|
2022-11-20 03:47:27 +01:00
|
|
|
);
|
2023-10-17 12:21:08 +02:00
|
|
|
color.rgb *= color.a;
|
|
|
|
return color;
|
2022-11-20 03:47:27 +01:00
|
|
|
}
|
|
|
|
|
2023-10-17 12:21:08 +02:00
|
|
|
void main() {
|
|
|
|
vec4 val = subpassLoad(in_color).rgba;
|
|
|
|
out_color = linear_color_to_srgb(val);
|
|
|
|
}
|