I need a hand with interpolation

Looking for a way to make those nearest neighbour pixels a bit smoother that doesn’t completely destroy them like linear interpolation does. With reshade, I can use @guest.r 's excellent 2Dscaler shader (a hidden gem, can be found here), which works like a charm (and I suspect traces of its DNA can be found in guest-advanced) but I don’t think there’s a slang version of it.

It would be amazing if more blending/scaling options were added to RA’s preset creation tool (consider that a request, guys!), but for the time being, a shader would more than suffice. Been playing around with the interpolation folder, and have struck a more or less happy medium between linear and nearest using bicubic, but I’m really missing the knobs that 2Dscaler has. My current, poor man’s approach is basically just an on/off switch and the effects, while interesting, are not even that apparent in non-pixelpeeping circumstances :frowning:

Squalo’s hacky bicubic solution

Nasty linearity

Beautiful neighbours, sometimes a bit too sharp

Any ideas? Please help me save the peaceful kingdom of Raguy from the evil Linear Empire!

By the way, I’m also very interested in making masked subpixels more rounded, as seen in this lanczos-upscaled crop that I posted someplace else this morning.

I expect the solution to my first problem to involve a prepend, while the second one, if at all possible, would require an append.

3 Likes

Bicubic is what I use for Scanline Classic’s upscaler and it is (through survey) considered the best ‘dumb’ upscaler for images. I started off with the interpolation/shaders/bicubic.slang shader because it allows you to adjust B and C easily. A setting of 1/3 for B and C is considered the most balanced. You have to linearize the input first.

https://en.wikipedia.org/wiki/Mitchell%E2%80%93Netravali_filters

2 Likes

You can also try some shaders in edge-smoothing/ddt. @Hyllian’s DDT always amazed me with it’s ingenuinity.

3 Likes

@anikom15 Yeah, bicubic works and it’s quite cheap also. It would be a good algorithm for sure, but I do not know how to implement it properly, so that capture I posted is as smooth as I can get right now without breaking the pixels.

Cubic-gamma-correct preserves brightness, which is really nice, so I’m experimenting with that one too. And those 6 tap shaders that separate X and Y are also interesting, since they allow me to leave the vertical axis in its original, supersharp nearest form that scanlines like so much, and linearize/blur the horizontal one, which the mask appreciates.

I’m looking for something streamlined with a slider of sorts, instead of my current switch. A port of 2Dscaler would be awesome, winkwink lol.

Speaking of which, @guest.r is your shader completely custom or based on any of the established methods?

Will check DDT right away anyways. If it’s coming from Hyllian and it amazes you, I’m sure it’s fantastic.

I continued some concepts from my good old ngemu ePSXe shader research, and since it’s not too sensitive to small input resolution missmatches, it went to ReShade. :grin:

1 Like

If you read that page about Mitchell-Netravali filters, you can see how B and C work as sliding scales to affect the output picture. interpolation/shaders/bicubic.slang already has B and C as parameters and you just need to setup the preset with the gamma shaders. Scanline Classic combines B and C into a single parameter called Focus, which is a value between 0 and 1:

float C = -1.0 / 3.0 * sq(FOCUS) + 5.0 / 6.0 * FOCUS;
float B = 1.0 - 2.0 * C;
3 Likes

@guest.r well I’m by no means an expert obviously, but it’s the best blending solution I have ever seen, at least in the context of videogames, and if it ever comes to RA it will be more than welcome. Excellent work as per usual.

@anikom15 I played around with B and C this afternoon, but wasn’t able to grasp them fully. Will certainly read the page, thank you man.

2 Likes

BTW, there are 2D version of Lanczos which is Jinc (EWA Lanczos)

Lanczos (1D)

e1e3445ff03b82cd6dde28d689bbece1

Jinc (2D)

34102c933aa47eb08cffaed6411b9843

4 Likes

If you’re investigating interpolation, you might want to look at Fast Third-Order Texture Filtering from GPU Gems 2. It explains how to do single pass 2D cubic b-spline interpolation with only 6 texture fetches per output pixel.

That article inspired the ‘tweak the texture coordinates and do a single texture fetch’ approach that makes crt-pi so fast.

2 Likes

Thanks a lot guys.

For now I’m going to solve the original problem with pixel_aa and ControlledSharpness, both of which have sliders and work beautifully.

With that said, going through every interpolation shader at 300% magnification has been a spiritual journey, and opened up quite the rabbit hole. I wasn’t a fan of the posterized look that I traditionally associate with heavy interpolation, but yesterday I discovered some methods that can be applied in a very controlled way. I know it has been combined with crt shaders since the beginning of time, but again I never really liked the look of it. This is mighty impressive though, like an actual HD remake :O.