Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-02-14 17:10:34 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-02-14 17:10:34 +0300
commit21c395fa8342dfe2846cc843a5bc8c5ccb491cec (patch)
tree179ebcbb66afb43526435029a158a38a5f5483b1 /source/blender/editors/interface
parent6143f97531c670458ac22e0624bd9b482379bb00 (diff)
parent15141ec19ae54a0f087405e1d0ddba899daf886d (diff)
Merge branch 'master' into temp-abc-features
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_draw.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 23ae8915e93..9a51aa5cb9d 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2293,54 +2293,29 @@ void UI_draw_box_shadow(const rctf *rect, uchar alpha)
void ui_draw_dropshadow(
const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
{
- float rad;
+ const float max_radius = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
+ const float rad = min_ff(radius, max_radius);
- if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f) {
- rad = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
- }
- else {
- rad = radius;
- }
+ /* This undoes the scale of the view for higher zoom factors to clamp the shadow size. */
+ const float clamped_aspect = smoothminf(aspect, 1.0f, 0.5f);
- int a, i = 12;
-#if 0
- if (select) {
- a = i * aspect; /* same as below */
- }
- else
-#endif
- {
- a = i * aspect;
- }
+ const float shadow_softness = 0.6f * U.widget_unit * clamped_aspect;
+ const float shadow_offset = 0.5f * U.widget_unit * clamped_aspect;
+ const float shadow_alpha = 0.5f * alpha;
GPU_blend(GPU_BLEND_ALPHA);
- const float dalpha = alpha * 2.0f / 255.0f;
- float calpha = dalpha;
- float visibility = 1.0f;
- for (; i--;) {
- /* alpha ranges from 2 to 20 or so */
-#if 0 /* Old Method (pre 2.8) */
- float color[4] = {0.0f, 0.0f, 0.0f, calpha};
- UI_draw_roundbox_4fv(
- true, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a, color);
-#endif
- /* Compute final visibility to match old method result. */
- /* TODO: we could just find a better fit function inside the shader instead of this. */
- visibility = visibility * (1.0f - calpha);
- calpha += dalpha;
- }
uiWidgetBaseParameters widget_params = {
.recti.xmin = rct->xmin,
.recti.ymin = rct->ymin,
.recti.xmax = rct->xmax,
- .recti.ymax = rct->ymax - 10.0f,
- .rect.xmin = rct->xmin - a,
- .rect.ymin = rct->ymin - a,
- .rect.xmax = rct->xmax + a,
- .rect.ymax = rct->ymax - 10.0f + a,
+ .recti.ymax = rct->ymax - shadow_offset,
+ .rect.xmin = rct->xmin - shadow_softness,
+ .rect.ymin = rct->ymin - shadow_softness,
+ .rect.xmax = rct->xmax + shadow_softness,
+ .rect.ymax = rct->ymax - shadow_offset + shadow_softness,
.radi = rad,
- .rad = rad + a,
+ .rad = rad + shadow_softness,
.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
@@ -2351,7 +2326,7 @@ void ui_draw_dropshadow(
GPUBatch *batch = ui_batch_roundbox_shadow_get();
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
GPU_batch_uniform_4fv_array(batch, "parameters", 4, (const float(*)[4]) & widget_params);
- GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility);
+ GPU_batch_uniform_1f(batch, "alpha", shadow_alpha);
GPU_batch_draw(batch);
/* outline emphasis */