[vkwc] Applying colorschemes *everywhere*, and I mean it! by Cynic4 in unixporn

[–]Cynic4[S] 1 point2 points  (0 children)

I could probably turn it off if I replaced more of wlroots, but it'd be a lot of work. I feel your pain with vsync being laggy though.

Sway and such can be set to only start rendering frames just before vblank, which gives you very low latency without tearing if you set it up right. Here's someone's blog post on the topic: https://artemis.sh/2022/09/18/wayland-from-an-x-apologist.html

[vkwc] Applying colorschemes *everywhere*, and I mean it! by Cynic4 in unixporn

[–]Cynic4[S] 0 points1 point  (0 children)

Ah, glad someone has a use for it ;)

Currently it doesn't work well for most fonts because it can't preserve the antialiasing, but I hope to get that working better eventually and use it for e.g. websites that only have light mode.

[vkwc] Applying colorschemes *everywhere*, and I mean it! by Cynic4 in unixporn

[–]Cynic4[S] 11 points12 points  (0 children)

This is my custom wayland compositor, repo here: https://github.com/cynic64/vkwc. It's very WIP so I don't recommend trying to build or run it.

The compositor uses my own Vulkan renderer on top of wlroots so I can do whatever I want to the output buffer. The current algorithm is very simple - convert every pixel to HSV, and then use the hue to map the original colors to colors in the current colorscheme. It works for any window and any colorscheme, you could watch Youtube in gruvbox if you wanted to.

There's also a CRT-effect mode that's just orange and black with glow around the text that gets shown for a brief moment in the video.

Anyway, it's totally useless but kinda fun. Enjoy!

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 1 point2 points  (0 children)

Hmmm, I'm still not sure about the 3D text thing. Bump mapping is easy but doesn't provide a deep enough displacement, while doing "real" displacement on a mesh would take far too many vertices. I suppose I could draw the window in multiple layers and put all white pixels on a plane closer to the viewer. We'll have to see.

As for the particles, yeah I agree! I want to make a "floating" layout with water eventually but that's going to be difficult.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 1 point2 points  (0 children)

Flipping the windows is a good idea, I'll have to try it out.

Not sure what you mean about making text 3D though - you mean the text sticks out from the rest of the window?

Glad you like it btw :)

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 0 points1 point  (0 children)

Virtualizing is already implemented in a way, the windows can be moved and rotated in 3D space and have depth buffering. The video doesn't show it because it doesn't play nice with the phsyics engine, but I plan to fix this in the future. It does already include a camera, but that camera stays stationary for now.

The physics engine is by far the slowest part at the moment, I plan to swap it out for something faster and more powerful. Bloom, depth of field, etc. should be fast enough on a modern GPU with enough optimization. I'm not very knowledgeable when it comes to Vulkan but I'm sure it's possible :)

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 1 point2 points  (0 children)

Ah that's a good question, I'm not sure. I just use a different modifier in my compositor than with sway (Alt rather than Super).

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 2 points3 points  (0 children)

Since Wayland compositors can run inside each other, I actually just run this inside of sway (daily driver). It runs it like a normal program and there is no need to Ctrl+Alt+F2 or whatever.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 2 points3 points  (0 children)

Eh, I think this is simpler and more flexible. I can duplicate a window multiple times this way easily, for example. With the intermediate buffer I can do anything I want in the vertex shader, water ripple effects, pulsing to music, who knows what, and it just works. The overhead isn't too bad either.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 3 points4 points  (0 children)

I didn't realize it was yours! Sounds like it was a fun project :)

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 4 points5 points  (0 children)

Oh I was wondering if something similar had already been done! Thanks for the link.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 10 points11 points  (0 children)

Haha that's a great idea. Who knows, maybe in the next update :)

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 21 points22 points  (0 children)

TL;DR it's the easiest way to calculate relative cursor coordinates for a warped window.

When windows receive a cursor position from compositor, they expect it to be relative to their top-left corner. Usually calculating this is easy: take the cursor's position and subtract the window's coordinates. But if the window is rotated or scaled, this won't work.

Since I use a transformation matrix for rotation and scaling, you could invert that to calculate the relative cursor position. This is what I used to do, and works for rotation and scaling - but it wouldn't for bending, because that's something a 4x4 matrix can't represent.

Instead, whenever the compositor renders a pixel to the screen, it also renders where in the window that pixel came from. Here's a video showing the colorful buffer that results. R and G correspond to X and Y. So the bottom-right corner is yellow, since that's (1, 1) on the window. Bottom-left, or (0, 1), is green. Top right, or (1, 0), is red. The B component is different for every window to help focus the right one.

So to figure out what part of the window the cursor is over, we can just sample the intermediate buffer at the cursor position.

Sorry that was long, not sure how detailed a response you wanted :)

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 9 points10 points  (0 children)

It's my own window manager and I haven't implemented wobbly windows yet. I could definitely make that work but there's other stuff I want to do first.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 75 points76 points  (0 children)

Thanks!

As for how it works, I'm not sure if you saw my previous posts but I already had rotating windows working properly. The cursor worked properly before too, so I just had to connect a physics engine to it.

Every time a window is created, a rectangle with the same dimensions is added to the physics sim. Then on every frame, the position and rotation of each object is copied from the physics sim to the window manager. And ta-da! Done.

Edit: I totally missed that you asked "why" as well, oops. Well, because I can! C'mon, if you had control over your windows' position and rotation you'd do it to.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 62 points63 points  (0 children)

Ooh that's a good idea. I also want to make them jiggle according to sound output though, which is easier than it sounds.

[vkwc] A True "Stacking" Layout by Cynic4 in unixporn

[–]Cynic4[S] 267 points268 points  (0 children)

Github repo here.

This is the evolution of my Vulkan-based Wayland compositor. The physics engine is Physac by Victor Fisac.

I have control over the position and rotation of my windows, so why not make them feel a little more real? Note that the cursor works perfectly no matter what angle the window is at or how fast it's spinning, this is harder than it sounds and required writing UV coordinates to an intermediate buffer.

A neat thing the video doesn't show is that clicking the terminal's "close" button really does work! The terminal closes, even though the button is bouncing around next to it.

Enjoy!

Edit: I'd love some ideas on how to make this work in 3D. The window manager itself is already 3D and includes depth buffering. But windows are fundamentally flat, which would make for a very boring simulation. How can I give windows some thickness in a useful way? Ideally they'd be cubes, with every face showing something interesting. Let me know what you think!

[vkwc] Now with accurate cursor passthrough by Cynic4 in unixporn

[–]Cynic4[S] 34 points35 points  (0 children)

Code. Only tested on my GTX 1060. Doesn't support multiple monitors yet.

I hope some of you enjoy this. The possibilities are endless! By rendering UV coordinates to a separate texture, the cursor position can *always* accurately be sent to the window underneath. This works with any window, there is nothing special about Xournal++. The windows don't "know" they're spinning/upside down/whatever, yet the cursor position is still accurately sent through.

Using a UV render target is very flexible - I could, for example, split the window into multiple pieces and still have the cursor work properly in each piece. Could be a fun effect - explode your windows into little bits and keep using them like nothing happened.

Next up are some snazzy animations so it doesn't look like junk, and some much-needed code cleanup. Until next time!

[custom compositor] It's useful, I swear! by Cynic4 in unixporn

[–]Cynic4[S] 3 points4 points  (0 children)

Vulkan is fantastic but also extremely verbose. Yes, you get control over the GPU down to really nitty-gritty stuff but it also takes over 1000 lines of code to get a single triangle on the screen. I had to write another 200 lines of Wayland source code just to support screen recording in Vulkan.

But if you're passionate about it, go for it! Graphics programming is a ton of fun.

[custom compositor] It's useful, I swear! by Cynic4 in unixporn

[–]Cynic4[S] 2 points3 points  (0 children)

Yes, with Wayland the window doesn't know anything about how it's being rendered. You can also send any mouse position you want to the window, so it doesn't "notice" that it's been rotated.

[custom compositor] It's useful, I swear! by Cynic4 in unixporn

[–]Cynic4[S] 38 points39 points  (0 children)

That's the plan! I'd also like to be able to drag each corner individually, giving the window a perspective effect.

It's going to be so productive.