English Amiga Board


Go Back   English Amiga Board > Support > support.FS-UAE

 
 
Thread Tools
Old 14 December 2017, 22:46   #1
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
sharp-bilinear-simple shader for FS-UAE

I added a shader called sharp-bilinear-simple that does an automatic integer prescale for sharp pixels with minimum blur.

Some explanation of the shader is here:
https://gamingprojects.wordpress.com...nd-distortion/

My pull request is here:
https://github.com/FrodeSolheim/fs-uae/pull/167

If you want to try it, you can download the file from here (right click, save as...):
https://raw.githubusercontent.com/rs...-simple.shader

and enable it in fs-uae launcher by adding a line
Code:
shader = <your_path>/sharp-bilinear-simple.shader
in the advanced config textfield.

Last edited by rsn8887; 15 December 2017 at 00:09.
rsn8887 is offline  
Old 15 December 2017, 15:53   #2
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 466
Finally a fast and sharp workbench scaling, thanks. Of course we can use just gl-nearest scaling without any shader. But some pixels are doubled and the very next are not, which makes fonts look extremely ugly. This shader addresses the issue and also works well with "weird" Amiga 640x256 resolution. Very usefull.
jbl007 is offline  
Old 15 December 2017, 19:50   #3
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 466
I think, I found a bug.
RTG screen 960x540 should sharp-scale to 1920x1080 (same output as texture_filter=nearest) but it does not.
It looks like only bilinear scaling is used, same result as no-shader + texture_filter=bilinear.

Edit: Changed
floor(rubyOutputSize / rubyInputSize)
to
floor((rubyOutputSize + 1.0) / rubyInputSize)
to "save" one pixel.
I have absolutely no clue what I'm doing here, but it seems to work, LOL

Last edited by jbl007; 15 December 2017 at 21:35.
jbl007 is offline  
Old 15 December 2017, 20:22   #4
nobody
Registered User
 
nobody's Avatar
 
Join Date: Dec 2013
Location: GR
Age: 46
Posts: 1,416
Very useful for systems that were supposed to stretch the image e.g. SNES stretch 256x224 horizontally to 4:3. This should be ported to WinUAE too.
nobody is offline  
Old 16 December 2017, 18:35   #5
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
Thanks for debugging. It surprises me, maybe the float math gives 1.99998 instead of 2 as a result sometimes?

Can you do a quick check if adding 0.1 or 0.01 produces the correct result too?

I will fix the pull request later today.

Thanks!
rsn8887 is offline  
Old 16 December 2017, 18:54   #6
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
@Jbl007: I tested it again on uae4all2 on the Vita, the Shader works correct there without the +1.0. Scaling source 136 by 4 to target 544 gives a perfect result, just like nearest filtering. So it might be some peculiarity if the FS-UAE ruby_*** variables. Which is good because I already implemented this shader as-is in a whole bunch of apps and games.

@nobody: I already tried to port the shader to WinUAE with disappointing results. WinUAE does some internal scaling and internal shader passes. This results in pixels that are not shaped correctly as soon as my user shader is activated to scale from Amiga to host size. Even if I change my shader to a null filter so it just a pass through the pixels, the pixels in WinUAE become distorted. I had a discussion with Toni about it but we never figured out how to fix it. You can play around with it here:
http://eab.abime.net/showthread.php?t=85432

Last edited by rsn8887; 16 December 2017 at 19:00.
rsn8887 is offline  
Old 16 December 2017, 19:21   #7
guest.r
Registered User
 
guest.r's Avatar
 
Join Date: May 2017
Location: EU
Posts: 342
You could try an even simpler sharp-bilinear shader in which the built in "fit-to-output" slider in WinUAE is set to "Bilinear".
Overscaling the output doesn't hurt here...

The texture sampler should be set to POINT though.

Code:
sampler	sourceSampler = sampler_state
{
	Texture   = (source_tex);
	MinFilter = LINEAR;
	MagFilter = LINEAR;
};
to:

Code:
sampler	sourceSampler = sampler_state
{
	Texture   = (source_tex);
	MinFilter = POINT;
	MagFilter = POINT;
};
A simple pass-trough shader should be used with this method.
Attached Thumbnails
Click image for larger version

Name:	BilinearSetting.png
Views:	210
Size:	3.3 KB
ID:	55861  
guest.r is offline  
Old 16 December 2017, 22:28   #8
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
Quote:
Originally Posted by guest.r View Post
You could try an even simpler sharp-bilinear shader in which the built in "fit-to-output" slider in WinUAE is set to "Bilinear".
Overscaling the output doesn't hurt here...

The texture sampler should be set to POINT though.

Code:
sampler	sourceSampler = sampler_state
{
	Texture   = (source_tex);
	MinFilter = LINEAR;
	MagFilter = LINEAR;
};
to:

Code:
sampler	sourceSampler = sampler_state
{
	Texture   = (source_tex);
	MinFilter = POINT;
	MagFilter = POINT;
};
A simple pass-trough shader should be used with this method.
How do I select the integer prescale factor then? In fact I don’t understand how this results in an integer pre-scale before the bilinear filtering is applied? But I must confess I don’t understand the meaning of he various options in the filter window in WinUAE very well.
rsn8887 is offline  
Old 17 December 2017, 10:08   #9
guest.r
Registered User
 
