Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StyleBox fake AA improvements (make anti aliasing size a float property) #51442

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

Geometror
Copy link
Member

By allowing decimal values for StyleBoxFlat's anti_aliasing_size property the user has more control over it while the crispness of the fake AA can be slightly increased as seen in this screenshot (partly fixes #35279):

grafik

Although it is by far from perfect, I think this is still an improvement to the StyleBox resource and could be enough for using rounded corners in #51159 (@Calinou What do you think?). This change can be combined with the addition of an enum for different fake AA techniques as suggested by Calinou in #35279 (comment).

Changes:

  • Changed the anti-aliasing size to be a float property and set the new default value to 0.625 (determined through testing)

  • Adjusted slightly how the anti-aliasing gradient ring is calculated when a border is drawn to partly solve the problems mentioned in StyleBoxFlat aliasing looks blurry (regression between 3.2beta5 and 3.2beta6) #35279. As shown in these screenshots, the extent of the border fake AA gradient ring matches the extent when just the infill is drawn.
    CURRENT MASTER:
    grafikgrafik
    THIS PR:
    grafikgrafik

  • Corrected some comments and variable names to fit the Godot codestyle (camelCase variables and COMMENTS FULLY IN CAPS)

I would suggest that you try it out yourself and compile this PR to see it in action since resized screenshots can't properly depict how it looks in the end. Feedback is always appreciated :)

@Geometror Geometror requested a review from a team as a code owner August 9, 2021 16:40
@Calinou Calinou added this to the 4.0 milestone Aug 9, 2021
@akien-mga akien-mga requested review from Calinou and a team August 9, 2021 17:00
@Calinou
Copy link
Member

Calinou commented Aug 9, 2021

I tested this on my default project theme PR rework. Here are the results: https://imgsli.com/NjQ5MTA/3/5
It works well on focus outlines too (not pictured on the above comparison).

It's definitely an upgrade over what we have currently, and it should still work nicely on rotated StyleBoxes. Nice work 🙂

@pouleyKetchoupp pouleyKetchoupp added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Aug 10, 2021
Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a great way to solve this issue! Thanks for looking into this.

There's just one regression I've found, it's that if you have a border with rounded corners and don't fill the inside part, the inside edges of the border are not anti-asliased anymore.

Before:
image

With this PR:
image

(it's also visible inside the corners without the rotation)

Apart from that, everything looks better and there's more flexibility to adjust AA, so it seems all good! It would be probably worth porting to 3.x as well, since the current state is not great and this PR's compatibility breaking is not that bad (it might just require re-adjusting AA size in some cases).

@Geometror Geometror force-pushed the styleboxflat-fake-aa-float branch 2 times, most recently from 88b7ca6 to e27bfb3 Compare August 10, 2021 21:22
@Geometror
Copy link
Member Author

@Calinou @pouleyKetchoupp Thanks for testing.
I fixed the regression and changed some of the remaining comments to match Godot's codestyle (// Abc.) or removed them where they are unnecessary (primarily in the style_box header).

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@akien-mga akien-mga merged commit 588883e into godotengine:master Aug 11, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

This doesn't seem trivial to cherry-pick so it might warrant a dedicated PR if it's wanted in 3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StyleBoxFlat aliasing looks blurry (regression between 3.2beta5 and 3.2beta6)
4 participants