godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add to Label new rendering settings in theme and LabelSettings #10383

Open xolarkodak opened 3 months ago

xolarkodak commented 3 months ago

Describe the project you are working on

2d action runner

Describe the problem or limitation you are having in your project

You cannot set the outline color of the shadow, although you can set the thickness of the shadow's stroke. You can't change the rendering sequence of the shadow so that it would be like in the 3 versions of the engine (the shadow would be between the text and the text stroke). Sometimes you need to create the effect of convex or voluminous text that is possible only when duplicating Label with different colors and each time synchronize their value text that is very undesirable or shader that is undesirable on mobile devices

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Adds to Label Theme and LabelSettings advanced text rendering settings and the ability to change the order in which shadows are rendered. Finalize the rendering of the shadow stroke so that it is generated in a separate step. Implement the ability to set the color for the shadow stroke, not duplicate the shadow color. Realize the ability to change the order of shadow rendering to create the same effect of rendering shadows as was godot 3-x. This will help to better customize the visual for label.

-An example of a required result that cannot be done with the current Label render settings and without using additional nodes and shaders image

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

PR

Theme Overrides for Label and LabelSettings include 2 new parameters: font_shadow_outline_color and draw_shadow before outline. Now for the shadow, the shadow outline is still drawn, you just need to draw the shadow outline in a separate step to avoid overlap and set the color through a separate variable, and not use the same color as the shadow

To realize different postdates of drawing queues, before executing the loop we will form an array of drawing steps and go through the contents of the array

Label.cpp:

LabelDrawStep draw_steps[DRAW_STEP_MAX];

if (shadow_before_outline) {
    draw_steps[0] = DRAW_STEP_OUTLINE;
    draw_steps[1] = DRAW_STEP_SHADOW_OUTLINE;
    draw_steps[2] = DRAW_STEP_SHADOW;
    draw_steps[3] = DRAW_STEP_TEXT;
} else {
    draw_steps[0] = DRAW_STEP_SHADOW_OUTLINE;
    draw_steps[1] = DRAW_STEP_SHADOW;
    draw_steps[2] = DRAW_STEP_OUTLINE;
    draw_steps[3] = DRAW_STEP_TEXT;
}

// Draw shadow outline, shadow, outline and text. Note: Do not merge this into the single loop iteration, to prevent overlaps.
for (int step : draw_steps) {

Examle Theme bn_1

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

These changes affect the Label rendering logic in Label.cpp, so this should be core

Calinou commented 3 months ago