Filters for Scaler

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, Greenious, spiny, Sorgelig, Moderator Team

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Filters for Scaler

Postby Sorgelig » Wed Dec 05, 2018 8:36 am

This topic is for discussion about filters.

ghogan42 made some filters: https://github.com/MiSTer-devel/Filters_MiSTer

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Filters for Scaler

Postby Sorgelig » Wed Dec 05, 2018 8:49 am

I think LCD effect with blur is oxymoron - either LCD or blur :)
I would like to see LCD effect with lite-strong scale instead. I remember i had one version of LCD with darker lines. Also the ratio between dot and gap size can be different for different tastes :)

Also the coeff_pp.txt from Main_MiSTer repository gives best result in Minimig (not released yet) - i believe it's Laczos 2 as i've extracted it from VIP scaler. May be some more Lanczos 2/3 filters would be good.

ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Wed Dec 05, 2018 5:42 pm

Yeah, LCD Blur is a bit of an oxymoron. What those filters are is a very sharp scaler (close to NN) and then a wide blur added to it at low strength to it to make it look a little smeared. So the LCD pixels are still sharp squares but they sort of bleed into adjacent pixels.

I do need to make a series where the LCD grid is different darkness. The reason I didn't yet is because thin lines scale badly without integer scaling so the LCD ones are hard to make look good.

The problem with Lanczos is that lanczosN is defined to be filter with 2N taps. So lanczos3 is a 6-tap filter. You can still calculate the coefficients for 4 taps and then scale them up so the rows add up to 128. Or you can squeeze the kernel to fit in [-2,2] instead of [-3,3] and [-4,4] and then compute 4 taps. I think you had Lanczos3 on one axis and lanczos2 on another for the VIP polyphase. I think the coefficient size goes over 255 though for lanczos4 squeezed in [-2,2].

Fake EDIT: While I was typing this up I tried and I see how to make a lanczos2 series with different sharpness levels. So no problem now. I'll add those soon. They're easy to make and look good -- better than the lanczos2 I have now.

Real EDIT: Also I can do Lanczos3. I don't think it looks good but it may look better for small resizes of higher resolution screens like amiga.

Another EDIT: Just did some tests in the preview app. Some Lanczos variants look *much* better than the Gaussian_Sharp_XX for amiga workbench type things. I'll get these made tonight when I have to to check them out on MiSTer for real.

ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Thu Dec 06, 2018 7:18 am

I added some variants of Lanczos to the repository.

Normally, Lanczos2 is defined on [-2, 2] and is used for a 4-tap filter,
and Lanczos3 on [-3,3] and is used for a 6-tap filter,
and so on.

I decided to try to compress Lanczos3 to [-2,2] by applying a 1.5x compression and discovered that I get essentially the same values from the VIP polyphase filter that is the default in MiSTer.

I tried a few intermediate compression values and decided that a couple of Lanczos2 and Lanczos3 variants were ok to include. They tend to look better than the Gaussian_Sharp_XX filers for smaller upscaling values like 1.8x as opposed to 4.5x like you might see when scaling 240p sources.

I also added the Lanczos3 Horz. and Lanczos2 Vert filter from the VIP Polyphase Filter.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Filters for Scaler

Postby Sorgelig » Thu Dec 06, 2018 7:22 am

I will extend Filter setting to use it per-core as it's hard to find one filter for all.

Usually 240p input resolutions are used for games so NN(with LCD for example) should work best.
High resolutions are usually present on computer with text like Amiga, so Lanczos will be better for them.

ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Thu Dec 06, 2018 7:38 am

Sorgelig wrote:High resolutions are usually present on computer with text like Amiga, so Lanczos will be better for them.


Someone made a little preview app for the filter coefficients that you can load images to and set the scaling factor. I loaded in some screenshots with different resolutions of the Amiga workbench up to about 1024x768. It's just like you say, the Lanczos filters are better for text on computers.

ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Thu Dec 13, 2018 9:40 am

I just corrected a number of filters where the row sums weren't 128. They had faint light or dark lines appearing periodically that were noticeable in flat shaded regions. Hopefully, I fixed all of them. Bicubic, two of the Gaussian_Sharp_XX and all of the catmull-rom scanlines where affected! I though I had run them all through a function that would fix the coefficients for me but I guess I didn't have that working right. :(

I'm working on some better LCD effects. Rysha/Kitrinx asked if an LCD effect could be made where the border is brighter instead of darker. I need to spend a little time trying to see if I can minimize weirdness with non-integer scaling but I should have something in the next day or two. It only looks good with Game Boy, but that's ok.

So far it looks like this. Notice the light cross hatch pattern. That's what I'm trying to minimize before I post them to the repository:

Image


Does anybody see anything missing from the currently available filters that should be implemented? Feel free to post it here!

ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Fri Dec 21, 2018 10:40 am

I had more time to work on the LCD Filters.

The best thing that happened is that the Phase Accurate mode of the scaler clears up the scaling artifacts from the LCD shader if you're at either an integer scaling factor like 5x at 720p or at a half integer factor like 7.5x at 1080p.

This means as soon as the Game Boy core is updated officially you'll have better filters and perfect scaling! Here's a fake screenshot from the preview app, but even better output is available from mister now.

Also it shouldn't be necessary for Game Boy because the numbers come out evenly, but if you want to use the lcd filter effects with other systems like Game Gear, you'll need to lock the scaling to 0.5 intervals for good quality. The way you do that is with an updated mister binary (not yet officially released) and the new option "vscale_mode". Setting this to 2 will lock mister into half integer scaling which is necessary for good quality with some filters.

EDIT: Use right-click -> open in new window to see the pic full size
Image

And here is a link if you want to try the phase accurate mode of the scaler for Game Boy or the "vscale_mode=2" modes before the official release of the core or mister binary.

https://drive.google.com/open?id=1J3le1 ... i0C9LHvdNa
You do not have the required permissions to view the files attached to this post.

User avatar
Newsdee
Atari God
Atari God
Posts: 1482
Joined: Fri Sep 19, 2014 8:40 am

Re: Filters for Scaler

Postby Newsdee » Fri Dec 21, 2018 1:14 pm

These LCD effects are gorgeous. Good work!

User avatar
Shazz
Atari Super Hero
Atari Super Hero
Posts: 576
Joined: Wed Aug 27, 2003 9:27 am
Location: Crétin des Alpes dauphinoises

Re: Filters for Scaler

Postby Shazz » Thu Dec 27, 2018 4:00 pm

Hi,

Would it be technically possible (I just ordered a DE10 board, I did not find yet how the display is implemented, any pointer welcome) to implement filters like Leonard's SainT CRT SC1425 emulation using shaders (http://leonard.oxg.free.fr/SC1425/SC1425.html) ?

Is there a description of the MiSTer architecture (What's running in the FPGA vs the ARM code and so on) ?
...8bits are enough...

Grabulosaure
Atari maniac
Atari maniac
Posts: 91
Joined: Tue Sep 05, 2017 9:35 pm
Contact:

Re: Filters for Scaler

Postby Grabulosaure » Thu Dec 27, 2018 4:19 pm

Shazz wrote:Hi,
Would it be technically possible [...] to implement filters like Leonard's SainT CRT SC1425 emulation using shaders [...] ?

Possible, yes.
Easy, no.
Image deformations or rotations would require a different type of scaler. More complex, larger, more cached RAM in internal buffers, more memory bandwidth used. It is still interesting, and MiSTer could one day support early 3D game consoles, with support for texture mapping shaders...

Adding effects for imitating RGB phosphors patterns would be _far_ easier.

User avatar
nightshadowpt
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 115
Joined: Wed May 10, 2017 5:04 am

Re: Filters for Scaler

Postby nightshadowpt » Sun Dec 30, 2018 10:47 am

Grabulosaure wrote:Adding effects for imitating RGB phosphors patterns would be _far_ easier.


And that is exactly the kind of filter I love the most, as many of these machines run on phosphor CRT's that gave the image a nicer look than those ugly blocky pixels we get from the LCD's.

Scanlines are the "easy" fix, but a proper CRT effect goes a long way providing authenticity to the experience...

Thank you guys for all the wonderful work you have been doing on this topic.

stefanem
Atarian
Atarian
Posts: 7
Joined: Thu Apr 11, 2019 7:11 pm

Re: Filters for Scaler

Postby stefanem » Tue Apr 23, 2019 10:02 pm

Grabulosaure wrote:Adding effects for imitating RGB phosphors patterns would be _far_ easier.


Is anything remotely comparable to this in the works?

bhamadicharef
Atariator
Atariator
Posts: 22
Joined: Tue Jul 18, 2017 8:31 am
Location: Singapore

Re: Filters for Scaler

Postby bhamadicharef » Fri Oct 11, 2019 4:52 am

ghogan42 wrote:Does anybody see anything missing from the currently available filters that should be implemented? Feel free to post it here!


I like the filters for scaler and as not everyone has MATLAB, I think a C/C++ or python version
of the filter design tools would be useful. I have started to convert to C and will be adding
a Qt GUI. Plot the impulse response and need to implement the scaler for a png / bmp image
so one can see the effect. Maybe there are some image processing libraries with this already
implemented ? OpenCV even maybe has it.

Interesting would be to assess how these Polyphase filters perform (visually) when applied to
some test images (e.g. MATLAB has Jähne test pattern) and allow to play around with coeffs
either using standard methods or free value poking ...
Brahim HAMADI CHAREF:: Singapore

yxkalle
Atarian
Atarian
Posts: 5
Joined: Fri Oct 04, 2019 3:08 pm

Re: Filters for Scaler

Postby yxkalle » Fri Oct 11, 2019 1:59 pm


ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Fri Oct 11, 2019 10:17 pm



Yep that's the thing to use! Yxkalle knocked that out super quick back when the filters were brand new. I compiled it myself just just to change the default image so that I wouldn't have to load one every time I start the app.

https://drive.google.com/open?id=1GOZnB ... wMOxFCSwN1

bhamadicharef
Atariator
Atariator
Posts: 22
Joined: Tue Jul 18, 2017 8:31 am
Location: Singapore

Re: Filters for Scaler

Postby bhamadicharef » Sat Oct 12, 2019 12:16 am

First time I hear about this tool, thank you for sharing
Brahim HAMADI CHAREF:: Singapore

yxkalle
Atarian
Atarian
Posts: 5
Joined: Fri Oct 04, 2019 3:08 pm

Re: Filters for Scaler

Postby yxkalle » Sun Oct 13, 2019 7:46 pm

Wasn't sure anyone needed this tool, so I haven't "advertised" it. ;)
I just made a small update that saves the settings, like last used filter, image and scale factors.

Lightwave
Atari freak
Atari freak
Posts: 61
Joined: Sun Dec 16, 2018 8:18 pm

Re: Filters for Scaler

Postby Lightwave » Wed Oct 23, 2019 1:07 am

ghogan42 wrote:Does anybody see anything missing from the currently available filters that should be implemented? Feel free to post it here!


I really like the Catmull-Rom scanlines as they add a bit of softness that looks nice on my VGA CRT. The normal vertical scanlines look a bit to sharp for my taste however. Any chance you could add Catmull-Rom vertical scanlines (if that is even possible)?

Thanks for your work on the filters.

ghogan42
Atari maniac
Atari maniac
Posts: 91
Joined: Wed Oct 17, 2018 7:27 pm

Re: Filters for Scaler

Postby ghogan42 » Wed Oct 23, 2019 9:12 am

Lightwave wrote:
ghogan42 wrote:Does anybody see anything missing from the currently available filters that should be implemented? Feel free to post it here!


I really like the Catmull-Rom scanlines as they add a bit of softness that looks nice on my VGA CRT. The normal vertical scanlines look a bit to sharp for my taste however. Any chance you could add Catmull-Rom vertical scanlines (if that is even possible)?

Thanks for your work on the filters.


I'm getting together an update for the filters that will reorganize them into subfolders now that we have the ability to use subfolders for filters and also for the new gamma tables too. After I get that up in the next couple of days we can add more vertical scanlines if needed since they can be put into a "Vertical Scanlines" subfolder.

We also have soft and sharp variants of newer brighter scanline filters, but i only made a couple of the for use in vertical games. Again, we can add more now that they have a place to go.

In the mean time, you can actually just open on the scanline filter (it's a text file) that you like and if you copy/paste to switch the horizontal coefficients with the vertical coefficients then you will get vertical scanlines. It's super easy.

Lightwave
Atari freak
Atari freak
Posts: 61
Joined: Sun Dec 16, 2018 8:18 pm

Re: Filters for Scaler

Postby Lightwave » Wed Oct 23, 2019 1:21 pm

ghogan42 wrote:
Lightwave wrote:
ghogan42 wrote:Does anybody see anything missing from the currently available filters that should be implemented? Feel free to post it here!


I really like the Catmull-Rom scanlines as they add a bit of softness that looks nice on my VGA CRT. The normal vertical scanlines look a bit to sharp for my taste however. Any chance you could add Catmull-Rom vertical scanlines (if that is even possible)?

Thanks for your work on the filters.


I'm getting together an update for the filters that will reorganize them into subfolders now that we have the ability to use subfolders for filters and also for the new gamma tables too. After I get that up in the next couple of days we can add more vertical scanlines if needed since they can be put into a "Vertical Scanlines" subfolder.

We also have soft and sharp variants of newer brighter scanline filters, but i only made a couple of the for use in vertical games. Again, we can add more now that they have a place to go.

In the mean time, you can actually just open on the scanline filter (it's a text file) that you like and if you copy/paste to switch the horizontal coefficients with the vertical coefficients then you will get vertical scanlines. It's super easy.


Awesome, that all sounds great.

Also, thanks for the tip regarding editing the filters, I didn't realize it was that simple :)


Return to “MiSTer”

Who is online

Users browsing this forum: No registered users and 11 guests