feat: Use sRGB LUT for cells

This commit is contained in:
Martin Wernstål 2023-01-23 19:23:46 +01:00
parent b10c18b8fe
commit 8ece895774
2 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,7 @@ uniform uint draw_bg_bitfield;
layout(location=0) in uvec3 colors;
layout(location=1) in uvec4 sprite_coords;
layout(location=2) in uint is_selected;
uniform float gamma_lut[256];
const int fg_index_map[] = int[3](0, 1, 0);
@ -87,7 +88,7 @@ vec3 color_to_vec(uint c) {
r = (c >> 16) & BYTE_MASK;
g = (c >> 8) & BYTE_MASK;
b = c & BYTE_MASK;
return vec3(float(r) / 255.0, float(g) / 255.0, float(b) / 255.0);
return vec3(gamma_lut[r], gamma_lut[g], gamma_lut[b]);
}
uint resolve_color(uint c, uint defval) {

View File

@ -570,6 +570,10 @@ set_cell_uniforms(float current_inactive_text_alpha, bool force) {
S(CELL_PROGRAM, dim_opacity, OPT(dim_opacity), 1f); S(CELL_FG_PROGRAM, dim_opacity, OPT(dim_opacity), 1f);
S(CELL_BG_PROGRAM, defaultbg, OPT(background), 1f);
#undef S
#define SV(prog, name, num, val, type) { bind_program(prog); glUniform##type(glGetUniformLocation(program_id(prog), #name), num, val); }
SV(CELL_PROGRAM, gamma_lut, 256, srgb_lut, 1fv); SV(CELL_FG_PROGRAM, gamma_lut, 256, srgb_lut, 1fv);
SV(CELL_BG_PROGRAM, gamma_lut, 256, srgb_lut, 1fv); SV(CELL_SPECIAL_PROGRAM, gamma_lut, 256, srgb_lut, 1fv);
#undef SV
cell_uniform_data.constants_set = true;
}
if (current_inactive_text_alpha != cell_uniform_data.prev_inactive_text_alpha || force) {