aboutsummaryrefslogtreecommitdiff
path: root/render/vulkan/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'render/vulkan/shaders')
-rw-r--r--render/vulkan/shaders/texture.frag22
1 files changed, 21 insertions, 1 deletions
diff --git a/render/vulkan/shaders/texture.frag b/render/vulkan/shaders/texture.frag
index 0f9c52f1..15ef52af 100644
--- a/render/vulkan/shaders/texture.frag
+++ b/render/vulkan/shaders/texture.frag
@@ -9,8 +9,28 @@ layout(push_constant) uniform UBO {
layout(offset = 80) float alpha;
} data;
+layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
+
+#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));
+}
+
void main() {
- out_color = textureLod(tex, uv, 0);
+ 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;
+ }
+
out_color *= data.alpha;
}