post-processing: rework gamma correction (#1756)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

This commit is contained in:
setepenre 2024-12-22 16:18:07 +01:00 committed by GitHub
parent ab5240d8d2
commit 8a409d86d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -12,8 +12,14 @@ layout(push_constant) uniform settings {
float gamma;
} pp;
const float cutoff = 0.0031308, a = 1.055, b = 0.055, d = 12.92;
vec3 gamma(vec3 rgb)
{
return mix(a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b, d * rgb / pp.gamma, lessThan(rgb, vec3(cutoff)));
}
void main()
{
vec4 color_linear = texture(texSampler, uv);
color = pow(color_linear, vec4(1.0/(2.2 + 1.0 - pp.gamma)));
color = vec4(gamma(color_linear.rgb), color_linear.a);
}

View file

@ -154,7 +154,7 @@ void Presenter::CreatePostProcessPipeline() {
const auto& fs_module =
Vulkan::Compile(pp_shaders[1], vk::ShaderStageFlagBits::eFragment, instance.GetDevice());
ASSERT(fs_module);
Vulkan::SetObjectName(instance.GetDevice(), vs_module, "post_process.frag");
Vulkan::SetObjectName(instance.GetDevice(), fs_module, "post_process.frag");
const std::array shaders_ci{
vk::PipelineShaderStageCreateInfo{