xBR algorithm tutorial

I didn’t know about that. I’ll look into it and see how it compares to others. Sounds good! It seems focused in sharp output like standard xbr, hqx or scalefx.

super-xbr is more all purpose scaler like jinc, cubic or bilinear. Speaking of it, I think it looks much better than cubic, jinc or lanczos outputs.

EDIT: tested mmpx here. I think it needs further developments on rules and blending, because it let many raw pixels behind and it doesn’t look good near the smoothed ones. Even on SMW, which is a very cartoon game, it shows many flaws in pixel treatment.

3 Likes

Looks really good @Hyllian!

I took a look at your zip package, is it correct that it is only a preset which uses the existing XBR shaders?

3 Likes

Even though I never liked this kind of upscaling, I must admit that this one looks quite nice.

3 Likes

Yes, I adjusted the edge strength parameter so that not obvious edge regions aren’t smoothed out. And some other minor tweaks.

By the way, compare it with nnedi3 output and see how it stands with a fraction of its required power.

3 Likes

At first view you might think that it’s just some bicubic or lanczos filter. But if you look closer and test games, in motion, mainly, you’ll see that HUDs, fonts, small details and texture are more preserved with super-2xbr.

Fonts and huds gallery: https://imgbox.com/gallery/edit/QYblsHYzB0/DiClW7QiGK1WzpbF

2 Likes

I spent some time revisiting the old xBR shaders and decided to put some effort to organize the slang code, as they were just ports of Cg.

I cut out most of cg compatible code in favor of pure slang ones. And I’ve changed the color distance function (thanks to valious suggestions from @guest.r). The old code was very fast, but wasn’t very accurate on discerning some color gradient.

On top of that, I have improved the AA code, which works at any resolution (interger and non-integer) and will preserve crispness even at 4k resolutions. And merged the noblend shader with that AA. A switch param was inserted to allow toggling between the two options.

So, summarizing:

  • New color distance function to improve IQ;
  • Merge noblend and aa shaders in same files;
  • Better param descriptions;
  • New param to switch between noblend and aa;
  • New lv1, lv2-multipass and lv3-9x.

I made a Pull Request on github repo with the changes. If you don’t wanna wait for the main repo be updated (EDIT: main libretro repo updated! So, just update your slang shaders through Retroarch online updater!), here’s a pack of new shader/presets:

xbr updated - 22-07-16.zip

And some screenshots from xbr-lv3-9x:

More on gallery: https://imgbox.com/gallery/edit/BdbTjTWRyI/aXCWJ8RplC2Ep2SD

5 Likes

looks great man :smiley:

That copyright circle-C in the SMW shot is :chef-kiss:

2 Likes

I’m ‘somewhat’ familiar with the changes and they are very nice. xBR is fast, consistent and nice looking.

Also looking forward to @Hyllian 's possible new shading projects. :smiling_face_with_three_hearts:

6 Likes

Well, if there ever was a case where I might use this kind of upscaler, it’s this:

Source image:

Toonstruck-220716-225719

4 Likes

The best target for this kind of filter are games that don’t use too much color gradient. All 8-bit and prior generation games. For 16-bit, all Mario, Zelda and cartoon games.

For most 16-bit and further generations (32-bit and up) there are better filters that blend subtle color gradients.

3 Likes

Released today on repo (use update online to get it) this xbr-small-details that skips most dithering and relevant pixels when filtering. The result is a bit less smelted than regular xbr shaders and textures are more preserved:

Gallery: https://imgbox.com/gallery/edit/GyClrfRcwP/dimw6SMp0w0toHUk

6 Likes

Some improvements on xbr-lv2-small-details. Now dithering is almost completely intact.

It’s available on slang repo already.

Some screens:

Gallery: https://imgbox.com/gallery/edit/4jGhy8V7dI/waPxx431rW4N1O3w

6 Likes

New versions of xBR and Super-xBR added to slang libretro repo!

What’s new:

  • Major cleanup to xBR folder. Now only six presets in main folder. Most of old presets are now inside “other presets” new folder for historical reasons.

  • In main folder only multipass and gamma corrected versions available. Blending in linear gamma now favors white pixels the same way as dark ones, which means dark lines are thinner and produces a pleasant result in cartoon games;

  • I have changed some core rules of xBR and now dithering looks less weird when filtered. I even provided an option to not touch dithering at all, which looks good in some dithered plagued games;

  • The old small-details version is now the default as I think some pixels can’t be touched or else drawing details are lost when filtered;

  • Added new params, now the user can control the level of smoothness. At max, it’ll reminds old xbr versions, at min it’ll be more pixelized. So, some place in between must be the sweet spot and the user can decide now.

  • After thinking about it, I decided that a bit of blur is necessary as a final touch and not let a very sharp output. So, the main presets are slightly blurred compared to old versions (these can be used inside “other presets” folder yet). It isn’t an issue if you don’t play with your nose touching the display (LOL);

  • And finally, got rid of those fancy names (3p, 2p, 6p, etc).

xBR screenshots:

Super-xBR screenshots:

Gallery: https://imgbox.com/gallery/edit/sooQy2v31R/hGDzGaEJblivg9gc

10 Likes

Did you integrate a deposterize algorithm? Would be nice to see with deposterisation

Is there a Super-XBR version for ReShade?

An old thread, but I need to update something here.

I’ve updated the Super-xBR shaders on the libretro repo (just use update online to get them).

The new version is much sharper than before.

Here’s a comparison slider:

old sxbr vs new - slider comparison

And here are the screenshots: (BTW, the special screenshots use a special preset I made for this game)

01 - New, 02 - Old, 03 - Special:

ff3-01-new ff3-01-old ff3-01-special

02 - New, 02 - Old, 03 - Special:

ff3-02-new ff3-02-old ff3-02-special

03 - New, 02 - Old, 03 - Special:

ff3-03-new ff3-03-old ff3-03-special

04 - New, 02 - Old, 03 - Special:

ff3-04-new ff3-04-old ff3-04-special

05 - New, 02 - Old, 03 - Special:

ff3-05-new ff3-05-old ff3-05-special

Special preset
shaders = "9"
feedback_pass = "0"
shader0 = "shaders_slang/sharpen/shaders/cheap-sharpen.slang"
filter_linear0 = "false"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
shader1 = "shaders_slang/denoisers/shaders/bilateral-horizontal.slang"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "shaders_slang/denoisers/shaders/bilateral-vertical.slang"
filter_linear2 = "false"
wrap_mode2 = "clamp_to_border"
mipmap_input2 = "false"
alias2 = ""
float_framebuffer2 = "false"
srgb_framebuffer2 = "false"
scale_type_x2 = "source"
scale_x2 = "1.000000"
scale_type_y2 = "source"
scale_y2 = "1.000000"
shader3 = "shaders_slang/edge-smoothing/xbr/shaders/support/luma.slang"
filter_linear3 = "false"
wrap_mode3 = "clamp_to_border"
mipmap_input3 = "false"
alias3 = "XbrSource"
float_framebuffer3 = "false"
srgb_framebuffer3 = "true"
scale_type_x3 = "source"
scale_x3 = "1.000000"
scale_type_y3 = "source"
scale_y3 = "1.000000"
shader4 = "shaders_slang/edge-smoothing/xbr/shaders/super-xbr/super-xbr-pass0.slang"
filter_linear4 = "false"
wrap_mode4 = "clamp_to_edge"
mipmap_input4 = "false"
alias4 = ""
float_framebuffer4 = "false"
srgb_framebuffer4 = "true"
scale_type_x4 = "source"
scale_x4 = "1.000000"
scale_type_y4 = "source"
scale_y4 = "1.000000"
shader5 = "shaders_slang/edge-smoothing/xbr/shaders/super-xbr/super-xbr-pass1.slang"
filter_linear5 = "false"
wrap_mode5 = "clamp_to_edge"
mipmap_input5 = "false"
alias5 = ""
float_framebuffer5 = "false"
srgb_framebuffer5 = "true"
scale_type_x5 = "source"
scale_x5 = "2.000000"
scale_type_y5 = "source"
scale_y5 = "2.000000"
shader6 = "shaders_slang/edge-smoothing/xbr/shaders/super-xbr/super-xbr-pass2.slang"
filter_linear6 = "false"
wrap_mode6 = "clamp_to_edge"
mipmap_input6 = "false"
alias6 = ""
float_framebuffer6 = "false"
srgb_framebuffer6 = "true"
scale_type_x6 = "source"
scale_x6 = "1.000000"
scale_type_y6 = "source"
scale_y6 = "1.000000"
shader7 = "shaders_slang/edge-smoothing/xbr/shaders/super-xbr/custom-jinc2-sharper.slang"
filter_linear7 = "false"
wrap_mode7 = "clamp_to_edge"
mipmap_input7 = "false"
alias7 = ""
float_framebuffer7 = "false"
srgb_framebuffer7 = "true"
scale_type_x7 = "viewport"
scale_x7 = "1.000000"
scale_type_y7 = "viewport"
scale_y7 = "1.000000"
shader8 = "shaders_slang/edge-smoothing/xbr/shaders/support/deblur-fast.slang"
filter_linear8 = "false"
wrap_mode8 = "clamp_to_border"
mipmap_input8 = "false"
alias8 = ""
float_framebuffer8 = "false"
srgb_framebuffer8 = "false"
scale_type_x8 = "viewport"
scale_x8 = "1.000000"
scale_type_y8 = "viewport"
scale_y8 = "1.000000"
CS_SHARPNESS = "0.200000"
FRANGE = "2.000000"
FBSMOOTH = "0.150000"
FSIGMA = "1.000000"
XBR_EDGE_STR_P0 = "3.000000"
XBR_EDGE_STR_P1 = "3.000000"
SMART_F = "0.500000"
DEBLUR_F = "7.000000"

6 Likes

Great job. The special preset amps the contrast in a pleasant way. Is it game-specific?

1 Like

Yes. It may be a bit overkill for games with less color gradients (cartoon). FF3/6 uses some nice palette with gentle color gradient. So, as a general rule, I recommend it for games more “realistic”. The bilateral filter (thanks to @guest.r) get rid of some “noise” in the FF3/6 backgrounds (it works well with pre-rendered snes games).

The default preset is good for most games, so it’s less sharp.

2 Likes

I’ve got a bilateral filter running to combine jinc2 with xBR (standard). On low gradient regions it behaves like jinc2 with all color nuances. On high gradient edges it behaves like xbr. So it gets the best of both worlds.

Here are some screenshots:

002-250429-075118-250501-131058 002-250429-075118-250501-131054 002-250429-075118-250501-131050 002-250429-075118-250501-131046 002-250429-075118-250501-131041 003538-250501-090001 003538-250430-184255

It was uploaded to the repo: https://github.com/libretro/slang-shaders/pull/700/files

It isn’t just that, the same framework may be used with any other shader. Obviously some combinations don’t work well.

6 Likes

Fonts are pretty, it’s hard to get them right. I’ll test it later, but it already looks interesting. Seems more on the balanced side, which is advantageous to be an agnostic alternative for different kinds of contents.

2 Likes