Gaussian blur shader, gaussian resampler, more resamplers

I have been recently looking for a nice solution to produce better glow with my crt shader(s) and since it should comply with a ‘list of requests’, a nice gaussian blur came out as a byproduct.

It can be used as a standalone shader where one would like to use blur, like to smooth scaling artifacts of scaling algorithms, mitigate tiling with PSX games, use the advantages of higher internal resolutions etc.

Recently i added a version, which does filtering with ‘substractive sharpness’, it’s quite a nice upgrade of the usage.

Download link (15.12.2020):

Download link (first version):

https://mega.nz/file/x1QD3A5Y#kwIyvtnMbkNpaDytww4dbueyA8A-2_4I7M-zUiOz1A8

Some screenies:

original:

blurred:

Technical stuff: The implementation also allows resampling to custom scale, custom filter size and sigma.

Edit: i couldn’t be too fond of only blurring, so i have implemented substractive sharpness already.

Needs to work a bit different, but looks very promising.

9 Likes

I really like it in combination with ScaleFX-rAA! Thank you for this! It makes scaled graphics look more natural.

1 Like

You’ll probably like the next version even more, although the preset should be more or less set or corrected manually for best effect with ScaleFX, xBR etc…

I tested the new shader with PSX 2x Scaled + xBR:

Release soon.

6 Likes

Subtractive sharpness is related to your deblur shader? (I like deblur applied to super-xbr)

1 Like

It’s what i use in crt-gdv to substract colors a bit. It has also evolved since the initial versions. Deblur is much different, mostly with more steadfast utilization over blur compared with substractive sharpness.

It’s ready for usage i think. It’s quite precise with settings, but i think it will not be too hard to grasp.

The filter is very consistent, even in with lo-res:

2 Likes

New release version (10.12.2020).

OK, it’s finished. It’s a bit defined to use, but should be ok. The shader pack includes gaussian blur shaders as well as two more shaders + preset for advanced filtering.

It can be used from low res to higher res content and it can upscale to viewport resolution. Some functionalities like sharpening range are hard-coded, but a nice option was used.

Download link:

https://mega.nz/file/xpJDSSbQ#5qJDZR7MO9FwaR_7VNQmNePu02xfWZkdPnnVun0PiAo

Edit: hard-coded functionality made a parameter.

5 Likes

Loved it, I’m using the shapen version in combination with ScaleFX-rAA, and for Sega Genesis I’m using ScaleFX-rAA-SGENPT-MIX-Gaussian Blur. Very good setup for when I want to play the games in a “modern way”.

Overlays from u/DarrenJCarol https://www.reddit.com/r/RetroArch/comments/k7auwp/new_retroarch_overlays/

2 Likes

That’s a great setup. It might also work very well with vanilla scalers like xBR, ScaleFX…because of the filtering.

Meanwhile i tested a setup with planar blur calculation and it’s quite sharp, although it can be used only with a single pass version. Dense filter at 2x internal resolution requires many weight calculations, but it can look very nice, since it doesn’t skip pixels.

OTOH the Linear version wins this one regarding 3D clearly.

I think xBR textures can be put to a super combo with it, 3D is much preserved.

5 Likes

Another showcase of new filter usage. It’s quite known that default bi-linear down sampling doesn’t give good results, even if an AA shader is used. The posted shaders (sharp versions) can down sample pretty well, even without a prior AA shader. It’s because a dense and wide filter is used, sharpening reduces the blur quite well. Another benefit is exact sampling to viewport resolution, which makes sure the shaders are not running slower with increased internal resolution.

I have been into this with few shaders before (AA Shader 4.0…) and they lacked exact density and the sharpening effect. You can also try the filters, but don’t forget to crank-up the internal resolution. :grinning:

Bilinear downsampling (4k -> 1080p):

Bicubic downsampling (4k -> 1080p):

