Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent CanvasModulate color in 2D HDR #93802

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,15 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
normal_transform.columns[2] = Vector2();
_update_transform_2d_to_mat4(normal_transform, state_buffer.canvas_normal_transform);

state_buffer.canvas_modulate[0] = p_modulate.r;
state_buffer.canvas_modulate[1] = p_modulate.g;
state_buffer.canvas_modulate[2] = p_modulate.b;
state_buffer.canvas_modulate[3] = p_modulate.a;
bool use_linear_colors = texture_storage->render_target_is_using_hdr(p_to_render_target);
Color modulate = p_modulate;
if (use_linear_colors) {
modulate = p_modulate.srgb_to_linear();
}
state_buffer.canvas_modulate[0] = modulate.r;
state_buffer.canvas_modulate[1] = modulate.g;
state_buffer.canvas_modulate[2] = modulate.b;
state_buffer.canvas_modulate[3] = modulate.a;

Size2 render_target_size = texture_storage->render_target_get_size(p_to_render_target);
state_buffer.screen_pixel_size[0] = 1.0 / render_target_size.x;
Expand Down
13 changes: 9 additions & 4 deletions servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,10 +1451,15 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
normal_transform.columns[2] = Vector2();
_update_transform_2d_to_mat4(normal_transform, state_buffer.canvas_normal_transform);

state_buffer.canvas_modulate[0] = p_modulate.r;
state_buffer.canvas_modulate[1] = p_modulate.g;
state_buffer.canvas_modulate[2] = p_modulate.b;
state_buffer.canvas_modulate[3] = p_modulate.a;
bool use_linear_colors = texture_storage->render_target_is_using_hdr(p_to_render_target);
Color modulate = p_modulate;
if (use_linear_colors) {
modulate = p_modulate.srgb_to_linear();
}
state_buffer.canvas_modulate[0] = modulate.r;
state_buffer.canvas_modulate[1] = modulate.g;
state_buffer.canvas_modulate[2] = modulate.b;
state_buffer.canvas_modulate[3] = modulate.a;

Size2 render_target_size = texture_storage->render_target_get_size(p_to_render_target);
state_buffer.screen_pixel_size[0] = 1.0 / render_target_size.x;
Expand Down
Loading