2021-02-21 18:30:12 +01:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
layout(set = 0, binding = 0) uniform sampler2D tex;
|
|
|
|
|
|
|
|
layout(location = 0) in vec2 uv;
|
|
|
|
layout(location = 0) out vec4 out_color;
|
|
|
|
|
|
|
|
layout(push_constant) uniform UBO {
|
|
|
|
layout(offset = 80) float alpha;
|
|
|
|
} data;
|
|
|
|
|
2022-11-12 04:53:06 +01:00
|
|
|
layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
|
|
|
|
|
2023-05-24 11:25:30 +02:00
|
|
|
// Matches enum wlr_vk_texture_transform
|
2022-11-12 04:53:06 +01:00
|
|
|
#define TEXTURE_TRANSFORM_IDENTITY 0
|
|
|
|
#define TEXTURE_TRANSFORM_SRGB 1
|
|
|
|
|
|
|
|
float srgb_to_linear(float x) {
|
|
|
|
return max(x / 12.92, pow((x + 0.055) / 1.055, 2.4));
|
|
|
|
}
|
|
|
|
|
2021-02-21 18:30:12 +01:00
|
|
|
void main() {
|
2022-11-12 04:53:06 +01:00
|
|
|
vec4 val = textureLod(tex, uv, 0);
|
|
|
|
if (TEXTURE_TRANSFORM == TEXTURE_TRANSFORM_SRGB) {
|
|
|
|
out_color = vec4(
|
|
|
|
srgb_to_linear(val.r),
|
|
|
|
srgb_to_linear(val.g),
|
|
|
|
srgb_to_linear(val.b),
|
|
|
|
val.a
|
|
|
|
);
|
|
|
|
} else { // TEXTURE_TRANSFORM_IDENTITY
|
|
|
|
out_color = val;
|
|
|
|
}
|
|
|
|
|
2021-10-16 16:31:48 +02:00
|
|
|
out_color *= data.alpha;
|
2021-02-21 18:30:12 +01:00
|
|
|
}
|
|
|
|
|