mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-06 09:08:33 +02:00
gl-renderer: add offset to the color mapping matrix
The offset will be useful for black point handling. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
42059ce258
commit
b15dcfe790
3 changed files with 16 additions and 5 deletions
|
|
@ -389,6 +389,7 @@ struct weston_color_mapping_3dlut {
|
|||
*/
|
||||
struct weston_color_mapping_matrix {
|
||||
struct weston_mat3f matrix;
|
||||
struct weston_vec3f offset;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ uniform HIGHPRECISION sampler3D color_mapping_lut_3d;
|
|||
uniform HIGHPRECISION vec2 color_mapping_lut_scale_offset;
|
||||
#endif
|
||||
uniform HIGHPRECISION mat3 color_mapping_matrix;
|
||||
uniform HIGHPRECISION vec3 color_mapping_offset;
|
||||
|
||||
/*
|
||||
* 2D texture sampler abstracting away the lack of swizzles on OpenGL ES 2. This
|
||||
|
|
@ -450,7 +451,7 @@ color_mapping(vec3 color)
|
|||
else if (c_color_mapping == SHADER_COLOR_MAPPING_3DLUT)
|
||||
return sample_color_mapping_lut_3d(color);
|
||||
else if (c_color_mapping == SHADER_COLOR_MAPPING_MATRIX)
|
||||
return color_mapping_matrix * color.rgb;
|
||||
return color_mapping_matrix * color.rgb + color_mapping_offset;
|
||||
else /* Never reached, bad c_color_mapping. */
|
||||
return vec3(1.0, 0.3, 1.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,10 @@ union gl_shader_color_mapping_uniforms {
|
|||
GLint tex_uniform;
|
||||
GLint scale_offset_uniform;
|
||||
} lut3d;
|
||||
GLint matrix_uniform;
|
||||
struct {
|
||||
GLint matrix_uniform;
|
||||
GLint offset_uniform;
|
||||
} mat;
|
||||
};
|
||||
|
||||
struct gl_shader {
|
||||
|
|
@ -457,9 +460,12 @@ gl_shader_create(struct gl_renderer *gr,
|
|||
"color_mapping_lut_scale_offset");
|
||||
break;
|
||||
case SHADER_COLOR_MAPPING_MATRIX:
|
||||
shader->color_mapping.matrix_uniform =
|
||||
shader->color_mapping.mat.matrix_uniform =
|
||||
glGetUniformLocation(shader->program,
|
||||
"color_mapping_matrix");
|
||||
shader->color_mapping.mat.offset_uniform =
|
||||
glGetUniformLocation(shader->program,
|
||||
"color_mapping_offset");
|
||||
break;
|
||||
case SHADER_COLOR_MAPPING_IDENTITY:
|
||||
break;
|
||||
|
|
@ -701,9 +707,12 @@ gl_shader_load_config_mapping(struct weston_compositor *compositor,
|
|||
sconf->lut3d.scale, sconf->lut3d.offset);
|
||||
return;
|
||||
case SHADER_COLOR_MAPPING_MATRIX:
|
||||
assert(unif->matrix_uniform != -1);
|
||||
glUniformMatrix3fv(unif->matrix_uniform,
|
||||
assert(unif->mat.matrix_uniform != -1);
|
||||
assert(unif->mat.offset_uniform != -1);
|
||||
|
||||
glUniformMatrix3fv(unif->mat.matrix_uniform,
|
||||
1, GL_FALSE, sconf->mat.matrix.colmaj);
|
||||
glUniform3fv(unif->mat.offset_uniform, 1, sconf->mat.offset.el);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue