A couple of deinterlacing shaders

I made a couple of shaders to deal with interlaced content, figured I’d post about them here. They all take the weird, woven-field output from emulators and do different things with it.

interlacing.cg takes the fields and blanks out half of them, alternating each frame. This basically makes it act like typically interlaced content you would find in a broadcast situation.

bob-deinterlace.cg shows alternating fields line-doubled each frame, which causes characteristic judder (i.e., ‘bobbing’). It still produces a sharp picture, making it ideal for situations with a lot of movement to hide the bobbing image.

bob-and-ghost-deinterlace.cg takes the regular bob deinterlacing output and blends in the previous line-doubled frame to soften the judder. It looks good on menus, where the judder is most obvious and annoying. Menus were also the most commonly interlaced content on PSX.

1 Like

Thank you. bob-deinterlace does magic when paired together with mednafen-psx and Genesis-Plus-GX. :smiley:

My pleasure! I’m glad you like them :slight_smile:

I tested with Silent Hill intro and still got judder, scanlines also wobble. I load bob-deinterlace.cg and then bob-and-ghost-deinterlace.cg as second pass, is that correct?

No, just one or the other. Bob causes judder, bob-and-ghost will have it, as well, but it’ll be less obtrusive.

So at what pass should this be added if using with one of the CRT shaders?

first pass.

The bob shaders work well enough when I’m a good distance from the screen (and not wearing my contacts :P), but I’m still wondering if a core option for deinterlacing in beetle is on the agenda?

PSX is really the only system I’m not satisfied with at the moment, and I feel like beetle is probably the closest I can get at the moment… Mednafen has greater input lag without the hard sync setting of RetroArch, beetle has no native deinterlacing option, if you could call it that, ePSXe/PCSX-R are both, well… And Xebra has sync issues which basically require you to choose between perfect audio (no crackling) and perfect video (no stuttering). So many years since v1.13 and I’m still mourning the unannounced retirement of the pSX dev…

it’s not viable for a core option as far as I can see, it’s implemented on mednafen’s frontend side

Ahh :confused: Is shader deinterlacing the best we’re likely to have for the foreseeable future?

How would I combine an interlacing shader with something like sharp-bilinear to use for full screen non-integer scaling? I tried stacking them but it looks bad an d crashes.

Weird. It crashes for me, too, but not when gdb is attached -_-

The interlacing shader is really just for some pretty specific use-cases and frequently doesn’t cooperate outside of 2x integer scale. For most cases (i.e., anything that’s not 2x integer on a CRT display), you’re better off with one of the deinterlacing shaders.

I can’t seem to be able to change any of the interlacing shaders during runtime without it hard locking my computer. They do seem to work if I specify them in the cfg file before launching retroarch. Although that way I can’t combine them with something like pixellate.

I can’t choose any shaders when browsing the misc folder via the RetroArch menu, since it’s empty (“no items”). In both cases, glsl and slang. I assume it’s because of my Intel IGP (HD 4000). Do you need a certain minimum OpenGL/Direct3D version to run the shaders located in the misc folder?

The shaders in the ‘misc’ directory don’t have presets, as they’re usually used in conjunction with other shaders. You just need to load them manually by incrementing the number of passes by 1, then scroll down to the new pass where it says ‘N/A’ and navigate to the shader you want, then hit ‘apply changes’.

2 Likes

Great, thanks! The bob-deinterlacing shader works perfectly:

Edit: I noticed it only works when shader filter is set to nearest, not linear.

1 Like

The user Kumiibo in the retroarch subreddit pointed out that the screen is flickering when using the bob-deinterlacing shader (I didn’t notice it yesterday):

note: watch in HD for 60fps playback

Is there a way to remove or reduce the flickering? I noticed there is an anti-flicker shader in the misc folder, but it doesn’t help here. I tried using it as 1st and then as 2nd pass.

Yes, that’s what bob deinterlacing does. The other deinterlacing shader, bob-and-ghost, will blend the current and previous frames to smooth out the jitter at the expense of… you guessed it: 1 frame of ghosting.

So there is always a trade-off. :slight_smile: I don’t mind the flickering and I barely notice it during gameplay in motion. My prefered shader therfore in this case is bob-deinterlace.

1 Like

I updated the slang version of bob-deinterlace and added an option to compensate for increased internal resolution (e.g., from increasing the res in Beetle-PSX-HW) and added the frame-blending from bob-and-ghost (and made it actually work correctly) in as a parameter, as well, instead of keeping it as a separate shader.

I’ll probably merge it into the main repo soon, but you can try it out here in the meantime: https://github.com/hunterk/slang-shaders/blob/interlacing/misc/bob-deinterlacing.slang

4 Likes