diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2023-04-25 14:24:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 14:24:38 +0200 |
commit | d78691d44fe6e4f38dce3a89164cdae688772031 (patch) | |
tree | 26b6162338b2be9844691916f60a9b0878b79c1c /scene/resources | |
parent | 90b4ca2e506c6a0d432770d59f62ae7eea565ad0 (diff) | |
parent | b5bd99d9e6062f5820e7e51cdaee8d799c85f701 (diff) |
Merge pull request #76405 from YuriSizov/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 2nd batch
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 24 | ||||
-rw-r--r-- | scene/resources/particle_process_material.cpp | 4 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 72 | ||||
-rw-r--r-- | scene/resources/style_box.h | 2 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 12 |
5 files changed, 64 insertions, 50 deletions
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 2e1ba96d11..35c81ea91b 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -162,7 +162,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_font("font", "Button", Ref<Font>()); theme->set_font_size("font_size", "Button", -1); - theme->set_constant("outline_size", "Button", 0 * scale); + theme->set_constant("outline_size", "Button", 0); theme->set_color("font_color", "Button", control_font_color); theme->set_color("font_pressed_color", "Button", control_font_pressed_color); @@ -190,7 +190,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_font("font", "MenuBar", Ref<Font>()); theme->set_font_size("font_size", "MenuBar", -1); - theme->set_constant("outline_size", "MenuBar", 0 * scale); + theme->set_constant("outline_size", "MenuBar", 0); theme->set_color("font_color", "MenuBar", control_font_color); theme->set_color("font_pressed_color", "MenuBar", control_font_pressed_color); @@ -315,7 +315,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_outline_color", "CheckBox", Color(1, 1, 1)); theme->set_constant("h_separation", "CheckBox", 4 * scale); - theme->set_constant("check_v_offset", "CheckBox", 0 * scale); + theme->set_constant("check_v_offset", "CheckBox", 0); theme->set_constant("outline_size", "CheckBox", 0); // CheckButton @@ -352,7 +352,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_outline_color", "CheckButton", Color(1, 1, 1)); theme->set_constant("h_separation", "CheckButton", 4 * scale); - theme->set_constant("check_v_offset", "CheckButton", 0 * scale); + theme->set_constant("check_v_offset", "CheckButton", 0); theme->set_constant("outline_size", "CheckButton", 0); // Label @@ -1034,7 +1034,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * scale); theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * scale); - theme->set_constant("line_separation", "RichTextLabel", 0 * scale); + theme->set_constant("line_separation", "RichTextLabel", 0); theme->set_constant("table_h_separation", "RichTextLabel", 3 * scale); theme->set_constant("table_v_separation", "RichTextLabel", 3 * scale); @@ -1057,10 +1057,10 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("separation", "BoxContainer", 4 * scale); theme->set_constant("separation", "HBoxContainer", 4 * scale); theme->set_constant("separation", "VBoxContainer", 4 * scale); - theme->set_constant("margin_left", "MarginContainer", 0 * scale); - theme->set_constant("margin_top", "MarginContainer", 0 * scale); - theme->set_constant("margin_right", "MarginContainer", 0 * scale); - theme->set_constant("margin_bottom", "MarginContainer", 0 * scale); + theme->set_constant("margin_left", "MarginContainer", 0); + theme->set_constant("margin_top", "MarginContainer", 0); + theme->set_constant("margin_right", "MarginContainer", 0); + theme->set_constant("margin_bottom", "MarginContainer", 0); theme->set_constant("h_separation", "GridContainer", 4 * scale); theme->set_constant("v_separation", "GridContainer", 4 * scale); theme->set_constant("separation", "SplitContainer", 12 * scale); @@ -1069,9 +1069,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("minimum_grab_thickness", "SplitContainer", 6 * scale); theme->set_constant("minimum_grab_thickness", "HSplitContainer", 6 * scale); theme->set_constant("minimum_grab_thickness", "VSplitContainer", 6 * scale); - theme->set_constant("autohide", "SplitContainer", 1 * scale); - theme->set_constant("autohide", "HSplitContainer", 1 * scale); - theme->set_constant("autohide", "VSplitContainer", 1 * scale); + theme->set_constant("autohide", "SplitContainer", 1); + theme->set_constant("autohide", "HSplitContainer", 1); + theme->set_constant("autohide", "VSplitContainer", 1); theme->set_constant("h_separation", "FlowContainer", 4 * scale); theme->set_constant("v_separation", "FlowContainer", 4 * scale); theme->set_constant("h_separation", "HFlowContainer", 4 * scale); diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp index 7ae154ea1d..41edbcb726 100644 --- a/scene/resources/particle_process_material.cpp +++ b/scene/resources/particle_process_material.cpp @@ -419,7 +419,7 @@ void ParticleProcessMaterial::_update_shader() { if (tex_parameters[PARAM_ANGLE].is_valid()) { code += " float tex_angle = textureLod(angle_texture, vec2(0.0, 0.0), 0.0).r;\n"; } else { - code += " float tex_angle = 0.0;\n"; + code += " float tex_angle = 1.0;\n"; } if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) { @@ -737,7 +737,7 @@ void ParticleProcessMaterial::_update_shader() { code += " VELOCITY = normalize(VELOCITY) * v;\n"; code += " }\n"; code += " }\n"; - code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, rand_from_seed(alt_seed));\n"; + code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, angle_rand);\n"; code += " base_angle += CUSTOM.y * LIFETIME * (tex_angular_velocity) * mix(angular_velocity_min,angular_velocity_max, rand_from_seed(alt_seed));\n"; code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + tv * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));\n"; // angle diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 9e0b856ecd..27ae83908e 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -757,76 +757,84 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { } // Create infill (no AA). - if (draw_center && (!aa_on || blend_on || !draw_border)) { + if (draw_center && (!aa_on || blend_on)) { draw_ring(verts, indices, colors, border_style_rect, adapted_corner, infill_rect, infill_rect, bg_color, bg_color, corner_detail, skew, true); } if (aa_on) { real_t aa_border_width[4]; + real_t aa_border_width_half[4]; real_t aa_fill_width[4]; + real_t aa_fill_width_half[4]; if (draw_border) { for (int i = 0; i < 4; i++) { if (border_width[i] > 0) { aa_border_width[i] = aa_size; + aa_border_width_half[i] = aa_size / 2; aa_fill_width[i] = 0; + aa_fill_width_half[i] = 0; } else { aa_border_width[i] = 0; + aa_border_width_half[i] = 0; aa_fill_width[i] = aa_size; + aa_fill_width_half[i] = aa_size / 2; } } } else { for (int i = 0; i < 4; i++) { aa_border_width[i] = 0; + aa_border_width_half[i] = 0; aa_fill_width[i] = aa_size; + aa_fill_width_half[i] = aa_size / 2; } } - Rect2 infill_inner_rect = infill_rect.grow_individual(-aa_border_width[SIDE_LEFT], -aa_border_width[SIDE_TOP], - -aa_border_width[SIDE_RIGHT], -aa_border_width[SIDE_BOTTOM]); - if (draw_center) { - if (!blend_on && draw_border) { - Rect2 infill_inner_rect_aa = infill_inner_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP], - aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]); - // Create infill within AA border. + // Infill rect, transparent side of antialiasing gradient (base infill rect enlarged by AA size) + Rect2 infill_rect_aa_transparent = infill_rect.grow_individual(aa_fill_width_half[SIDE_LEFT], aa_fill_width_half[SIDE_TOP], + aa_fill_width_half[SIDE_RIGHT], aa_fill_width_half[SIDE_BOTTOM]); + // Infill rect, colored side of antialiasing gradient (base infill rect shrunk by AA size) + Rect2 infill_rect_aa_colored = infill_rect_aa_transparent.grow_individual(-aa_fill_width[SIDE_LEFT], -aa_fill_width[SIDE_TOP], + -aa_fill_width[SIDE_RIGHT], -aa_fill_width[SIDE_BOTTOM]); + if (!blend_on) { + // Create center fill, not antialiased yet draw_ring(verts, indices, colors, border_style_rect, adapted_corner, - infill_inner_rect_aa, infill_inner_rect_aa, bg_color, bg_color, corner_detail, skew, true); + infill_rect_aa_colored, infill_rect_aa_colored, bg_color, bg_color, corner_detail, skew, true); } - if (!blend_on || !draw_border) { - Rect2 infill_rect_aa = infill_rect.grow_individual(aa_fill_width[SIDE_LEFT], aa_fill_width[SIDE_TOP], - aa_fill_width[SIDE_RIGHT], aa_fill_width[SIDE_BOTTOM]); - Color alpha_bg = Color(bg_color.r, bg_color.g, bg_color.b, 0); - - // Create infill fake AA gradient. - draw_ring(verts, indices, colors, style_rect, adapted_corner, - infill_rect_aa, infill_rect, bg_color, alpha_bg, corner_detail, skew); + // Add antialiasing on the center fill + draw_ring(verts, indices, colors, border_style_rect, adapted_corner, + infill_rect_aa_transparent, infill_rect_aa_colored, bg_color, alpha_bg, corner_detail, skew); } } if (draw_border) { - Rect2 infill_rect_aa = infill_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP], - aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]); - Rect2 style_rect_aa = style_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP], - aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]); - Rect2 border_style_rect_aa = border_style_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP], - aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]); - - // Create border. + // Inner border recct, fully colored side of antialiasing gradient (base inner rect enlarged by AA size) + Rect2 inner_rect_aa_colored = infill_rect.grow_individual(aa_border_width_half[SIDE_LEFT], aa_border_width_half[SIDE_TOP], + aa_border_width_half[SIDE_RIGHT], aa_border_width_half[SIDE_BOTTOM]); + // Inner border rect, transparent side of antialiasing gradient (base inner rect shrunk by AA size) + Rect2 inner_rect_aa_transparent = inner_rect_aa_colored.grow_individual(-aa_border_width[SIDE_LEFT], -aa_border_width[SIDE_TOP], + -aa_border_width[SIDE_RIGHT], -aa_border_width[SIDE_BOTTOM]); + // Outer border rect, transparent side of antialiasing gradient (base outer rect enlarged by AA size) + Rect2 outer_rect_aa_transparent = style_rect.grow_individual(aa_border_width_half[SIDE_LEFT], aa_border_width_half[SIDE_TOP], + aa_border_width_half[SIDE_RIGHT], aa_border_width_half[SIDE_BOTTOM]); + // Outer border rect, colored side of antialiasing gradient (base outer rect shrunk by AA size) + Rect2 outer_rect_aa_colored = border_style_rect.grow_individual(aa_border_width_half[SIDE_LEFT], aa_border_width_half[SIDE_TOP], + aa_border_width_half[SIDE_RIGHT], aa_border_width_half[SIDE_BOTTOM]); + + // Create border ring, not antialiased yet draw_ring(verts, indices, colors, border_style_rect, adapted_corner, - border_style_rect_aa, ((blend_on) ? infill_rect : infill_rect_aa), border_color_inner, border_color, corner_detail, skew); - + outer_rect_aa_colored, ((blend_on) ? infill_rect : inner_rect_aa_colored), border_color_inner, border_color, corner_detail, skew); if (!blend_on) { - // Create inner border fake AA gradient. + // Add antialiasing on the ring inner border draw_ring(verts, indices, colors, border_style_rect, adapted_corner, - infill_rect_aa, infill_rect, border_color_blend, border_color, corner_detail, skew); + inner_rect_aa_colored, inner_rect_aa_transparent, border_color_blend, border_color, corner_detail, skew); } - - // Create outer border fake AA gradient. + // Add antialiasing on the ring outer border draw_ring(verts, indices, colors, border_style_rect, adapted_corner, - style_rect_aa, border_style_rect_aa, border_color, border_color_alpha, corner_detail, skew); + outer_rect_aa_transparent, outer_rect_aa_colored, border_color, border_color_alpha, corner_detail, skew); } } diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 17acfd773e..9d96e9a3b7 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -163,7 +163,7 @@ class StyleBoxFlat : public StyleBox { int corner_detail = 8; int shadow_size = 0; Point2 shadow_offset; - real_t aa_size = 0.625; + real_t aa_size = 1; protected: virtual float get_style_margin(Side p_side) const override; diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 3a6d40d22c..e46b643cd1 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -2183,11 +2183,17 @@ void VisualShader::_update_shader() const { const String temp = String(info.name); if (!info.options.is_empty()) { + if (!render_mode.is_empty()) { + render_mode += ", "; + } + // Always write out a render_mode for the enumerated modes as having no render mode is not always + // the same as the default. i.e. for depth_draw_opaque, the render mode has to be declared for it + // to work properly, no render mode is an invalid option. if (modes.has(temp) && modes[temp] < info.options.size()) { - if (!render_mode.is_empty()) { - render_mode += ", "; - } render_mode += temp + "_" + info.options[modes[temp]]; + } else { + // Use the default. + render_mode += temp + "_" + info.options[0]; } } else if (flags.has(temp)) { flag_names.push_back(temp); |