Skip to content

Commit

Permalink
PlatformCore: Adjust color correction shaders
Browse files Browse the repository at this point in the history
Drop the output gamma correction, as that's handled by the driver for
sRGB-encoded framebuffer.
  • Loading branch information
GranMinigun committed Oct 6, 2023
1 parent 6c1c5a4 commit 4eb87f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
8 changes: 3 additions & 5 deletions src/platform/core/src/device/shader/color_agb.glsl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ constexpr auto color_agb_frag = R"(
#define darken_screen 1.0
#define target_gamma 2.2
#define display_gamma 2.2
#define sat 1.0
#define lum 0.94
#define contrast 1.0
Expand Down Expand Up @@ -48,14 +47,14 @@ constexpr auto color_agb_frag = R"(
vec4 screen = pow(texture(u_screen_map, v_uv), vec4(target_gamma + darken_screen)).rgba;
vec4 avglum = vec4(0.5);
screen = mix(screen, avglum, (1.0 - contrast));
mat4 color = mat4(
r, rg, rb, 0.0, //red channel
gr, g, gb, 0.0, //green channel
br, bg, b, 0.0, //blue channel
blr, blg, blb, 0.0 //alpha channel; these numbers do nothing for our purposes.
);
mat4 adjust = mat4(
(1.0 - sat) * 0.3086 + sat, (1.0 - sat) * 0.3086, (1.0 - sat) * 0.3086, 1.0,
(1.0 - sat) * 0.6094, (1.0 - sat) * 0.6094 + sat, (1.0 - sat) * 0.6094, 1.0,
Expand All @@ -67,7 +66,6 @@ constexpr auto color_agb_frag = R"(
screen = clamp(screen * lum, 0.0, 1.0);
screen = color * screen;
frag_color = pow(screen, vec4(1.0 / display_gamma));
frag_color.a = 1;
frag_color = vec4(screen.rgb, 1.0);
}
)";
14 changes: 5 additions & 9 deletions src/platform/core/src/device/shader/color_higan.glsl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ constexpr auto color_higan_frag = R"(
color.rgb = pow(color.rgb, vec3(4.0));
frag_color = vec4(
pow(
vec3(
1.000 * color.r + 0.196 * color.g,
0.039 * color.r + 0.901 * color.g + 0.117 * color.b,
0.196 * color.r + 0.039 * color.g + 0.862 * color.b
),
vec3(1.0 / 2.2)
), 1.0);
1.000 * color.r + 0.196 * color.g,
0.039 * color.r + 0.901 * color.g + 0.117 * color.b,
0.196 * color.r + 0.039 * color.g + 0.862 * color.b,
1.0);
}
)";
)";

0 comments on commit 4eb87f0

Please sign in to comment.