In search of a simple, lightweight scanlines software filter

Hi guys,

I use RetroArch on GNU/Linux only, framebuffer only, mainly in ARM-based SBCs. On the Raspberry Pi, there’s very good GLES support, but other boards lack half decent open-source GLES libraries, such as the ones based on Allwinner A20 (Banana Pi, Cubieboard 1, 2 and Cubietruck, etc) and the ones based on Samsung Exynos where the framebuffer GLES libs perform poorly and show artifacts. However, I went and added some RA native 2D API drivers for the A20 boards, and LiquidAcid did the same with the Exynos boards, thus gaining great performance and smooth screen updates with advanced multiple buffering, etc. The problem is that this rendering route leaves the fragment shaders out of reach, so we’re restricted to software filters in machines with not much CPU power to “waste”. At least a simple scanlines filter would be very useful, as it greatly improves how these games look, in my opinion. The available soft filters in gfx/video_filters are too demanding and there isn’t a simple scanlines filter there either, so I’m trying to modify one to create my own scanlines filter. I chose the darken.c one, and simply applied the darkening in odd lines, for example. The result was an image with thick scanlines, because these filters are applied to the image before the hardware does the scaling, I believe, so it’s not what’s needed. My opinion now is that it’s impossible to implement a good scanlines soft filter without processing the final scaled image, because a correct scanline implementation should depend on the physical screen resolution to avoid “patterns”. Any thoughts? Is that possible at all for a software filter like the ones in gfx/video_filters?

All scanline filters will have the patterns with non-integer scaling. Your best bet is probably to use an overlay. Check the ones in the wii subfolder.

ok, found them in the wii release package. I will try.

Well, tried the scanlines and scanlines bold overlays. I had to try them on the GL driver because dispmanx, sunxi or exynos don’t implement the overlay_interface function yet. I get thick black bands. Doesn’t seem to be a solution really.

Can you try these? http://www.mediafire.com/download/u7sadtz08olu4al/scanlines-test.zip

They’re very big but should work at any integer scale factor.

I have tried them. Always using “integer scale” in the video options. Both cause patterns. Thick groups of “darker” lines appear, so the scanline effect is by no means uniform. My guess is these scanline pngs are fixed size and they don’t scale well to the monitor resolution. Using integer scaling means the core image is scaled using integers, but the overlay PNG resolution isn’t an exact multiple of (core image * integer), so very obvious patterns appear, I am right?

EDIT: to prove my point, I cut a 1366x768 rect, which is my monitor physical resolution (I run RA in KMS mode and fbset reports this resolution is in use), from the scanline-fade.png file and tried that. The result was good, with no patterns. Scanline density is uniform. The only problem is that density is too low, because I cut a 1366x768 rect from a 2160x2160 bitmap, so each scanline is too thick as there are not enough of them. So I need a method to generate scanline PNGs of any resolution. Or better yet, RA could implement an internal LUT generator in which an scanlines bitmap with the physical resolution of the monitor. Do you know of an algorithm to generate an scanline bitmap of a given size with the right density?