Gaussian-sharp downsampling ((4k -> 1080p):

I’ll post optimized versions soon, but only speed optimizations.

4 Likes

New release version (11.12.2020).

Notable changes:

  • new, unified preset settings, that make much better sense
  • new naming scheme for the resamplers with sharpening
  • resamplers with sharpening cannot do pure blur any more
  • very nice speed optimisations for the resamplers, dynamic radius, which makes the single pass version like 5x faster with lo-res content and default settings.

Download link:

https://mega.nz/file/9kwBFYyI#FJzmqvIi6OuyKJ-AQcCv3GBCCeKJh4Lopy_9LmaStnQ

Feedback is welcome. :upside_down_face:

5 Likes

What game is that? It can’t place it.

1 Like

Do you think it can be merged with crt to have effect of the scanlines without the actual presence of the scanlines ? I have attempted to do that with jinc2 and crt-hyllian-sinc , but the scanlines are still there to a degree .

1 Like

Tales of Symphonia.

These shaders should look better with masks only, but will not have scanlines as they are. You can still try an overlay for scanlines.

1 Like

Playing with Deblur a bit, but only with 2-pass version. It’s too taxing for bulkier single pass.

Original resampled:

Resampled with built-in deblur (no extra pass):

1 Like

Finally got some time to test. I tested the naked one. I don’t know why, for me the best config is to use gaussian shader two times, the first one scaled by 2x and the second scaling to viewport.

Since retro games were developed for CRT TVs, I think the horizontal filter should be a bit stronger than the vertical one. So I got better results with sigma_h bigger than sigma_v. The same for radius.

My results:

My preset:

shaders = "2"
shader0 = "shaders_slang/gaussian_blur+g-sharp_resampler/shaders/gaussian.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 = "2.000000"
scale_type_y0 = "source"
scale_y0 = "2.000000"
shader1 = "shaders_slang/gaussian_blur+g-sharp_resampler/shaders/gaussian.slang"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
parameters = "SIZEH;SIGMA_H;SIZEV;SIGMA_V"
SIZEH = "4.000000"
SIGMA_H = "0.800000"
SIZEV = "2.000000"
SIGMA_V = "0.500000"
4 Likes

I’ve been known to make too much blur already, but now i try to do at least smart blur. :grin: Trying to remove glitches by adding deblur in the same pass and going trough some headaches i realized i should do a separate pass. Works quite nice for a resampler i guess, maybe you’ll find the deblur useful too, but it’s only smart debluring, hard to convince it otherwise. :rofl:

It’s quite good on extreme lo-res (resampler + deblur):

Will post shaders soon…

3 Likes

The shaders are now usable with the added deblur functionality. I decided to not endorse artifacting too much, but it’s got a quite natural look now.

As a reminder, the shaders are great for high res content due the density of the pixel lookups, which doesn’t change by increasing the range of the effect.

New release version (13.12.2020).

Notable changes:

  • adapted deblur version, which allows better contrast. Has some settings which influence performance, like kernel size…but also quality.
  • single pass version uses planar filtering (aka cylindrical, instead of cartesian)
  • some minor tweaks

Download link:

https://mega.nz/file/94ZzjCDT#bjHt_bhix285runj6suAXdwc3_vAHDofpzE5xbvndy4

Edit: a deblur shader speed improvement.

3 Likes

Hi @guest, is there a way to make a fast deblur shader?

It’s a good candidate to replace jinc as a last shader on my presets. Though it’s a bit slower than jinc shaders so my PS3 chokes when I try using it to scale to 5x as a last pass.

I’m using the repo version. I don’t know if it’s already optimized. I tried to understand the logic behind the shader but couldn’t grasp everything that was happening, :laughing:. The only optimization I’ve found possible was to calculate the texture sampling positions in vertex. Other than that I couldn’t see any other otimizations without changing quality.

BTW, about the gaussian shaders, could you describe how gaussian blur differenciates from gaussian resampler? (I was using gaussian.slangp)

2 Likes

There is a faster version around, should work well enough i guess, but it allows more contrast though.

But if you really have a notch of performance left, you can use the fast sharpen shader, which also has some nice properties, but you could tweak it a little for better upscaling etc.

It’s been worthwhile for me to use this concept. Gaussian curve is quite adaptable and serves as a basis for final shifted down curve, since we want something like this:

https://upload.wikimedia.org/wikipedia/commons/6/6a/Lanczos-kernel.svg

I played with the idea a bit to have 2 kernels in crt-gdv, but it’s less adaptable.

Anyway, very glad to hear again from you on the forums. :upside_down_face:

2 Likes

Great! Thanks for pointing those shaders. I’ll try them and see how they compare to deblur.slang on the repo.

1 Like