@@ -454,6 +454,13 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
454454
455455 Color base_color = p_item->final_modulate ;
456456 bool use_linear_colors = texture_storage->render_target_is_using_hdr (p_render_target);
457+ if (use_linear_colors) {
458+ base_color = base_color.srgb_to_linear ();
459+ }
460+ per_instance_buffer.base_color [0 ] = base_color.r ;
461+ per_instance_buffer.base_color [1 ] = base_color.g ;
462+ per_instance_buffer.base_color [2 ] = base_color.b ;
463+ per_instance_buffer.base_color [3 ] = base_color.a ;
457464
458465 for (int i = 0 ; i < 4 ; i++) {
459466 per_instance_buffer.modulation [i] = 0 ;
@@ -583,7 +590,7 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
583590 per_instance_buffer.flags |= FLAGS_USE_LCD;
584591 }
585592
586- Color modulated = rect->modulate * base_color ;
593+ Color modulated = rect->modulate ;
587594 if (use_linear_colors) {
588595 modulated = modulated.srgb_to_linear ();
589596 }
@@ -632,7 +639,7 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
632639 }
633640 }
634641
635- Color modulated = np->color * base_color ;
642+ Color modulated = np->color ;
636643 if (use_linear_colors) {
637644 modulated = modulated.srgb_to_linear ();
638645 }
@@ -682,15 +689,10 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
682689
683690 _prepare_canvas_texture_data (polygon->texture , current_filter, current_repeat, last_texture, per_instance_buffer, texpixel_size);
684691
685- Color color = base_color;
686- if (use_linear_colors) {
687- color = color.srgb_to_linear ();
688- }
689-
690- per_instance_buffer.modulation [0 ] = color.r ;
691- per_instance_buffer.modulation [1 ] = color.g ;
692- per_instance_buffer.modulation [2 ] = color.b ;
693- per_instance_buffer.modulation [3 ] = color.a ;
692+ per_instance_buffer.modulation [0 ] = 1.0 ;
693+ per_instance_buffer.modulation [1 ] = 1.0 ;
694+ per_instance_buffer.modulation [2 ] = 1.0 ;
695+ per_instance_buffer.modulation [3 ] = 1.0 ;
694696
695697 for (int j = 0 ; j < 4 ; j++) {
696698 per_instance_buffer.src_rect [j] = 0 ;
@@ -715,7 +717,7 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
715717 per_instance_buffer.points [j * 2 + 1 ] = primitive->points [j].y ;
716718 per_instance_buffer.uvs [j * 2 + 0 ] = primitive->uvs [j].x ;
717719 per_instance_buffer.uvs [j * 2 + 1 ] = primitive->uvs [j].y ;
718- Color col = primitive->colors [j] * base_color ;
720+ Color col = primitive->colors [j];
719721 if (use_linear_colors) {
720722 col = col.srgb_to_linear ();
721723 }
@@ -731,7 +733,7 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
731733 per_instance_buffer.points [j * 2 + 1 ] = primitive->points [j + 1 ].y ;
732734 per_instance_buffer.uvs [j * 2 + 0 ] = primitive->uvs [j + 1 ].x ;
733735 per_instance_buffer.uvs [j * 2 + 1 ] = primitive->uvs [j + 1 ].y ;
734- Color col = primitive->colors [j + 1 ] * base_color ;
736+ Color col = primitive->colors [j + 1 ];
735737 if (use_linear_colors) {
736738 col = col.srgb_to_linear ();
737739 }
@@ -840,7 +842,7 @@ void RendererCanvasRenderRD::_prepare_item_data(RID p_render_target, const Item
840842
841843 uint32_t surf_count = mesh_storage->mesh_get_surface_count (mesh);
842844
843- Color modulated = modulate * base_color ;
845+ Color modulated = modulate;
844846 if (use_linear_colors) {
845847 modulated = modulated.srgb_to_linear ();
846848 }
@@ -2860,6 +2862,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
28602862 actions.renames [" INSTANCE_CUSTOM" ] = " instance_custom" ;
28612863
28622864 actions.renames [" COLOR" ] = " color" ;
2865+ actions.renames [" MODULATE" ] = " modulate" ;
28632866 actions.renames [" NORMAL" ] = " normal" ;
28642867 actions.renames [" NORMAL_MAP" ] = " normal_map" ;
28652868 actions.renames [" NORMAL_MAP_DEPTH" ] = " normal_map_depth" ;
@@ -2892,6 +2895,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
28922895 actions.renames [" screen_uv_to_sdf" ] = " screen_uv_to_sdf" ;
28932896
28942897 actions.usage_defines [" COLOR" ] = " #define COLOR_USED\n " ;
2898+ actions.usage_defines [" MODULATE" ] = " #define MODULATE_USED\n " ;
28952899 actions.usage_defines [" SCREEN_UV" ] = " #define SCREEN_UV_USED\n " ;
28962900 actions.usage_defines [" SCREEN_PIXEL_SIZE" ] = " @SCREEN_UV" ;
28972901 actions.usage_defines [" NORMAL" ] = " #define NORMAL_USED\n " ;
0 commit comments