Author Topic: New stretch option for FBA!  (Read 17816 times)

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: New stretch option for FBA!
« Reply #15 on: November 16, 2015, 08:32:47 PM »
On second thought, is there any way to force the scaling engine to make sure every pixel is the same width?

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #16 on: November 16, 2015, 09:54:03 PM »
On second thought, is there any way to force the scaling engine to make sure every pixel is the same width?

Not possible really. Non-integer stretching does produce inaccurate data. It's posible to use some softfx filters with scanlines for a quick palliation, haven't tried that though. It should be possible to upscale to a bigger integer resolution and then downscale from that. This way should produce better sized pixels.

On the other hand I believe that changing the way the scanlines are generated is still a viable option.

Your pictures really show a lot of moire. I have attached a similar picture, try disabling both pre-scaling options for the blitter.
« Last Edit: November 16, 2015, 10:05:42 PM by gausen »

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: New stretch option for FBA!
« Reply #17 on: November 16, 2015, 10:38:59 PM »
While improved, I still couldn't imagine scanlines looking like that.  hmm, I've been wanting to come up with a good idea for a long time now.  maybe, apply the scanlines after resizing? hmmm.. well, I don't mean to derail your thread, what you've done is really nice.  my quest, otoh, is sort of a personal one.

best regards,
- dink

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #18 on: November 16, 2015, 10:48:10 PM »
There a lot of ways of sorting this up. But I will avoid those that take lots of work (like writing a new blitter). Don't lose hope just yet, while the non integer scaler could do fine I never thought of this scanlines as a final product. I'm working on something, if it comes to fruition you will be the first to know  :wink:.

EDIT: I might have found something, it's far from usable but eventually it will work (screenshots attached). Made the scanlines few and fat to make them more noticeable. Going to bed now, it's 1:10 am here.
« Last Edit: November 16, 2015, 11:12:40 PM by gausen »

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #19 on: November 17, 2015, 05:32:56 AM »
Updated D3D blitter. Still WIP. Vertical scanlines don't look so good.

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: New stretch option for FBA!
« Reply #20 on: November 17, 2015, 07:23:05 AM »
That's quite an improvement, nice! :)

Offline Romhack

  • Expert
  • *****
  • Posts: 92
  • Karma: +49/-0
Re: New stretch option for FBA!
« Reply #21 on: November 17, 2015, 07:25:15 AM »
Really nice.

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #22 on: November 17, 2015, 07:34:26 AM »
Thanks! You can give it a shot if you like. All you need is the source from the first post and the updated blitter from my latest post with screenshots.

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #23 on: November 17, 2015, 11:45:09 PM »
Ok, after some more reading I now know a few important things (please forgive my previous and present ignorance).

FBA does have proper non-integer scaling code (it just don't work with scanlines). This changes everything, I'm now working on making this code work with scanlines.

Non-integer scaling w/scanlines doesn't look nice on windows. It's a feature more suited for fullscreen gaming.

So far the issue is related to the texture coordinates passed for scanline textures. I know this because fixing it in the D3D and DX9 blitters greatly improved things (so far all the games tested looked great in fullscreen as long as scanlines are horizontal). Fullstretch also suffered from the same moire when using scanlines. With this partial fix fullstretch is also looking good. Vertical scanlines still looking bad though.

Some screenshots and fresh code attached.





Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: New stretch option for FBA!
« Reply #24 on: November 18, 2015, 09:19:11 AM »
Nice, Looking good :)  I was playing around with MAME earlier, and it seems no matter how the window is resized, the scanlines(H or V) stay perfect.  I was meaning to check out how they do it, but kept getting side tracked.. hehe..


Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #25 on: November 18, 2015, 06:55:03 PM »
Nice, Looking good :)  I was playing around with MAME earlier, and it seems no matter how the window is resized, the scanlines(H or V) stay perfect.  I was meaning to check out how they do it, but kept getting side tracked.. hehe..

I'm sure they have a proper solution. They have been rolling for a long time. No surprise you are getting side tracked, you are producing an insanely big amount of fixes and new systems support!  :biggrin:

In the mean time here I have a some new code  ;p. I've added a scanline multiplier in the ini to control the effect. I'm not seeing moire or hatching on any of my screens and scanlines remain solid independently of re sizing.

The default is set to 16x (It works ok and looks nice on my screens). The sweet spot though should be tweaked for each screen I supposed. I've seen moire by setting this number to some crazy value like 512. This time only the D3D blitter was fixed. Give it a try if you like. I'm sure there must be plenty of cases where it doesn't work.
« Last Edit: November 18, 2015, 07:03:33 PM by gausen »

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #26 on: November 23, 2015, 03:56:36 PM »
Posting some progress. First whats on this update:

*Updated DX9Alt blitter (now have proper scanlines with all stretching modes).
*The non integer stretching option.

How does this work?
FBA sets scanlines to the same amount of the limiting dimension. For example in SteetFighterAlpha2 224 scanlines are going to be needed, this requires at least 2x arcade resolution. On lcd/led screens the maximum amount of presentable scanlines is half of the biggest resolution. Exactly fitting scanlines for the screen will be halfMaxMonitorRes / N (with N being an even number). The modified blitter calculates exactly monitor fitting scanlines closest to the emu required scanlines. 

For this blitter you have inaccurate MAME style scanlines for zoom factors smaller than 2. For zoom factors bigger than 2 you have closest to FBA scalines. Obviously for resolutions that are integer multiples of arcade res you have perfect FBA scanlines. Also for zoom factors between 2 and 4 thin FBA scanlines are used while for zoom factors bigger than 4 fat FBA scanlines are used.

Which are the issues?
*I can see slight aliasing/moire/hatching when rezising a window. Somehow fitting the window so that there are no black borders at the sides of the game screen reduces or remove the effect.
* I've seen two fat vertical lines in dig dug on a 1080p fullscreen resolution. Changing the fullscreen resolution completely removes this issue.

EDIT: Attached a bug free d3d blitter. As far as I can test no moire, hatching or aliasing here. Works nice with the new stretch option.

EDIT2: A few more screenshots from the D3D blitter.
« Last Edit: November 25, 2015, 08:51:55 AM by gausen »

Offline gausen

  • Newbies
  • *
  • Posts: 19
  • Karma: +2/-0
Re: New stretch option for FBA!
« Reply #27 on: May 08, 2016, 03:26:46 PM »
Hi All. I've been working a little more on this. Since I can't find a way to pull an arbitrary stretch while keeping proper scanlines aligned I'm trying a different approach. The option now is an integer overscan, that is incrementing the fitting scaling by one. The aspect ratio and scanlines alignment are conserved at the expense of loosing some lines. The amount of lines lost depends on the monitor and game resolutions. Screenshots are attached for a 1080p resolution.

To use the option it has to be selected in video->stretch and only the Enhanced blitter have been modified to accept it in fullscreen (other blitters will show a blackscreen).


Offline jan_klaassen

  • FBNeo Dev
  • ******
  • Posts: 315
  • Karma: +10/-0
Scanlines are harder than it seems at first blush...
« Reply #28 on: January 16, 2017, 04:21:37 PM »
Because apparently I like digging up and flogging dead horses.

There's a reason streching scanlines to arbitrary ratios looks bad -- it's simple math. And you can't make the problem go away, you can only try to mitigate the artifacts. The mitigation strategies you can apply use tend to have tradeoffs. The easiest is to just use higher display resolutions, as that by itself minimises the artifacts.

So that's why FBA enforces integer stretching ratios when using scanlines. It also allows for the use of point filtering when stretching vertically, which makes for even betterer looking scanlines. That said, there are  several new ways of displaying scanlines coming to FBA's DX9 blitter that let you scale them to any ratio you wish. And although they were designed to minimise aliasing, they do still alias. Sometimes clearly so, even at 1080p. You can't beat math...

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: New stretch option for FBA!
« Reply #29 on: January 16, 2017, 06:00:08 PM »
So true, but I really like this gausen's full screen stretch modes.  I would like to re-add gausen's full screen stretch mode code again sometime when things aren't so busy, and also create an alternate option for chosing it..  gausen - would you please post the latest code?  :)

best regards,
- dink