mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
render/vulkan: add luminance multiplier for texture shader
This commit is contained in:
parent
fa1feb447f
commit
ae85c31176
3 changed files with 14 additions and 0 deletions
|
|
@ -343,6 +343,7 @@ struct wlr_vk_vert_pcr_data {
|
||||||
struct wlr_vk_frag_texture_pcr_data {
|
struct wlr_vk_frag_texture_pcr_data {
|
||||||
float matrix[4][4]; // only a 3x3 subset is used
|
float matrix[4][4]; // only a 3x3 subset is used
|
||||||
float alpha;
|
float alpha;
|
||||||
|
float luminance_multiplier;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_vk_frag_output_pcr_data {
|
struct wlr_vk_frag_output_pcr_data {
|
||||||
|
|
|
||||||
|
|
@ -849,8 +849,18 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
|
||||||
wlr_matrix_identity(color_matrix);
|
wlr_matrix_identity(color_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float luminance_multiplier = 1;
|
||||||
|
if (tf != WLR_COLOR_TRANSFER_FUNCTION_SRGB) {
|
||||||
|
struct wlr_color_luminances src_lum, srgb_lum;
|
||||||
|
wlr_color_transfer_function_get_default_luminance(tf, &src_lum);
|
||||||
|
wlr_color_transfer_function_get_default_luminance(
|
||||||
|
WLR_COLOR_TRANSFER_FUNCTION_SRGB, &srgb_lum);
|
||||||
|
luminance_multiplier = get_luminance_multiplier(&src_lum, &srgb_lum);
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_vk_frag_texture_pcr_data frag_pcr_data = {
|
struct wlr_vk_frag_texture_pcr_data frag_pcr_data = {
|
||||||
.alpha = alpha,
|
.alpha = alpha,
|
||||||
|
.luminance_multiplier = luminance_multiplier,
|
||||||
};
|
};
|
||||||
encode_color_matrix(color_matrix, frag_pcr_data.matrix);
|
encode_color_matrix(color_matrix, frag_pcr_data.matrix);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ layout(location = 0) out vec4 out_color;
|
||||||
layout(push_constant, row_major) uniform UBO {
|
layout(push_constant, row_major) uniform UBO {
|
||||||
layout(offset = 80) mat4 matrix;
|
layout(offset = 80) mat4 matrix;
|
||||||
float alpha;
|
float alpha;
|
||||||
|
float luminance_multiplier;
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
|
layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
|
||||||
|
|
@ -61,6 +62,8 @@ void main() {
|
||||||
rgb = pq_color_to_linear(rgb);
|
rgb = pq_color_to_linear(rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rgb *= data.luminance_multiplier;
|
||||||
|
|
||||||
rgb = mat3(data.matrix) * rgb;
|
rgb = mat3(data.matrix) * rgb;
|
||||||
|
|
||||||
// Back to pre-multiplied alpha
|
// Back to pre-multiplied alpha
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue