r/rust • • 1d ago

A UI animation demo in modded GPUI, using temporal sub-frame multisampling to push perceived smoothness beyond 60Hz limits

https://youtu.be/q7CiWsawJ64

I modded GPUI to build a UI animation demo with temporal sub-frame multisampling. Turns out, even at 60Hz, rendering sub-frames at a higher multiple and blending them together gives you perceived smoothness well beyond the refresh rate limit.

Apple could probably make the MacBook Neo and iPad mini feel a lot less like e-waste if they tried this.

Not posting the source code since the idea and implementation are pretty simple, and it's just a demo.

(Note: Watch in 1080p60.)

25 Upvotes

40 comments sorted by

18

u/nuclearbananana 1d ago

Much less clarity though. This is good for visual effects but I'd hate to scroll through a page using this, you couldn't make out anything

3

u/kissfrosted 1d ago

yeah the blur might be rough for reading, but it does make the motion feel way smoother than usual 60hz stuff

1

u/FlirtyChunz_ 1d ago

yeah clarity would probably suffer big time, especially if you're actually trying to read anything on screen. bet it looks wild in motion though

-4

u/Yelov 1d ago edited 1d ago

To be fair, at 60 Hz you'd be able to read text only at quite slow scroll speed due to modern displays using sample and hold. With a CRT that would be different, but with a modern LCD or OLED you aren't getting good motion clarity at 60 Hz.

edit: I'd like to have a discussion with people instead of being downvoted for something that I know is correct

2

u/unicodemonkey 1d ago

Can you elaborate? Assuming CRT also receives 60 frames per second, how does CRT scanning/retention improve motion clarity?

2

u/Yelov 1d ago

It improves the motion clarity to humans because CRTs strobe, which helps when you're tracking an object on screen with your eyes because it doesn't blur the image on your retinas like on sample and hold displays. I just wrote a comment above, so I'll just link it https://www.reddit.com/r/rust/s/Coiz5FxhZE

1

u/unicodemonkey 14h ago

Ah, OK, I remember now. I've used CRTs for a long time, and also tried those backlight-strobing LCD displays for a short while. I agree with the motion clarity reasoning - but it's a side effect of strobed light, which looks so much worse subjectively than blurring at low frequencies. It's kinda instructive to watch simulations but this also reminds me why I was so happy to get rid of CRTs.

1

u/Real-Abrocoma-2823 1d ago

I certainly used bad monitors before, but never bought one, a lot of 60hz and 240hz monitors with horrible ghosting, I guess I was lucky or something as my 75hz and 165hz have 0 ghosting and reading while scrolling is perfect.

1

u/Yelov 1d ago

No, it's not about the actual display response time, it's a human limitation. If you track a moving object on a sample and hold display with your eyes, even if the display itself has perfect response times (e.g. an OLED), it will appear blurry because your eyes move smoothly, but the images do not, so while an image is being shown, your eyes are physically moving, and that results in you perceiving it blurry.

Blurbusters has a demo for this https://testufo.com/eyetracking

You can "fix" this either by refreshing the screen more often, or by strobing, which CRTs do naturally. But an LCD and OLED you can also use black frame insertion, CRT beam simulation etc.

If you're genuinely curious, feel free to search and read about it more, you'll find better explanations than mine.

-9

u/caniar 1d ago

I don't think there's any downside to it. The human eye can't really read any text while scrolling anyway.

11

u/nuclearbananana 1d ago

You telling me you never scan text while scrolling?

-8

u/caniar 1d ago

Nah, 99% of the content I take in is during the brief moments when scrolling slows to a stop.

11

u/nuclearbananana 1d ago

Well you & I are different then cause I 100% read/skim text while scrolling

7

u/Narrow-Glove1084 1d ago

"temporal sub-frame multisampling" so just motion blur? Do correct me if i'm wrong

-3

u/caniar 1d ago

To put it simply, I avoid using the term "motion blur" because its popular meaning has been polluted by the cheap, fast algorithms widely used in 3D game development. By comparison, temporal multisampling is much more expensive but delivers far superior results, and when dealing with simple 2D UI, the GPU is more than capable of handling it.

3

u/Helpful-Educator-415 1d ago

Fascinating. Like motion blur for UI.

7

u/pixel_gaming579 1d ago

And just like motion blur in games, I’d be turning this off straight-away every time. I’d rather not have virtual Vaseline smeared all over my GUI lol.

1

u/Helpful-Educator-415 1d ago

LOL, yeah. Some people like it, to each their own.

-6

u/caniar 1d ago

Your GPU isn't weak enough to need the cheap, corner-cutting approximations built for complex 3D scenes. Doing proper sub-frame sampling on simple 2D UI animations costs practically nothing. It has nothing in common with game-style motion blur.

