English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   support.FS-UAE (https://eab.abime.net/forumdisplay.php?f=122)
-   -   sharp-bilinear-simple shader for FS-UAE (https://eab.abime.net/showthread.php?t=89811)

rsn8887 14 December 2017 22:46

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.

jbl007 15 December 2017 15:53

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 15 December 2017 19:50

I think, I found a bug. :D
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

nobody 15 December 2017 20:22

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.

rsn8887 16 December 2017 18:35

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 16 December 2017 18:54

@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

guest.r 16 December 2017 19:21

1 Attachment(s)
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.

rsn8887 16 December 2017 22:28

Quote:

Originally Posted by guest.r (Post 1206399)
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.

guest.r 17 December 2017 10:08

1 Attachment(s)
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).

jbl007 17 December 2017 15:59

Quote:

Originally Posted by rsn8887 (Post 1206389)
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.).

rsn8887 17 December 2017 16:39

So it is just st some floating math rounding issue then. Ok I will fix the PR and the shader.

Decypher 13 January 2018 21:56

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.

rsn8887 14 January 2018 00:38

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 15 January 2018 07:06

Quote:

Originally Posted by guest.r (Post 1206480)
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?

guest.r 15 January 2018 18:20

Quote:

Originally Posted by rsn8887 (Post 1212010)
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).

rsn8887 16 January 2018 08:41

I see. What you say might work, it is certainly worth a try.


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

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

Page generated in 0.06109 seconds with 11 queries