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

Add a case for shadows when blur_radius = 0 #22441

Merged
merged 6 commits into from
Jan 6, 2025
Merged

Conversation

iamnbutler
Copy link
Member

@iamnbutler iamnbutler commented Dec 27, 2024

Closes #22433

Before/After (macOS):

CleanShot 2024-12-26 at 22 41 11@2x

For some reason the non-blurred one seems much lower quality, so we may need to tinker with the samples, or something else.

CleanShot 2024-12-26 at 22 42 12@2x

I'm unsure if this is a problem on Linux/in the Blade renderer, but since no changes were made outside of the medal shaders we can probably take this macOS-specific win for now.

Release Notes:

  • gpui: Fixed an issue where shadows with a blur_radius of 0 would not render.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 27, 2024
@iamnbutler iamnbutler requested a review from as-cii December 27, 2024 03:38
@iamnbutler iamnbutler added macOS Platform-specific feedback for macOS behaviors, features, design, etc gpui GPUI rendering framework support labels Dec 27, 2024
@iamnbutler iamnbutler marked this pull request as ready for review December 27, 2024 03:52
float distance = length(max(float2(0., 0.), rounded_edge_to_point)) +
min(0., max(rounded_edge_to_point.x, rounded_edge_to_point.y)) -
corner_radius;
alpha = distance <= 0. ? 1. : 0.;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does metal have something like the GLSL smoothstep()? With appropriate threshold values using that instead of the hard conditional here should fix the aliased edges nicely.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, I'll take a look!

Copy link
Contributor

@jansol jansol Dec 27, 2024

Choose a reason for hiding this comment

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

EDIT: nvm, I was reading the way distance is calculated wrong.
Alternatively a simple alpha = (1.0 - min(1.0, distance * distance)) should look good too.

@jansol
Copy link
Contributor

jansol commented Dec 27, 2024

Blade shaders are directly transcribed from the metal ones so they'll need the same fix.

@iamnbutler
Copy link
Member Author

Success! We have a 0-blur, non-jagged shadow:
CleanShot 2025-01-06 at 09 53 55@2x

@iamnbutler
Copy link
Member Author

I think I feel good about where the metal shader change is now. Going to see if I can get the blade change done next!

@iamnbutler
Copy link
Member Author

iamnbutler commented Jan 6, 2025

For future reference:

It looks like the blade renderer (at least when run on macOS using cargo run --example shadow -p gpui --features "gpui/macos-blade" has a number of shadow issues that don't match the metal one.

Group 3

For now I'll work on fixing blur_radius = 0 but we should try to track these differences!

Edit: #22711

@iamnbutler
Copy link
Member Author

Since this PR makes no structural changes, and the current blade rendering is unchanged, I'll merge this one and open a new PR with the blade changes!

@iamnbutler iamnbutler added this pull request to the merge queue Jan 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 6, 2025
@iamnbutler iamnbutler added this pull request to the merge queue Jan 6, 2025
Merged via the queue into main with commit d02bfe1 Jan 6, 2025
13 checks passed
@iamnbutler iamnbutler deleted the gpui-shadow-blur-0 branch January 6, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement gpui GPUI rendering framework support macOS Platform-specific feedback for macOS behaviors, features, design, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gpui: Drop shadows with no blur are not rendered
2 participants