Menu

#427 New scalerz (based on bilinear filtering)

future
open
nobody
None
5
2021-02-06
2020-04-12
Kiro San
No

==========------------------------------------------=========
==========>>>> New AMAZIN scalerZ for FuZe <<<<=========
==========------------------------------------------=========

HOwdy to U all !!!

I had nothin better to do this weekend so I made this pack of
NO LESS than SEVEN new scalerZ for the best Speccy emulator.

Amazin quality ... like U have never seen before. U are goin
to cry like a baby when U see how nice it lookZ. It'z so beautiful.
Bwwwwaaaaaaaaaaah!!! I'm already crying becauZ I'm so sentimental.
Bwwwwaaaaaaaaaaah!!!

110% realistic and accurate.

======= IncludeZ: =======

++ GamMA C0rREct10n 110% to the sRGB spec on Wikipedia. Amazin!!
Can't be beaten. U can't get this even on newest and lamest GPUs,
cuz this is pure CPU calc. Yes!!! ! It's absolutely 110% color
accurate.

++ ProvideZ 110% c0mpletely accurate rendering of muddy blurry
fuzzy PAL TV screen output.

++ A t0tal of 7 (yes, SeVeN!!!) new ScalerZ in 3 cats.

++ The bilinear scaler is the blurriest, followed by bimuddy,
and then the bifuzzy scaler is the sharpest.

### THis is c0mpletely 110% LEGIT !!! !! #### Cross my heart! ! ! !

======= Reccc0mmendati0nZ: =======

 --- If U had the most crappy TV set for UR Speccy back in the dayZ,
 which was making UR eyes bleed and UR head spin, then the bilinear
 filter can recreate this amazin experience for U.

    Note: after using bilinear filter for more than a couple of
    minutes, it is recommended to check with UR doctor so that he 
    can ascertain whether UR brain has already started to melt 
    and drip out of UR ears and eyes.

-- If UR parentZ had at least some small cAsH in their pocketZ,
then they could have provided U with a mediocre TV set which 
they bought to better enjoy the s0ap operas and other crap 
they were watchin. In this case the bimuddy filter is what U 
are l00kin for.

-- If U are from some upper class stiff lip family which 
wipeZ their asseZ with medieval silk toilet paper, then 
UR TV set wuZ probably top-of-the-line and state-of-the-art. 
The bifuzzy filter might be the best choice.

===== Misc =====

GreetingZ to all the Speccy fanZ round the globe U're all
amazin. The Speccy liveZ forever!!!!!!!!

Abs0lutely no need to thank me it wuZ my holy duty to make
Speccy emulator better I enjoyed doin it all the pleasure
is mine. The diff is bout 750 linez.

1 Attachments

Discussion

  • Kiro San

    Kiro San - 2020-04-15

    Hell0 again.

    I have n0ticed a small issue in the 0riginal patch.
    The initializati0n function was called m0re than 0nce. Darn!
    It cauzez no ill effectz, but it is ann0yin f0r me to have submitted a sub0ptimal patch.

    S0, attached is the fixed version of the patch.

     
  • Alberto Garcia

    Alberto Garcia - 2020-05-08

    Hi, and thanks for the work!

    I gave it a quick test and the scalers look good, although I find them quite similar to each other. Do you have an example where their differences are very visible? (I think that we already have a lot of scalers in Fuse, and some don't look very good, but that's just my opinion).

    A few problems that I noticed with the patch:

    • You made a reverse diff: the new scalers are removed, not added. I had to pass -R to patch or git apply.

    • There are a lot of lines in the patch where nothing changes, you only add or remove whitespaces. This should be cleaned. git apply also complains about it: warning: 9 lines add whitespace errors.

    • The coding style and indentation is quite different from what Fuse normally uses.

    • The documentation (man/fuse.1) should also be updated.

    But otherwise the patch works and can be tested. I would first wait until there's a decision about whether we want to have these new scalers in Fuse, and then the patch can be corrected.

    Thanks again!

     
  • Kiro San

    Kiro San - 2020-06-11

    Yes, the scalers are all very similar, the only difference is the amount of blur. The blur is always hard to notice, so it's hard to tell the difference. >>> You have to switch between the provided filters while focusing your eyes on the image to notice the difference<<<!!! So, there are three levels of blur: bilinear (too much blur), bimuddy(medium) and bifuzzy (simulates a very fine telly).

    In the 80's, the tellys had different amounts of blur, so this is intended to simulate that situation. These filters are intended to be "true to the original" to an unprecedented amount. I even added the gamma correction to make it more accurate, what other emulator in the world has gamma correction implemented? This is more accurate than the display output of any other emulator of any old machine that I know of (and those others would be wise to copy and use this work of mine, for example Dosbox and NES emulators would benefit from this kind of filtering). I personally prefer the bimuddy filter (I invented the name "bimuddy", because I have never stumbled upon this kind of slight modification to make bilinear filter a bit sharper).

    • The original patch is reversed (sorry about that). The last patch (v2) should be normal. Or did I manage to mess it up again? Maybe I'm going crazy, or am I crazy already?

    • About whitespaces: I usually add some whitespace unintentionally, and then I fix it by using a "remove unnecessary whitespace" option in my favorite editor (geany). So either I fixed some extraneous whitespace in the other parts of the file, or I forgot to run "remove whitespace" at the end of my coding process. Anyways, there is no harm. I'll try to be more carefull next time. But, Git will probably still output the message because I'll run the "remove unnecessary whitespace" on the entire file, and there is probably some unnecessary whitespace in the other parts of the file, left there by some other untidy developer.

    • Yeah, that's my style. Sorry. Can't help it, that's how I write. For example, I find any other style annoying. Run it through some source code beautifier if you like, it's OK, I'm used to reading other people's styles, despite the annoyance. And, I don't like reading idiotic 50 page style guidelines (cuz my style is better, end of discussion).

    • Ok, I'll update the docs in the next version of the patch. I didn't know that I should update the docs, but the docs are certainly a valuable asset im ny opinion. Anyway, it is just a bit of copy-paste work, it is easy to do.

    By the way: these filters are beneficial even if you implement arbitrary window-resizing over them, with some other filter used for resizing (probably bilinear cuz that's the easiest, despite the excessive blur. I mean, every GPU and every graphics API has it).

     
  • Kiro San

    Kiro San - 2020-06-11

    I can now finally enjoy Manic Miner in it's full glory.

    By the way, some jostick functions are buggy in the current version of Fuze (I press a button, and it fires, but it doesn't "hold down"). I have to figure out what's going wrong, but it works OK in Manic Miner. The problem appears when joystick buttons are mapped to keys, I think, and only with some key combos. Will report.

     
  • Kiro San

    Kiro San - 2020-06-11

    Ah, darn, patch v2 is also reversed, only v3 is OK. Here is patch v3:

     
  • Kiro San

    Kiro San - 2020-06-11

    I strongly recommend keeping in all the SEVEN provided filters. Don't cut your users on their preferences. All three kinds (bilinear, bifuzzy and bimuddy are needed), and due to the Hi-DPI thing, all variations are required.

    By usefulness:
    1. bimuddy (most useful)
    2. bifuzzy(just slightly more sharper for perople who prefer sharp)
    3. bilinear (for people who dislike seeing pixels)

    By resolution (scale factor): today's monitors have a vide variety of DPI. So I provided 2x - 4x scaling. Bifuzzy and bimuddy probably can't be done in 2x scaling version while keeping the required uniformity.

    So, you have to keep all the filters in because you don't know what is the DPI and resolution of user's monitor. I mean, it's not just the DPI, because the distance from eyes to monitor also varies, so it is some other measure like "pixels-per-unit-angle", ad that one is impossible to know because the user can put his display on different distances from his eyes.

    I mean, the makers of your favorite operating system SHOULD have put in some OS-wide setting called "scaling factor", which should balance all this, but this is mostly either not-working or just barely working in todays OSes, and there is no way for applications to query the value. Of course, this all says something about quality of today's software (low quality), even OS-es (catastrophic), and the developers/companies who make it (they don't care: it either works OK on their displays, or sells well as it is).

    So, you said:
    "I think that we already have a lot of scalers in Fuse, and some don't look very good, but that's just my opinion"

    Yes, you have a lot of filters, and you need this extra 7 also. It is all needed. Why cut out? MOre options = better.

     
  • Kiro San

    Kiro San - 2020-06-11

    Here is a new patch (v4) with the following changes compared to v3:
    - added documentation in man/fuse.1 (this is the first time that I'm adding a man doc)
    - consistently applied "strip trailing spaces" to every modified .c and .h source code file

    As I have previously indicated, I like these new filters a lot, and I hope that other users will like them, too. Enjoy your new and beautifull filtered output image.

     
  • Kiro San

    Kiro San - 2020-06-12

    Here is a quick explanation of provided filters:

    The bilinear filtering uses a "triangle "weighting function:
    if (0<=x<1): fb(x) = 1-x
    elseif (-1<x<0): fb(x) = x+1
    else f(x)=0

    It is called "triangle" because it looks like a triangle when drawn as a graph, because the function slopes are straight lines. Since the slopes are straight lines, it is also commonly called a "linear" filter.

    Of course, this above is a 1D simplification (1D linear filter), a componenet of 2D version, which is called "bilinear" (like: linear in both dimensions). The 2D case ("bilinear filter", where both x and y components must be multiplied together) uses this formula:
    if (0<=x<1 and 0<=y<1): fb2D(x,y) = (1-x)*(1-y)
    ... etc

    One important property of this "linear filter" function fb, which ensures the "brightness invariance" property is:
    if (-1<x<1): f(x) + f(1-x) +f(-1+x) = 1

    The trick is that this is not the only function having the desired property. For example, this one also fits, but it is not linear, it is quadratic:
    if (-0.5<x<0.5): f2(x) = 1-xx
    elseif (-1<x<-0.5): f2(x) = (x+1)
    (x+1)
    elseif (0.5<x<1): f2(x) = (x-1)*(x-1)
    else f(x)=0

    But, f2 has an undesirable property that it is discontinous. So, you make a continous version f3:
    if (-0.5<x<0.5): f3(x) = 1-2xx
    elseif (-1<x<-0.5): f3(x) = 2(x+1)(x+1)
    elseif (0.5<x<1): f3(x) = 2(x-1)(x-1)
    else f(x)=0

    ... and so you can invent more than an uncountably infinite number of weighting functions.

    The next thing to notice is that the original function, fb (bilinear filter) is excessively blurry when applied. Then you try out the f3 and you find out that it is sharper.

    Then, you select some of the possible variations that have the amount of blurriness which you like. Those are the bimuddy and bifuzzy filters.

    The trick is that, if the scaling factor is fixed and an integer, it can all be easily optimized to run extremely fast on a CPU. It almost doesn't matter whether you use bilinear, bimuddy or bifuzzy, or any other version: the code is exactly the same in each case. Ok, bilinear can be made even faster, but only by a small amount.

    It can also be done for noninteger scaling factor (arbitrary scaling), but it is a bit more work, slightly slower (because large precalc tables might be required) and in the case of current Fuse code it was irrelevant because Fuse currently uses integer scaling factor of 2,3 or 4 for all the filters.

    So, if necessary, you can also make arbitrary-scaling-factor version of bimuddy and bifuzzy.

    I don't know whether this explanation helps, because it now looks like a lot of text, but I tried to quickly explain it. But, I hope that this explanation helps you to understand those new filters.

     
  • Kiro San

    Kiro San - 2020-06-12

    I forgot:
    The bilinear filter is implemented in the patch as folows:
    === for 2x bilinear ===
    f(1)=1, f(0.5) = 0.5, f(-0.5)=0.5
    === for 3x bilinear ===
    f(1)=1, f(1/3) = 2/3, f(2/3)=1/3, then simetrical for negative x
    === for 4x bilinear ===
    f(1)=1, f(1/4) = 3/4, f(2/4)=2/4, f(3/4)=1/4, then simetrical for negative x
    === for 3x bimuddy ===
    f(1)=1, f(1/3) = 3/4, f(2/3)=1/4, then simetrical for negative x
    === for 3x bifuzzy ===
    f(1)=1, f(1/3) = 4/5, f(2/3)=1/5, then simetrical for negative x

    I think these coefficients are correct, if my memory serves me well, but even if I made a mistake, you can figure out what the general idea is.

     
  • Kiro San

    Kiro San - 2020-06-12

    Of course, to extend the bimuddy and bifuzzy filters to arbitrary scaling, you must play the game of "connect the dots". So, there are more than uncountably many versions of bimuddy and bifuzzy if arbitrary scaling is desired, depending on how you connect the dots. Use common sense to select the variations that you like.

     
  • Kiro San

    Kiro San - 2020-06-12

    I would also like to add that none of the existing Fuse filters can simulate blur. So, all the other filters that purpotedly simulate a TV set are deeply and essentially flawed, since BLUR is the PRIMARY effect on 99% of CRT television screens.

    All the effects that those other filters are simulating were virtually non-existant on 99% of real CRT TV sets, for various reasons, and I certaily won't go explaining and debunking each one since that would make this post too long.

    So, since those filters are flawed, I suggest that they should be removed as they serve little or no real purpose. The only usefulness of filters like "PAL TV" is that they are artistic creations, and some users may like them as such. They are certainly not a simulation of any significant real world effects.

    The other filters that are available, like HQ and MAME, are, again, artistic creations intended to hide the appearance of pixels, only because pixels were out-of-fashion some time ago. They certainly don't simulate the image of a TV set, and as such are highly unrealistic and untruthfull to the original. But, some users might like the resulting effect, although I find it mostly annoying, but still better than "nearest neighbour" method of "normal" filters, which is catastrohic (unrealistically and annoyingly sharp).

    Therefore, I conclude that the blurry filters which I provided are a significant advancement for the image quality and simulation realism of the Fuse emulator.

     
  • Sergio Baldoví

    Sergio Baldoví - 2021-02-06
    • Group: NextRelease --> future
     

Log in to post a comment.