guest.r's Avatar
 
Join Date: May 2017
Location: EU
Posts: 342
Quote:
How do I select the integer prescale factor then?
It's selected by the shader internal scaling factor (see attached pic).
It's more like 2x, 4x, 6x, 8x in reality, but that doesn't present a bad issue.

The built-in linear last pass finishes the job quite well, and we still need a shader with POINT resizing (there isn't one suitable yet i think).
Attached Thumbnails
Click image for larger version

Name:	ScaleFactor.png
Views:	171
Size:	2.3 KB
ID:	55866  
guest.r is offline  
Old 17 December 2017, 15:59   #10
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 466
Quote:
Originally Posted by rsn8887 View Post
Can you do a quick check if adding 0.1 or 0.01 produces the correct result too?
Yes, this works. The lowest value to be added is 0.00007 for the test case above (didn't check 0.000069 etc.).
jbl007 is offline  
Old 17 December 2017, 16:39   #11
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
So it is just st some floating math rounding issue then. Ok I will fix the PR and the shader.
rsn8887 is offline  
Old 13 January 2018, 21:56   #12
Decypher
Registered User
 
Decypher's Avatar
 
Join Date: Mar 2013
Location: Turkey
Posts: 35
Trying to give this shader a try but unfortunately it's giving me "(Shaders) Failed to compile vertex shader" error. All other shaders work just fine, so I'm wondering if there is any other requirement I'm missing.
Decypher is offline  
Old 14 January 2018, 00:38   #13
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
My bad, I just fixed it. The comments were wrong in my latest change.

Just redownload from original post link, make sure to refresh cache. In your shader file the comments should look like this (new version):
// The small number compensates for possible floating point rounding errors
// when scaling by exact integer mutiples, e.g. 540/1080=1.99999994

Not like this (old version):
#The small number compensates for possible floating point rounding errors
#when scaling by exact integer mutiples, e.g. 540/1080=1.99999994
rsn8887 is offline  
Old 15 January 2018, 07:06   #14
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
Quote:
Originally Posted by guest.r View Post
It's selected by the shader internal scaling factor (see attached pic).
It's more like 2x, 4x, 6x, 8x in reality, but that doesn't present a bad issue.

The built-in linear last pass finishes the job quite well, and we still need a shader with POINT resizing (there isn't one suitable yet i think).
Thank you. However, I still don't understand your last sentence. Why do we need a shader with POINT resizing? And where would we select it?

Do you mean we need a shader with POINT resizing to select it on the left drop-down menu next to the "1x, 2x..." selector that you showed in your screenshot? Or shall we leave it at none/null to make the pre-scale work?

What I understand now is the following: There is some internal re-sizing from Amiga size to host size. We can select shaders with negative ID<0 that are applied before re-sizing. We can select exactly one shader with ID=0 that is applied during re-sizing. And we can select multiple shaders with ID>0 that are applied after re-sizing.

However, there are a bunch of other options everywhere on the panel such as the "1:1..." dropdown selection, the filtering dropdown on the bottom right, and some other dropdowns that I just don't understand.

EDIT: Maybe the behavior changes depending on DirectX version?

Last edited by rsn8887; 15 January 2018 at 07:14.
rsn8887 is offline  
Old 15 January 2018, 18:20   #15
guest.r
Registered User
 
guest.r's Avatar
 
Join Date: May 2017
Location: EU
Posts: 342
Quote:
Originally Posted by rsn8887 View Post
Thank you. However, I still don't understand your last sentence. Why do we need a shader with POINT resizing? And where would we select it?
Sharp-bilienar shader works with linear resizing, so thats different here.
This shader code must be adjusted to achieve it (copy/paste over existing code):

Code:
MinFilter = POINT;
MagFilter = POINT;
D3D11 framework of the new WinUAE auto translates to the new standard.

A shader is needed because filter options null and none operate at 1x scale which leave us two options: full linear resize or unwanted point resize.

Then we select the "shader" from the shader list. ID is ok at 0, because we need internal scaling. I don't fully understand the extra settings from 1:1 to 3:3 since i didn't notice any changes with a shader used. 1:1 is fine therefore.

Best you test it with a simple troughput shader since the only WinUAE alternative is to use hi-res/double lines for a sharper image (or integer scaling).
guest.r is offline  
Old 16 January 2018, 08:41   #16
rsn8887
Registered User
 
rsn8887's Avatar
 
Join Date: Oct 2006
Location: USA
Posts: 1,058
I see. What you say might work, it is certainly worth a try.
rsn8887 is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bilinear filter wraparound? mark_k support.WinUAE 17 23 October 2016 20:18
D3D point/bilinear setting trouble Ami_GFX support.WinUAE 4 10 December 2014 20:23
Shader support and scaling options in FS-UAE 1.3 FrodeSolheim support.FS-UAE 9 18 December 2013 17:30
!!!My Sharp X68000 Project Update!!! CU_AMiGA Retrogaming General Discussion 9 18 August 2013 05:12
Is possible to play sharp x68000 modules on Amiga? _ThEcRoW Amiga scene 7 27 February 2012 23:12

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 08:10.

Top

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