Skip to content

Blur behind windows#1634

Closed
visualglitch91 wants to merge 20 commits intoniri-wm:mainfrom
visualglitch91:feat/blur
Closed

Blur behind windows#1634
visualglitch91 wants to merge 20 commits intoniri-wm:mainfrom
visualglitch91:feat/blur

Conversation

@visualglitch91
Copy link

@visualglitch91 visualglitch91 commented May 21, 2025

This PR ports the optimized blur implementation from https://github.com/nferhat/fht-compositor/tree/main/src/renderer/blur (kudos to @nferhat for the original implementation).

This is my first attempt at Rust and at Window Compositors, so be gentle 😋

This is more of a PoC than anything, I hacked away somethings that were missing in Niri and we can further develop if y'all want to move in this direction.

Preview

Screencast.From.2025-05-21.19-35-36.mp4

Todo

  • Prove that it can be done
  • Add the blur config to the kdl file
  • Move the hard coded blur settings to the config
  • Find a way to access the output the window currently belongs to from the tile element
  • Find the right place to init and update the EffectsFramebuffers
  • Find out why clipped surface shader is failing to compile if we haven't changed it
  • Make it work with rounded corners
  • Port the OptimizedBlur imeplementation
  • Clean up the code and make sure we follow Rust and project best practices (which I'm totally unfamiliar with)
  • Handle scaling in OptimizedBlur

Conclusion

If this is something you are intersted in I would love to continue working on it and also have help of more experienced people.

Thanks for this amazing project 😊

@visualglitch91 visualglitch91 force-pushed the feat/blur branch 2 times, most recently from d8cbb46 to 79946f4 Compare May 21, 2025 23:56
@YaLTeR
Copy link
Member

YaLTeR commented May 22, 2025

Uh, well, this is cool! Though, I stand by what I've said... somewhere I can't find apparently, guess it was in Matrix. For a complex operation like blur, I would like to first finish the Smithay Tracy GPU profiling integration, and then understand the underlying niri implementation very well (which amounts to a similar amount of work to trying to implement it myself).

That is to say:

  • it may still be a while until I get to this PR
  • I may do something else blur-related before I get to this PR (in particular I wanted to try x-ray blur first, and the way I was thinking it should work wasn't entirely like optimized blur in fht-comp)
  • it will still be a lot of work reviewing and likely heavily editing this PR

Still, a niri proof of concept is very appreciated, and especially the thousand of small things like adding the window rules and so on that hopefully shouldn't need much reviewing!

@visualglitch91
Copy link
Author

I don't think it's worth working on this for now then but once you get back to this subject let me know if you need an extra pair of hands 😉

@YaLTeR
Copy link
Member

YaLTeR commented May 22, 2025

If you bumped into any unforeseen code or design constraints (as it goes), please do write so we can think about it!

@visualglitch91
Copy link
Author

The only issue that I had (apart from not knowing rust) wast that we need access to the Output inside the Blur element so we can sample the correct one, and I didn't want change much code, so I did a trashy thingy just to get the last one that was added... But I guess it wouldn't be a problem to change whatever calls the render method to pass the output

@visualglitch91
Copy link
Author

But I think the hard part is done, the OptimizedBlur could just be copy and pasted now, the rest is just organizing the code

@nferhat
Copy link

nferhat commented May 22, 2025

Hello! Thank you for trying to port this!

I'd also like to wait for GPU profiling in smithay before calling this implementation good/optimized, we'll see soon.

Other remarks I have to do are:

  • The implementation is broken with scales. Try running the compositor with scale above one and it will break wonderfully!
    I am also unsure about a lot of stuff:
  • I can't do texture syncing yet because smithay keeps it private, I am not even sure if it should be done between passes
  • I don't like the use of glGetIntegerv, something from smithay would be required to rebind the output framebuffer after running the passes
  • Damage tracking it out the window right now, I can't seem to get window surface damage out of DamageSnapshot, it seems to be resetting by the time I draw the element.

The sole reason why this unfinished product is in my compositor is because it was good enough for me, and mostly nobody use my comp anyway

Regardless, good job!

@nferhat
Copy link

nferhat commented May 22, 2025

  • I may do something else blur-related before I get to this PR (in particular I wanted to try x-ray blur first, and the way I was thinking it should work wasn't entirely like optimized blur in fht-comp)

Curious about how you may implement that! Regardless, both impls need a lot of polishing

@visualglitch91
Copy link
Author

visualglitch91 commented May 22, 2025

Now that I'm a bit more familiar with how this works I've been thinking about a more "agnostic" strategy for the x-ray: setting pre-blurred image paths on the config and then just using them with frame,render_texture_from_to. I think it might statisfy my own needs while we don't get this implemented the right way 😅.

@YaLTeR
Copy link
Member

YaLTeR commented May 22, 2025

That sounds like part of a general effect where you can replace backgrounds with a shader or other surface (think like place-within-backdrop reuses an existing surface). But a question is whether it can reasonably be exposed in the config.

@visualglitch91 visualglitch91 force-pushed the feat/blur branch 3 times, most recently from 0863832 to 7b31f59 Compare May 24, 2025 17:09
@visualglitch91
Copy link
Author

I'm still working on this to have this feature for myself while it's not implement in the best way and also to learn more about rust and wayland.

I managed to improve and fix somethings from the todo list and found a new issue: the sample area gets displaced by the top layer, like when I have a waybar the blurred layer is off by the height of the bar... I couldn't find a way to get the value I should offset by, so for now I just added these values to the config so I can manually tweak them.

I feel like this should be an obvious fix for people who know the project, if that's the case please let me know 😁

@visualglitch91
Copy link
Author

Ok, the TrueBlur position error had nothing to do with waybar but with opengl being bottom-left based instead of top-left, it's fixed now 🥳 and OptimizedBlur (x-ray) is also working

@visualglitch91 visualglitch91 force-pushed the feat/blur branch 4 times, most recently from 4b859a0 to c4e3916 Compare May 26, 2025 16:41
@visualglitch91
Copy link
Author

So, I think this basically working now, both blur strategies and with scaling. I didn't manage to make with work it layers because I don't know if this even makes sense since the blur element is a rectangle 🤔

@YaLTeR fell free to close this PR if you like, I'll use this fork for myself and will try to keep up to date with the main repo/branch.

@visualglitch91 visualglitch91 marked this pull request as ready for review May 26, 2025 18:47
@0xhckr
Copy link

0xhckr commented May 26, 2025

I'm going to test it out personally - been missing blurry windows from hyprland for a hot minute haha. It'd be nice for the time being until either this gets merged or someone else implements it in the way @YaLTeR prefers and merges it into main.

@0xhckr
Copy link

0xhckr commented May 26, 2025

so just testing, haven't looked too closely at the code yet, but doing

blur {
  off
  passes 3
  radius 12.0
  noise 0.0
}

keeps the blur effect running.

(not sure if it's supposed to reload once you save changes to config.kdl)

@visualglitch91
Copy link
Author

I just tried this with an external 4k monitor and had bugs and perf issues 😭 this is not something I can fix myself, so if anybody wants to take over I'd be happy to help

@visualglitch91 visualglitch91 marked this pull request as draft May 26, 2025 21:17
@0xhckr
Copy link

0xhckr commented May 26, 2025

I was on a dual 4k display and had no perf issues on my end. I guess Smithay Tracy GPU profiling integration is supposed to help us debug. I also found out changing backgrounds does not update the blurred backdrop, just commenting for visibility.

@visualglitch91
Copy link
Author

Currently the buffer only updates when the output changes, I imagine we need to trigger this in other places as well

@visualglitch91
Copy link
Author

I think my perf issues are related to my hybrid nvidia gpu and this was never going to work on my machine, it does work flawlessly on my other laptop without this cursed gpu setup

@levpr1c
Copy link

levpr1c commented Dec 10, 2025

okay, thx for anwser

@Naxdy
Copy link

Naxdy commented Dec 10, 2025

@levpr1c if there aren't too many other changes for you, you can check out my fork (link in a previous comment). it has blur on layer shell, and I just recently implemented support for the KDE blur & background effect wayland protocols, so some apps can blur themselves now without requiring extra config.

@alicealysia
Copy link

@levpr1c if there aren't too many other changes for you, you can check out my fork (link in a previous comment). it has blur on layer shell, and I just recently implemented support for the KDE blur & background effect wayland protocols, so some apps can blur themselves now without requiring extra config.

Can you submit a pr for it? If so I'd happily review it

Blur is in no way contradictory to the goals of the niri project, it's just that we want to do it properly and aren't creating technical debt for ourselves in the process.

So if you're confident in the quality of what you've made, please, give us the chance to look it over!

See, the fun part is making blur work, the hard parts are:

Profiling - we want/need a way to determine and troubleshoot issues with any introduced visual flair, our best lead on that presently is an outstanding PR on smithay to introduce tracy GPU profiling. At least, that's a start.

Settings design - names of a setting should be self evident (i.e. there should be minimal possible ambiguity of the function of the setting when spotting it in the condig.kdl as a commented out default for the first time), they shouldn't clash, break or override existing settings, they should not introduce aditional considerations or challenges when updating the config with future settings.

Testing - lots of it. This is where at least submitting a draft comes in real handy. If we can download and install it on as many machines as possible, that gives us the data to make better choices overall.

So please, make a pr!!!

@levpr1c
Copy link

levpr1c commented Dec 12, 2025

@Naxdy I tried downloading and compiling your fork about a week ago, but the blur didn't work. Maybe I cloned the wrong branch or something.

@yayuuu
Copy link

yayuuu commented Dec 12, 2025

@levpr1c I've tried it quit a while ago and it didn't work, but after retrying it few days later, it now works for me, so maybe try it again.

@levpr1c
Copy link

levpr1c commented Dec 12, 2025

@yayuuu Did you compile the type and turn it on a few days later? Or did you compile it again?

@Naxdy
Copy link

Naxdy commented Dec 12, 2025

@alicealysia I'm not saying that blur doesn't align with niri's goals (that part is more referring to the other things I'm doing in my fork, like adding KDE protocol support), but I was going off of what @YaLTeR said in the initial comment:

For a complex operation like blur, I would like to first finish the Smithay Tracy GPU profiling integration, and then understand the underlying niri implementation very well (which amounts to a similar amount of work to trying to implement it myself).

If this has changed, I'll happily open a PR at least for optimized / x-ray blur, since that implementation is pretty much finished & optimized for GPU performance (I tested this by comparing GPU load with other blur-enabled compositors like KWin & Hyprland). However, I'd like to avoid opening a PR that'll sit for many months, since this means having to keep it up-to-date & resolve conflicts, even if a merge is unlikely in the near future.

@yayuuu
Copy link

yayuuu commented Dec 12, 2025

@levpr1c I've compiled it again few days later. Currently I use my personal fork that ports Naxdy's changes as well as changes from release and modifier only keybinds PR, removed scanout tranche flags that fix the performance on my PC and few more scrolling improvements that I vibe coded myself.

@levpr1c
Copy link

levpr1c commented Dec 12, 2025

@yayuuu нихуя себе, okay i wiil tried it agian, maybe i will use ur fork

@levpr1c
Copy link

levpr1c commented Dec 13, 2025

@yayuuu if i use another shell based on quickshell blur doesn't work, i downloaded the naxdy fork first and then yours, but when i downloaded the naxdy fork i didn't run dms Here are the screenshots of your fork
Screenshot from 2025-12-13 14-49-21
Screenshot from 2025-12-13 14-49-03

@visualglitch91
Copy link
Author

@yayuuu @levpr1c @Naxdy please avoid using this PR comments to discuss and troubleshoot stuff unrelated to it.

@levpr1c
Copy link

levpr1c commented Dec 13, 2025

artworks-euByeS6lQFyIKgHA-Xe3AwQ-t500x500 png

@ryzendew
Copy link

ryzendew commented Dec 14, 2025

Testing it now and will report any issues

The blur isn't updating in maxed windows compared to smaller windows
the blur does not apply to the top layer aka top bars or docks
but it does run very well gpu wise

@midischwarz12
Copy link

@visualglitch91 Thought you might want to see this.

Also, anything you need help on currently? It looks like this is really close. Can we start a checklist of what still needs to be done before this is merged, or are we just not sure what all the bugs are yet?

@Sempyos
Copy link
Member

Sempyos commented Dec 20, 2025

Please read above for the reasons why this hasn't been merged yet

@YaLTeR
Copy link
Member

YaLTeR commented Jan 17, 2026

I would like to first finish the Smithay Tracy GPU profiling integration

This is now completed and merged.

@levpr1c
Copy link

levpr1c commented Jan 25, 2026

изображение When I change the scale, the blur does not change own scale, even after restarting the session

@visualglitch91
Copy link
Author

@levpr1c the blur seems aligned with the wallpaper, it's the semi-transparent background on your terminal panels that looks off, i don't think this is related to the blur

@shkouyo
Copy link

shkouyo commented Feb 12, 2026

I'm using this version of Niri and it's very stable.
However, when using mpvpaper as my animated wallpaper backend, the background stops updating whenever windows are tiled, but works fine with floating windows. It seems the background fails to redraw when covered by the tiling layout.
If this is an intentional optimization, I would love to see a configuration option to toggle or change this behavior.

@aimbot-user19
Copy link

@dotcubecn Yes. This is intended optimization, but I also would like a toggle to this behavior. In fact, in the early stages of this, there was no such optimization, so tiled windows would automatically update. This is useful because in order to update the x-ray - or optimized - blur (as they call it) after changing wallpapers, you would have to update the config. Or useful in your case, where you have a video background. I mean, why optimize the blur for battery life / less usage when you are running a whole video in the background, right? :) Also This is in hyprland too, just that the blur actually updates for the background properly, just not for other things like windows under the tiled windows (this can happen while moving windows), and shadows under the windows. In hyprland, floating windows do not have such restrictions forced onto them (I think you are able to turn on x-ray blur for floating windows) and behave like the floating windows in this implementation of blur.

@vuboi
Copy link

vuboi commented Feb 18, 2026

изображение When I change the scale, the blur does not change own scale, even after restarting the session

What bottom bar are you using? Can you share it?

@visualglitch91
Copy link
Author

Closing this in favor of the work being done in https://github.com/niri-wm/niri/tree/wip/branch which is already so much better than what we had here!

Thank you all folks for trying out my code during these months <3

@Fireye04
Copy link
Contributor

Closing this in favor of the work being done in https://github.com/niri-wm/niri/tree/wip/branch which is already so much better than what we had here!

Thank you all folks for trying out my code during these months <3

Thanks for maintaining it!

@nonetrix
Copy link

Anyway to track progress of WIP branch? Subscribed to this thread just to get notified

@Sempyos
Copy link
Member

Sempyos commented Feb 19, 2026

You can watch the matrix or discord or YaLTeR's mastodon for when he posts updates

@YaLTeR YaLTeR mentioned this pull request Feb 21, 2026
@YaLTeR
Copy link
Member

YaLTeR commented Feb 21, 2026

Hey everyone, here's the official blur PR for testing: #3483

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.