friction2d / friction

Friction Graphics
https://friction.graphics
GNU General Public License v3.0
233 stars 12 forks source link

Motion Blur glitching #73

Open NothingHereIsReal opened 1 year ago

NothingHereIsReal commented 1 year ago

https://github.com/friction2d/friction/assets/1449700/4d108e9a-5c13-4398-95b4-5225d8e23c6f

This is visible when clicking Play in the viewport.

Playback while scrubbing is fine. Preview is fine, and exported SVG is fine.

v0.9.4, 4K display, scaled 150%, Windows 10.

rodlie commented 1 year ago

Probably HiDPI issues (https://github.com/friction2d/friction/issues/68). Try with 100% display scaling

NothingHereIsReal commented 1 year ago

The glitching effect is not exactly the same with 100% scaling but pretty close.

rodlie commented 1 year ago

Ok, thanks for testing. I will need to replicate this somehow. What graphics card are you using?

NothingHereIsReal commented 1 year ago

test3.zip Here's the *.friction file

I have an RTX 3090 graphics card using the Studio drivers.

rodlie commented 1 year ago

Thanks for the project file, I'm able to replicate (on Linux using Intel UHD 630).

rodlie commented 1 year ago

So, the issue is with the GPU rendering in the motion blur effect it seems, changing to CPU-only removes the artifacts, but of course adds a big performance penalty.

Will need to figure out why this happens, I got a general idea where it breaks, but don't have a working solution yet.

Adding an additional shader effect on top also "fixes" the issue. Odd...

NothingHereIsReal commented 1 year ago

I'm happy to help in any way I can but GPU code isn't a forte of mine, sorry. I've only ever seen anything like this before with a double-buffer timing issue in another app. Shout if there's anything I can do.

rodlie commented 1 year ago

I assume the issue is in https://github.com/friction2d/friction/blob/main/src/core/RasterEffects/motionblureffect.cpp#L265 or https://github.com/friction2d/friction/blob/main/src/core/RasterEffects/motionblureffect.cpp#L231

But, why it works if you scrub vs. play I don't know. Let's hope this is not another rabbit hole :)

Will debug properly tomorrow.

rodlie commented 1 year ago

btw, forcing the motion blur effect to CPU-only will actually improve performance if you have a good CPU. It seems motion blur on the GPU only improves the performance on "bad" CPU's (laptops etc), and a high-end GPU does nothing (my Intel integrated GPU has the same performance as dedicated high-end NVIDIA cards).

Link to frictioncore.dll that disables GPU on motion blur (just replace existing dll): friction-0.9.4-win64-motionblur-cpu-only.zip

NothingHereIsReal commented 1 year ago

Perfect, that works well.