hrydgard/ppsspp — pull request #1640 by PeterTh (2013-05-03 01:15:29+00:00)
Title: Texture scaling improvements

This pull request includes a few things:
- Split texture scaling options into factor and technique
- Add two new techniques: Bilinear (obvious) and Hybrid (see below)
- Adjust xBRZ to deal better with textures featuring an alpha channel by including it in the pixel distance calculation (resulting in subtle improvements e.g. in fonts)

So, what is hybrid scaling?
Basically, when I finished implementing the xBRZ scaling and played around with it a bit, I (and others) noted that it causes a pretty severe [posterization](http://en.wikipedia.org/wiki/Posterization) issue. My idea to fix this was to detect areas with gradients and filter those linearly, while applying xBRZ to areas with detail. A few hours with Matlab later I had hybrid scaling. Then it just took a couple (ok, many) more hours to get it working in PPSSPP.

This example shows the difference between the 3 scaling modes in Wipeout:
Linear: http://abload.de/img/ppssppwindows_2013_059dfi7.png
XBRZ: http://abload.de/img/ppssppwindows_2013_05czi30.png
Hybrid: http://abload.de/img/ppssppwindows_2013_058qdqm.png

Just look at the sky/clouds to see the severe posterization in the XBRZ case, which is eliminated with hybrid scaling.

The main drawback of hybrid scaling is performance -- it takes ~4 times as long as xBRZ scaling in my tests. It's still perfectly usable even at the (overkill) 5x setting on my system, but it's probably out of the question on mobile devices. Some of this is just an implementation issue, it could probably be around twice as fast.