English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   support.WinUAE (https://eab.abime.net/forumdisplay.php?f=5)
-   -   Pre-scaling before bilinear filtering for less-blurry image (https://eab.abime.net/showthread.php?t=84145)

mark_k 17 September 2016 23:59

Pre-scaling before bilinear filtering for less-blurry image
 
3 Attachment(s)
This is probably already possible by stacking filters. Can anyone explain how because I haven't been able to figure it out.

I've been using a 1024×768-pixel Workbench. Text looks pretty small on my laptop, so I want to scale the image by 1.5× to have it occupy 1536×1152 pixels on-screen. Setting Horiz. size and Vert. size to 1.5× in Filter Settings works, but the result is pretty blurry.

However, if I could pre-scale the image (e.g. pixel-doubling to 2048×1536 then scaling down with filtering to 1536×1152) the result would be significantly sharper. See the attached images.

The blurrier scaled-up-1.5× image was created using a paint package rather than getting a screenshot of the filtered/scaled image in WinUAE. But it looks pretty similar. The other one was also made using a paint package, scaling up 2× then down with bilinear filtering.

[After clicking a thumbnail, click the image to (hopefully) show it unscaled in your web browser.]

Toni Wilen 21 September 2016 18:46

RTG mode? I think it can do integer scaling quite easily (can be made simultaneously with color space conversion = not free if there is no need for conversion)

Chipset mode? Far from easy..

mark_k 21 September 2016 18:55

Wouldn't being able to apply two null filters work? In my example (which is a chipset mode), I could have the first filter scale by 3× with point filtering, the second filter by 0.5× with bilinear filtering. But it seems the various size & position options/sliders in filter settings are only applied once?

Toni Wilen 21 September 2016 18:58

Quote:

Originally Posted by mark_k (Post 1112452)
Wouldn't being able to apply two null filters work? In my example (which is a chipset mode), I could have the first filter scale by 3× with point filtering, the second filter by 0.5× with bilinear filtering. But it seems the various size & position options/sliders in filter settings are only applied once?

That scaling is just final "blit" to display (with different source and destination rectangles), can't do it twice (or more).

Locutus 21 September 2016 19:08

2x 4x integer scaling of RTG modes would be useful for me, on HiDPI screens AmigaOS is pretty much unusable. 4x integer scaling would make this okay.

mark_k 21 September 2016 19:27

So to achieve what I want, I guess a D3D shader would have to be used? I think all the ones which come with WinUAE apply fancy scaling effects though, there isn't a simple pixel-doubling/tripling one.

Toni Wilen 21 September 2016 20:12

It probably would make best quality. Supersampling mode may also help (1x/2x/3x/4x) menu next to "reset defaults" which allocates 2x/3x/4x larger texture size, shader writes to large texture, then it is scaled back to output size.

mark_k 02 October 2016 17:52

2 Attachment(s)
Like a complete noob I tried making my own shader by simply modifying _winuae.fx, changing filtermode to POINT in the SourceSampler definition:
Code:

sampler        SourceSampler = sampler_state {
        Texture          = (SourceTexture);
        MinFilter = POINT;
        MagFilter = POINT;
        MipFilter = NONE;
        AddressU  = Clamp;
        AddressV  = Clamp;
};

On trying to use that filter with the attached config, starting emulation gives a black screen and this over and over in the log:
D3D9Ex: SetTechnique: 8876086C S=1 F=0876 C=086C (2156) ()

Any idea what I'm doing wrong?

Toni Wilen 02 October 2016 20:46

You can't rename _winuae.fx and use it as a standalone shader. _winuae.fx is special case final pass which also includes support for masks and overlays.

mark_k 02 October 2016 21:23

1 Attachment(s)
OK so much for that.

I found this which looks like it could do the job, with suitable modifications??? https://github.com/mamedev/mame/blob...sl/prescale.fx

mark_k 03 October 2016 22:01

6 Attachment(s)
I think I got an effect close to what I'm after by using this shader: http://www.si-gamer.net/gulikoza/src/point.fx

Using that unmodified there was an error in the WinUAE log, so I changed
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 PS();

to
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS();

after which it seemed to work OK.

I put point_modified.fx as the -4 entry in filter settings, 2x in the box next to that. Extra settings set to bilinear (that applies to the final (null?) shader which WinUAE applies).

Some screenshots are attached:
  • Original_unscaled.png (9776 bytes) - unscaled image
  • WinUAE_1.5x_null_bilinear.png (206293 bytes) - WinUAE display with only null filter, 1.5x scaling, bilinear
  • WinUAE_2x_point_1.5x_null_bilinear.png (141669 bytes) - WinUAE display with 2x point.fx shader then null filter bilinear to 1.5x (less blurry)
  • mtpaint_2x_to_1.5x_bilinear.png (25706 bytes) - Original image, scaled up to 2x (point) then down to 1.5x bilinear with mtpaint paint package
  • mtpaint_3x_to_1.5x_bilinear.png (23326 bytes) - Original image, scaled up to 3x (point) then down to 1.5x bilinear with mtpaint.

Note the much smaller file sizes for the mtpaint-created images. That's because they only use a small number of colours. For whatever reason the WinUAE-filter images have more than 256 different colours in them.

Dr.Venom 18 March 2018 13:50

Hi Mark,

I was interested in trying out your adjusted "pre-scaling shader" today (attached in post #11), as I wanted to see whether there's something similar to MAME's "prescale" factor before applying filtering (which your adjusted shader seems to do just that for WinUAE), but unfortunately it doesn't seem to work with D3D11.

Just wondering, did you get it to work with latest WinUAE 3.6.1 and D3D11?

Foebane 18 March 2018 15:55

Mark_K, what's the native resolution of your laptop screen?

mark_k 27 March 2018 16:33

I haven't done any more work on this since post #11 above. And I don't really know anything about shaders.

Laptop screen res is 1920×1200 but I was running WinUAE in a window. Trying to get a 1024×768-pixel Workbench to look a bit less blurry, 1.5× is the largest "round" scale factor which fits (WB screen would occupy 1536×1152 pixels).

Dr.Venom 29 March 2018 08:20

Quote:

Originally Posted by mark_k (Post 1230509)
I haven't done any more work on this since post #11 above. And I don't really know anything about shaders.

I can understand, shaders are a thing in itself.. In the mean time a solution was provided by guest.r here: point-prescale shader

It works the same way as the MAME prescale setting, i.e. you need to scale this shader 2x or 3x and set the bilinear option to true.

It works very well for lowres screens, but unfortunately there's some scaling issue on hires screens that you may or may not notice.

rsn8887 31 March 2018 16:53

I tried for a long time to get this to work, and I could get it to work in FS-UAE but not in WinUAE.

http://eab.abime.net/showthread.php?t=89811

It is easy to test by looking at the text - in WinUAE, some pixels are more distorted then others after scaling.

On FS-UAE, my shader "sharp-bilinear-simple" works perfectly and has been included in the Git repo already.

Toni Wilen 31 March 2018 17:12

I think there is not enough information, this is more like "it does not work" than including basic config, screenshots and more to describe it exactly. (I am still not sure if I understand what this is really supposed to do and why)


All times are GMT +2. The time now is 20:01.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.11313 seconds with 11 queries