Help Stacking Shaders

(My GitHub Shader repo for some context)

I’m using OpenEmu on Mac instead of RetroArch, so not everything seems to work / work as intended. But, on the whole what I’m trying to do is have a series of clean scanline (or lcd grid for handheld) filters like you might find on official mini consoles/Analogue HD consoles/UltraHDMI adapters. (so, outside of this topic - I am open to ideas and suggestions.)

For scanlines, I’ve been using Yeetron from Sonic Mania. Whenever I’ve tried to stack Pixellate before it to ensure pixels are first correctly shaped, the pixellate effect would be absent. Eventually, I got it to half show-up like so:

shaders = 5

shader0 = ../Sources/Slang/stock.slang
filter_linear0 = false
scale_type0 = source
scale0 = 1.0

shader1 = ../Sources/Slang/misc/ntsc-colors.slang
filter_linear1 = false
scale_type1 = source
scale1 = 1.0

shader2 = ../Sources/Slang/crt/shaders/snes-hires-blend.slang
filter_linear2 = false
scale_type2 = source
scale2 = 1.0

shader3 = ../Sources/Slang/interpolation/shaders/pixellate.slang
filter_linear3 = false
scale_type_3 = source
scale3 = 1.0

scale_type_x3 = viewport
scale_x3 = 1.0
scale_type_y3 = source
scale_y3 = 1.0

shader4 = ../Sources/Slang/crt/shaders/yeetron.slang
filter_linear4 = false
scale_type_4 = source
scale4 = 1.0

parameters="INTERPOLATE_IN_LINEAR_GAMMA; NTSC Intensity"
INTERPOLATE_IN_LINEAR_GAMMA = 0.0
"NTSC Intensity" = 0.0

That’s getting the effect to appear on the sides of a pixel, but not on the top and bottom (need to zoom in to see). How can I get the entire effect? I’m using Super Mario World’s title screen as a test. Mostly looking at the black pixels in the red S.

I believe this is the reason that only the x axis is getting antialiased. Pixellate needs some scaling to happen to be able to do its thing, and by setting it to source/1x, it’s essentially not doing anything.

Yeetron, OTOH (and most scanline/CRT shaders) need the original size to produce nice scanlines.

@hunterk What should it be set to here instead? Not knowing too much, I just copied that bit from https://github.com/libretro/slang-shaders/blob/368bdb8fd92bf7712054f1d996851f6e335d7d50/presets/tvout/tvout%2Bsnes-hires-blend.slangp

I’ve tried without the separate scale for x&y here before, I’ve also tried setting y to viewport, as well as the scale set to 2.

That part you quoted is redundant. It’s only using one of those codeblocks.

If you keep the x and y separate, you could try setting the y scale to 2x or 3x or whatever, but it’s probably going to screw up your scanlines.

Redundant, also quoted by mistake. I corrected it once my post went through approval.

So, should I choose between: (pixellate not applied)

filter_linear3 = false
scale_type_3 = source
scale3 = 1.0

and (pixellate x-axis applied)

scale_type_x3 = viewport
scale_x3 = 1.0
scale_type_y3 = source
scale_y3 = 1.0

and just leave it at that if any changes will break the scanlines?

I think applying pixellate on the X axis and using integer scaling on the Y axis will solve both of your issues.

@hunterk Is integer scaling something I can set in the slangp file? My googling shows it as a RetroArch setting; in which case I’m out of luck due to using OpenEmu.

Ah, yeah, that’s correct. It is possible to do integer scaling within shaders but it needs to happen in the same pass as the scanlines.

Alright. Thanks for the help and information.

I’ve cleaned this up slightly to:

shaders = 4

shader0 = ../Sources/Slang/misc/ntsc-colors.slang
filter_linear0 = false
scale_type0 = source
scale0 = 1.0

shader1 = ../Sources/Slang/crt/shaders/snes-hires-blend.slang
filter_linear1 = false
scale_type1 = source
scale1 = 1.0

shader2 = ../Sources/Slang/interpolation/shaders/pixellate.slang
filter_linear2 = false
scale_type_x2 = viewport
scale_x2 = 1.0
scale_type_y2 = source
scale_y2 = 1.0

shader3 = ../Sources/Slang/crt/shaders/yeetron.slang
filter_linear3 = false

parameters="intensity;INTERPOLATE_IN_LINEAR_GAMMA"
intensity = 0.0
INTERPOLATE_IN_LINEAR_GAMMA = 0.0

Not perfect, but as far the integer scaling goes… full screen looks fine, not perfect - still missing pixellation on the y-axis. But 4x windowed mode in OpenEmu looks a bit better; the x-axis pixellation seems more consistent. So, I think I’ll chalk this up to quirk of the software. I might have better luck if I was using RetroArch proper.

If you check out the border shaders, they have some examples of forcing integer scaling from within a shader, and they also have options for scanlines and some other things, all through the parameters. You might like 'em for your purposes.