CRT shaders unwanted scanlines when scaling an image

Hi all, I recently discovered a rather unpleasant side effect of using the CRT shaders. It’s practically impossible to shrink the size of the resulting screenshots with no artifacts if the shader is already applied.

Imagine you want to make a screenshot inside a retro game or capture a video from an emulator. The video on YouTube or an image on Instagram may not always be displayed in its original size. Also, you often scale videos or screenshots during editing. I sometimes see comments on Reddit that some screenshots have to be shown only in 100% size, because the previews have ugly artifacts with big scanlines, which never appeared on the original image. It’s even worse when you apply a curved CRT shader, then your scanlines form curves or even circles, depending on the zoom value.

The following screenshots were made from doxbox-staging with crt-geom.glsl shader (the original image and images scaled to 50%). But in general, it doesn’t matter where exactly you capture a screenshot. I have seen the same effect in RetroPie and PCem with different shaders. I tried to reduce the destructive effect of the shader scaling by adding a bit of Gaussian Blur or Lens Blur in advance. It’s a bit better, though the image is not as sharp, and the effect is still barely visible.

I have found zero information regarding this effect on the internet. It’s more or less clear that shrinking images is a destructive operation, and there is math behind the image resizing that is responsible for image degradation when applied on top of the shader. But do you maybe have any practical advice, how to minimize this effect? The answer might be: don’t use shaders when capturing, add them during the post-processing phase. But as I said before, the content you produce won’t be played in its original size anyway, there is no guarantee. I refuse to believe that people who edit videos or stream retro games have never seen these artifacts before.

  1. The original image:

  1. 50% shrunk image with cubic interpolation:

  1. 50% shrunk image with no interpolation

  1. 50% shrunk image with cubic interpolation, but lens blur applied before resizing

OBS Studio (video capture tool) adds this strange, unwanted scanline effect right away, which is even more annoying. It might be related to the encoder settings, and I basically have no idea how to get rid of it. The game itself and the CRT shader looked perfect on screen. The curved lines were added after I captured it. This can be seen in the video from my channel.

https://youtu.be/qOtg6FZM8ks

Thank you in advance for your help.

It’s normal, nothing new. You are pushing 1080 lines to fit to 540 so artifacts are introduced. It would be nice to have the same clarity 540 and 1080 but it can’t be. Too few pixels to render the effect. Just record your videos without scanlines

1 Like

Hi Ninja,

Always nice to see some Norton Commander…

I think the artifact you’re referring to is called Moiré. It’s not really specific to CRT shaders, anything that’s striped can show that type of pattern when images are scaled.

I guess the best way to minimize that pattern would be to use the OBS monitor to watch your recording while setting the shader parameters accordingly. Maybe by reducing the scanlines effect, reducing the curvature or trying another mask (maybe a slotmask). But if you’ve got some GPU or CPU headroom you may also try to record at your native resolution, so that OBS doesn’t downscale at all. You may even want to upscale to 4K for Youtube. The larger the resolution, the better it will look despite Youtube’s compression.

1 Like

Trying to help: professional content creators capture raw footage and, if later desired, apply specific post-processing effects in their video editor that can be customized to avoid artifacts, per situation. They’re not the same shaders RetroArch use, but something else. Search online for “crt effect” for your favorite video or photo editor; there are even online tools for that.

1 Like

scanline and mask effects will look bad, but you can do other aspects of the CRT look, like curvature, color/gamma shifts, chromatic aberration, etc.

I believe this is how most content creators deal with it. If they include scanline/masks at all, they’re very light so they just blend into nothing when resized/resampled.

2 Likes

I also think that the less re-encoding occurs the better it’ll look. If you’re doing let’s plays with minimal editing you may consider using lossless-cut instead of a full fledged video editor. There’s also a few useful ffmpeg commands with “-c copy” parameters. If you set OBS to encode in HEVC directly for example, that program can edit the video and trim it losslessly on the keyframes. So if you set the keyframe interval of the encoding to something like 1s, you can edit your videos without re-encoding.

1 Like

Maybe making footage of the display running shaders instead of recording directly could be better, but note that your original image already has scanline artifacts because of non-integer scaling and lack of resolution.

2 Likes