1

u/caniar 1d ago

Indeed

16

u/GaboureySidibe 1d ago

I'm not sure where the idea comes from the GUIs need extreme optimizations like subsampling.

GUIs have been fast since the 90s. If people could make buttons and labels 30 years ago on a 486 50mhz, we can do it today on a CPU that runs at 100x the clock speed, triple the integer lanes and SIMD that lets you do at least 8 float ops per cycle.

If someone is making a GUI and it isn't fast, they have an optimization problem, not a sampling problem (why is a GUI 'sampling' in the first place?)

3

u/nuclearbananana 1d ago

True but did those 90s guis have adaptable layouts, anti-aliasing, support non-ascii and arbitrarily formatted text, on 4k screens, multimedia, smooth scrolling with touch etc.

things are less optimized but requirements have also gone up a lot

3

u/bmitc 1d ago

GUIs seem drastically worse today than they used to be. Sure, dynamic layouts is a thing, but most actually suck at it.

5

u/GaboureySidibe 1d ago edited 1d ago

did those 90s guis have adaptable layouts

yes

anti-aliasing

no

support non-ascii

no

and arbitrarily formatted text

yes (what does that mean?)

on 4k screens

didn't exist

multimedia

yes

with touch

that's input, why would it make a significant difference?

things are less optimized but requirements have also gone up a lot

No they haven't. A single CPU core is at the very least 16,000 times faster. One core, 16,000x as fast, and that's conservative.

You have 26x the number of pixels and 16,000x the computation, 128,000x if you count all the cores. Do the math.

-1

u/nonotan 1d ago

You have 26x the number of pixels and 16,000x the computation, 128,000x if you count all the cores

Basically any modern GUI that isn't a complete catastrophe isn't bottlenecked by CPU, but rather memory/cache/GPU transfer latency. None of which has improved nearly as much as on-paper CPU clock speeds. To crazily over-simplify for the sake of illustration, it doesn't really matter if the CPU could hypothetically calculate the values of 1 billion pixels per frame at your target FPS, if actually storing those 1 billion pixels and getting them on screen within that time budget would be completely unfeasible.

3

u/GaboureySidibe 1d ago edited 1d ago

What I'm saying takes this into account. Latency to memory isn't the bottleneck in these situations because you aren't jumping around in memory.

If you access memory linearly the prefetcher will take care of the latency for you by having it available when you need it.

Your "hypothetical" calculations are real abilities because this has been taken into account on CPUs for decades. You can really do billions of calculations per second if you access memory in the right way - looping through arrays linearly.

Try it for yourself. Jump around in a large array, then loop through it linearly. You will see the difference.

if actually storing those 1 billion pixels and getting them on screen within that time budget would be completely unfeasible.

It's 8 million pixels for a 4k image, 480 million pixels at 60fps, most programs aren't full screen and they don't update their whole window every frame. There is a reason current CPUs can use their full power if someone knows what they are doing and there is a reason GUIs worked fine 30 years ago.

-2

u/nuclearbananana 1d ago

adaptable layouts: I find it hard to believe they were comparable given smartphones didn't really exist. From understanding most toolkits used fixed coordinates

yes (what does that mean?)

As in arbitrary spans with different fonts weights, italics, sizes, colors, etc. Basically could they render a modern web page. Oh and variable width fonts and ligatures and input and bidirectional text while continuing to support highlighting and the like

that's input, why would it make a significant difference?

Scroll with a mouse: it's a single jump/frame across multiple lines with tolerable latency. With touch you need smooth 60/120fps and lag is very noticeable because it's literally disconnecting from your finger.

A single CPU core is at the very least 16,000 times faster

not sure how you're getting this. You can't just count flops to flops, since most of that comes from simd/parallelization, and no app on earth is anywhere close to 100% parallel. Same for multicore, same for gpu. Though a lot of recent work in all these new framework is in fact trying to make better use of all this absurd parallel compute we have with gpus

Also keep in mind memory latency has barely improved and memory throughput a lot more slowly than cpus. Amdahls law

You have 26x the number of pixels

Also didn't they primarily use like 8 bit colors? A pixel today requires 4 bytes or more w/ HDR.

Look I agree with your basic premise that we can absolutely have way faster guis without extra tricks, but it's absurd to think that requirements haven't also gone up dramatically

7

u/GaboureySidibe 1d ago

adaptable layouts: I find it hard to believe they were comparable given smartphones didn't really exist. From understanding most toolkits used fixed coordinates

Well, your understanding is completely wrong. Adaptable layouts are some of the most basic elements of a UI library and a phone doesn't change anything. It's all boxes. If anything a phone will have far less components on screen.

