Smart Morph (Dilation & Erosion)

I recently looked into hyllians warp shaders. they have a nice effect but what I didn’t liked is that with dilation the picture often looks like it is overexposed. so I made a adaptive version of it.

ok, let me explain first how the morphing works. one looks at the neighborhood of a pixel E (including itself) and determines the brightest (or darkest) one X which then replaces E. instead of doing that we interpolate them both based on their luma difference. here is a quick screenshot comparison, original picture uses xbr-hybrid + ddt (original, sp00kyfox, hyllian):

there are several parameters to change the strength of the effect, you can also set it to behave like hyllian’s variant. here is a gallery in full resolution, check out the graph which explains the user parameters (which are also commentated in code):

download: common-shaders repository

recommended shader combination:

2xbr-hybrid-v5-gamma (nearest, 2x) ddt-extended (nearest, 2x) smart-morph (nearest, 1x)

Very good addition, Sp00kyFox!

I specially like your combination with second pass changed to bicubic-sharper, like this:

2xbr-hybrid-v5-gamma (nearest, 2x) bicubic-sharper (nearest, 2x) morph (nearest, 1x)

It really pushes the envelope in IQ for games without scanlines. The subtle color changing games looks very good with this combination!

too much haloing for my taste, looks nice though from a bigger view distance. at the moment I’m thinkin about how to make the weight function at the beginning smoother. the problem is, that with pwr < 1 the derivative in the origin goes to infinity instead of the desired zero slope. therefore even smoothstep doesn’t help as you can see on the graph in the image gallery. small steps in the low contrast range shouldn’t result in such sudden changes. any ideas here?

edit: tried playing around with tanh as the basic weight function… well the function looks smoother but the output picture on the other hand gets worse. pretty much nailed it what I wanted to implement with the first try.

I updated the shader and gave it a catchier name. you can now use the shader parameter submenu to configure the morphing strength. there is also an “adjust view” which allows you to better see how the paramets influence the result. the new version will be uploaded on the shader repo but for now you can download it here:

https://anonfiles.com/file/36cf845bd92b … e7503278a0

edit: it’s available now at the shader repo.

These look awesome! Are you commiting these to the repo?

hunterk is usually doing this for me since I don’t have a github acc. I already asked him so it shouldn’t take too long :wink: