Skip to content

Commit a322d64

Browse files
committed
Fix gamma brightness logic
1 parent ccfb1bb commit a322d64

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/video_core/host_shaders/post_process.frag

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ layout(push_constant) uniform settings {
1212
float gamma;
1313
} pp;
1414

15+
const float cutoff = 0.0031308, a = 1.055, b = 0.055, d = 12.92;
16+
vec3 linear_to_srgb(vec3 rgb) {
17+
return mix(a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b, d * rgb, step(rgb, vec3(cutoff)));
18+
}
19+
1520
void main()
1621
{
1722
vec4 color_linear = texture(texSampler, uv);
18-
color = pow(color_linear, vec4(1.0/(2.2 + 1.0 - pp.gamma)));
23+
color = vec4(linear_to_srgb(color_linear.rgb), color_linear.a);
1924
}

src/video_core/renderer_vulkan/vk_presenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void Presenter::CreatePostProcessPipeline() {
154154
const auto& fs_module =
155155
Vulkan::Compile(pp_shaders[1], vk::ShaderStageFlagBits::eFragment, instance.GetDevice());
156156
ASSERT(fs_module);
157-
Vulkan::SetObjectName(instance.GetDevice(), vs_module, "post_process.frag");
157+
Vulkan::SetObjectName(instance.GetDevice(), fs_module, "post_process.frag");
158158

159159
const std::array shaders_ci{
160160
vk::PipelineShaderStageCreateInfo{

0 commit comments

Comments
 (0)