Page MenuHome

UI: Improve node drop shadow
ClosedPublic

Authored by Leon Schittek (lone_noel) on Nov 24 2021, 8:34 PM.
Tags
Tokens
"Like" token, awarded by AlexeyAdamitsky."Love" token, awarded by hitrpr."Like" token, awarded by ncotrb."Love" token, awarded by HEYPictures."Love" token, awarded by pablovazquez.

Details

Summary

Improve the nodes' drop shadow by making it scale with the view and
replace the loop for the alpha calculation with something more explicit.


Issue
The amount of the drop shadow softness (meaning the width of the faded
border) was scaled with the zoom level and therefore had a fixed
screen space size.
So when zooming in and out of the node editor the shadow would appear
to grow and shrink in relation to the node.
DPI and UI scale on the other hand was't taken into account.

This patch fixes both by basing the shadow softness on the widget_unit
that scales correctly in zoomable views and takes UI scale etc. into
account.

masterpatch
normal DPI
high DPI

Changed Alpha Calculation
It seems like the pre-2.80 drop shadow was just drawing a bunch of
rounded boxes with very little opacity and, when the method was
changed, the alpha was still computed in the same loop to keep the
same apparent brightness.

I plotted the resulting alpha in relation to the input alpha to see
what function we could use to replace the loop.
To me it seems like simply taking half the input alpha is a close enough
fit for the interval [0, 1].
I'll gladly find a closer approximation, if that's desired. Replacing
that loop with something more explicit is great either way.

Here is a graph of the linear alpha used in the patch compared to the
results we get in master:

Diff Detail

Repository
rB Blender
Branch
ui-node-drop-shadow (branched from master)
Build Status
Buildable 19197
Build 19197: arc lint + arc unit

Event Timeline

Leon Schittek (lone_noel) requested review of this revision.Nov 24 2021, 8:34 PM
Leon Schittek (lone_noel) created this revision.
Leon Schittek (lone_noel) added projects: User Interface, Restricted Project, Nodes.
Leon Schittek (lone_noel) edited the summary of this revision. (Show Details)

I'll take Pablo's heart as an indication that it's preferred visually. Personally I find the size of the shadow a bit big when fully zoomed in.

I don't really feel strongly about that, but do you think there would be a simple way to tweak that a bit?

I agree with Hans here, the shadow is too big when fully zoomed it,

  • Merge branch 'master'
  • Smoothly clamp shadow size.
  • Fix error calculating shadow screenspace size
Leon Schittek (lone_noel) planned changes to this revision.Dec 2 2021, 9:53 AM

Thanks for the feedback! I don't have a strong opinion on the bigger shadow and updated the patch to clamp the shadow size.
From his comment on blender.chat I remember @Pablo Vazquez (pablovazquez)' issue was the shadow appearing all big and fuzzy when zooming out. So there is probably room for these kind of tweaks.

masterupdated patch

I now noticed a visible pop-in of the shadow under frames because the patch is enabling/disabling the shadow at a certain zoom level. I should probably add an additional alpha fade to make that transition more smoothly.

Leon Schittek (lone_noel) retitled this revision from UI: Improve node dropshadow to UI: Improve node drop shadow.Dec 2 2021, 9:55 AM
Leon Schittek (lone_noel) edited the summary of this revision. (Show Details)
  • Remove fading the shadow out at lower zoom sizes, since it didn't work well with the semi-transparent frames.
  • Merge branch 'master'

Update to current state of master.

This revision is now accepted and ready to land.Jan 29 2022, 7:22 PM
This revision was automatically updated to reflect the committed changes.