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

Server-side window shadows #927

Closed
YaLTeR opened this issue Jan 4, 2025 · 4 comments · Fixed by #990
Closed

Server-side window shadows #927

YaLTeR opened this issue Jan 4, 2025 · 4 comments · Fixed by #990
Assignees
Labels
enhancement New feature or request

Comments

@YaLTeR
Copy link
Owner

YaLTeR commented Jan 4, 2025

This is more important now that you can float windows, to make them stand out when overlapping.

Need to check what customization other compositors (swayfx, Hyprland) provide and how they handle irregular window shapes.

@YaLTeR YaLTeR added the enhancement New feature or request label Jan 4, 2025
@VaclavC
Copy link

VaclavC commented Jan 9, 2025

It would be nice to have semi-transparent mask over whole desktop in case of modal window alongside the actual shadow.

@YaLTeR
Copy link
Owner Author

YaLTeR commented Jan 9, 2025

There aren't really any modal windows or dialogs in niri at the moment. Either way, it's a separate issue from this.

@YaLTeR YaLTeR self-assigned this Jan 15, 2025
@timgott
Copy link

timgott commented Jan 15, 2025

As I have made https://github.com/timgott/wayfire-shadows but now often use niri, I can give you some tips:

  • Read this: https://madebyevan.com/shaders/fast-rounded-rectangle-shadows/. I would consider it the standard (and optimal) method to draw gaussian shadows. You essentially only need to draw a rectangle with this shader and you have shadows.
  • I have tried other implementations for fun (e.g. I did the math such that the light source is circular and not gaussian) but it is not worth it, gaussian approximates all other distributions very well
  • I believe swayfx later implemented shadows the same way and referenced exactly the same article, and hyprland has some ad-hoc gradient as shadow that is not worth cloning (a gradient cannot have the right light distribution in the corners and looks a bit to dark there, though you probably don't notice that as much unless you look for it).
  • To improve the contrast, you can make the box of the shadow a bit bigger than the window, e.g. grow the borders by 10 pixels. (reasons for doing this: The shadow is at only ~0.5 opacity at the borders of the rectangle because only half the light is blocked. Also a light source can have a bigger shadow than the object if it is close enough.)

@YaLTeR
Copy link
Owner Author

YaLTeR commented Jan 15, 2025

Thanks, that will be very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants