English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 17 September 2016, 23:59   #1
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
Pre-scaling before bilinear filtering for less-blurry image

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.]
Attached Thumbnails
Click image for larger version

Name:	WB_1024x768.png
Views:	160
Size:	14.6 KB
ID:	50010   Click image for larger version

Name:	Scale_up_1.5x_to_1536x1152.png
Views:	141
Size:	59.9 KB
ID:	50011   Click image for larger version

Name:	Scale_up_2x_down_to_1536x1152.png
Views:	164
Size:	35.5 KB
ID:	50012  
mark_k is offline  
AdSense AdSense  
Old 21 September 2016, 18:46   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,222
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..
Toni Wilen is online now  
Old 21 September 2016, 18:55   #3
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
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?
mark_k is offline  
Old 21 September 2016, 18:58   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,222
Quote:
Originally Posted by mark_k View Post
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).
Toni Wilen is online now  
Old 21 September 2016, 19:08   #5
Locutus
Registered User

 
Join Date: Jul 2014
Location: Finland
Posts: 831
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.
Locutus is offline  
Old 21 September 2016, 19:27   #6
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
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.
mark_k is offline  
Old 21 September 2016, 20:12   #7
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,222
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.
Toni Wilen is online now  
Old 02 October 2016, 17:52   #8
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
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?
Attached Files
File Type: zip PointFilter.zip (863 Bytes, 32 views)
File Type: zip my_test_JIT_uaegfx_FilterTest.zip (2.7 KB, 30 views)
mark_k is offline  
Old 02 October 2016, 20:46   #9
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,222
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.
Toni Wilen is online now  
Old 02 October 2016, 21:23   #10
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
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
Attached Files
File Type: txt prescale.fx.txt (2.9 KB, 37 views)
mark_k is offline  
Old 03 October 2016, 22:01   #11
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
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.
Attached Thumbnails
Click image for larger version

Name:	Original_unscaled.png
Views:	82
Size:	9.5 KB
ID:	50289   Click image for larger version

Name:	WinUAE_1.5x_null_bilinear.png
Views:	70
Size:	201.5 KB
ID:	50290   Click image for larger version

Name:	WinUAE_2x_point_1.5x_null_bilinear.png
Views:	75
Size:	138.3 KB
ID:	50291   Click image for larger version

Name:	mtpaint_2x_to_1.5x_bilinear.png
Views:	81
Size:	25.1 KB
ID:	50292   Click image for larger version

Name:	mtpaint_3x_to_1.5x_bilinear.png
Views:	66
Size:	22.8 KB
ID:	50293  

Attached Files
File Type: zip Config_and_shader.zip (4.1 KB, 30 views)

Last edited by mark_k; 03 October 2016 at 22:10.
mark_k is offline  
Old 18 March 2018, 13:50   #12
Dr.Venom
Registered User
 
Join Date: Jul 2008
Location: Netherlands
Posts: 384
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?
Dr.Venom is offline  
Old 18 March 2018, 15:55   #13
Foebane
Registered User
 
Join Date: Sep 2011
Location: Cardiff, UK
Posts: 1,051
Mark_K, what's the native resolution of your laptop screen?
Foebane is offline  
Old 27 March 2018, 16:33   #14
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,935
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).
mark_k is offline  
Old 29 March 2018, 08:20   #15
Dr.Venom
Registered User
 
Join Date: Jul 2008
Location: Netherlands
Posts: 384
Quote:
Originally Posted by mark_k View Post
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.
Dr.Venom is offline  
Old 31 March 2018, 16:53   #16
rsn8887
Registered User
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 781
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.
rsn8887 is offline  
Old 31 March 2018, 17:12   #17
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,222
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)
Toni Wilen is online now  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga and MAC-address filtering Depeche72 Amiga scene 15 01 September 2016 16:21
Pre-Scaling before Bilinear Scaling? rsn8887 request.UAE Wishlist 6 05 September 2015 19:13
Integer pre-scale to reduce blurry pixels? rsn8887 support.WinUAE 4 10 April 2015 18:11
D3D point/bilinear setting trouble Ami_GFX support.WinUAE 4 10 December 2014 20:23
Off-by-one error with RTG image scaling? mark_k support.WinUAE 10 01 December 2013 19:18

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.08819 seconds with 16 queries