diff options
author | Feiyue Zhang <feiyue_zhang@brown.edu> | 2024-07-01 16:05:41 +0800 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-07-24 09:49:50 +0200 |
commit | 6f30df4b6ab3a53ae676224ea45412b9c1624adf (patch) | |
tree | 528e02a6ab07e7a47dedff1ac77fca81be3bdaa6 /drivers/gles3 | |
parent | 8e36f98ea5b5ab4c1fb5249f94b61a7bbfb379a1 (diff) | |
download | redot-engine-6f30df4b6ab3a53ae676224ea45412b9c1624adf.tar.gz |
Linearize color if HDR 2D is on
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 941b1a1b28..8e9b0c2f29 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -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; |