From 5eae82ab331b2a46ad1171fa7c14763f91792e92 Mon Sep 17 00:00:00 2001 From: niki Date: Wed, 15 Feb 2023 01:22:38 +0100 Subject: [PATCH] vulkan: fix gammacorrect in Graphics::clear --- src/modules/graphics/vulkan/Graphics.cpp | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index e21097959..2131e4977 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -159,10 +159,14 @@ void Graphics::clear(OptionalColorD color, OptionalInt stencil, OptionalDouble d if (color.hasValue) { renderPassState.renderPassConfiguration.colorAttachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - renderPassState.clearColors[0].color.float32[0] = static_cast(color.value.r); - renderPassState.clearColors[0].color.float32[1] = static_cast(color.value.g); - renderPassState.clearColors[0].color.float32[2] = static_cast(color.value.b); - renderPassState.clearColors[0].color.float32[3] = static_cast(color.value.a); + + Colorf cf((float)color.value.r, (float)color.value.g, (float)color.value.b, (float)color.value.a); + gammaCorrectColor(cf); + + renderPassState.clearColors[0].color.float32[0] = static_cast(cf.r); + renderPassState.clearColors[0].color.float32[1] = static_cast(cf.g); + renderPassState.clearColors[0].color.float32[2] = static_cast(cf.b); + renderPassState.clearColors[0].color.float32[3] = static_cast(cf.a); } if (depth.hasValue) @@ -248,10 +252,15 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten if (colors[i].hasValue) { renderPassState.renderPassConfiguration.colorAttachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - renderPassState.clearColors[i].color.float32[0] = static_cast(colors[i].value.r); - renderPassState.clearColors[i].color.float32[1] = static_cast(colors[i].value.g); - renderPassState.clearColors[i].color.float32[2] = static_cast(colors[i].value.b); - renderPassState.clearColors[i].color.float32[3] = static_cast(colors[i].value.a); + + auto &color = colors[i]; + Colorf cf((float)color.value.r, (float)color.value.g, (float)color.value.b, (float)color.value.a); + gammaCorrectColor(cf); + + renderPassState.clearColors[i].color.float32[0] = static_cast(cf.r); + renderPassState.clearColors[i].color.float32[1] = static_cast(cf.g); + renderPassState.clearColors[i].color.float32[2] = static_cast(cf.b); + renderPassState.clearColors[i].color.float32[3] = static_cast(cf.a); } }