As in arbitrary spans with different fonts weights, italics, sizes, colors, etc.

Who cares? You think this is 16,000x slower?

Oh and variable width fonts and ligatures and input and bidirectional text while continuing to support highlighting and the like

What part of this is slow? What are you even talking about?

not sure how you're getting this. You can't just count flops to flops, since most of that comes from simd/parallelization,

Clock speed, AVX instructions. This is actually extremely conservative since AVX instructions can be dispatched more than once per cycle on many CPUs and floats took many cycles. Most GUI operations can be done with integers, but modern CPUs have far more integer units than a 486 anyway.

and no app on earth is anywhere close to 100% parallel.

This is a nonsense statement that means nothing. You are mixing SIMD lanes and large scale thread parallelism. If you loop through memory linearly you can use SIMD easily and it will give you at least 7x for floats on a sandy bridge CPU from 15 years ago.

Though a lot of recent work in all these new framework is in fact trying to make better use of all this absurd parallel compute we have with gpus

Recent work? Like what? Rendering on a GPU like softimage 3D from the 90s? The whole point here is that GUIs worked in the 90s on CPUs, they don't even need GPUs.

Also keep in mind memory latency has barely improved and memory throughput a lot more slowly than cpus. Amdahls law

That's probably why every CPU advancement for the last 30 years has been about minimizing the impact of memory latency, especially prefetching.

Amdahls law

Amdahls law what? That has nothing to do with what you're saying. It says that if you have a lot of cores, the part that you can't parallelized becomes the bottleneck. It's nonsense and it has nothing to do with memory latency, which can be dealt with by accessing memory linearly so that it can be prefetched.

Why did you think this would mean something?

Also didn't they primarily use like 8 bit colors? A pixel today requires 4 bytes or more w/ HDR.

Says who? 24 bit color was 3 bytes. People write realtime raytracers on CPUs and you don't think someone can draw a GUI as fast as a 486 from 30 years ago.

Look I agree with your basic premise that we can absolutely have way faster guis without extra tricks, but it's absurd to think that requirements haven't also gone up dramatically

It's not absurd because I can do basic math.

What is absurd (and embarrassing) is arguing about something you know practically nothing about.

1

u/Real-Abrocoma-2823 1d ago

Maybe we did get better hardware, but there are still people who can push optymalization beyond what some think is possible. It just got much easier to use electron instead of caring about performance when people can just get better PC.

1

u/Franks2000inchTV 1d ago

Not to mention the limits of human perception make this kind of thing literally useless.

Yeah there’s going to be some natural variation in human perception, but there’s a real law-of-diminishing returns effect here.

1

u/Helpful-Educator-415 1d ago

I think it's mostly a proof of concept. I can imagine this being cool in a game or game-y kind of application. Obviously your CRUD business-y app should not do GUI subsampling, but sometimes proving that something is possible is, in and of itself, cool.

-1

u/GaboureySidibe 1d ago

Why would a game need GUI subsampling?

2

u/Helpful-Educator-415 1d ago

I dunno. Maybe it's for style-points. Maybe it's for some kinda... digetic UI type thing. Some games are mostly UI, maybe a game engine wants to offer this over its GUI rendering, I dunno. It sacrifices readability obviously, but it's like motion blur for your UI. Could be cool to someone. Not me, though -- I don't think I'd ever use it.

-2

u/GaboureySidibe 1d ago

So you 'dunno' ?

3

u/Helpful-Educator-415 1d ago

Did I step on your toes or something? I'm confused what you're getting at.

0

u/stylist-trend 1d ago

Turns out, the comment continued far past the second word.

Games are well known to be driven by strict necessity, and never by novelty or cool factor or fun or anything else. This is a strictly enforced law of the universe.

I'm not sure if I'd ever use this or enjoy it, but if all arguments to use against it (or arguably any other hobby project), "necessity" isn't a strong one.

1

u/words_number 2h ago

Looks very smooth and nice as a tech demo :)

But please, everyone, stop ruining your UX with animations. They suck. If I click on something, ideally that thing has already happened. There is no better UX than that. Everything else makes me busy wait for nothing. Especially terrible: Menus with submenus where I have to wait for every sub menu to unfold instead of just operating at the speed of thought 🤮

-6

u/caniar 1d ago

Stop arguing about motion blur hurting text readability. I've tested all animation speeds under both 60Hz (1x/4x) and 120Hz (1x/2x) configurations, and as long as my gaze actively tracks the moving text, there's no difference in text recognition whatsoever. Your visual cortex effortlessly decodes multisampling. In fact, if I can't make out the multisampled version, I can't make out the standard rendered version either.

-2

u/DavidXkL 1d ago

Wow very cool