14 December 2017, 22:46 | #1 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
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 Last edited by rsn8887; 15 December 2017 at 00:09. |
15 December 2017, 15:53 | #2 |
Registered User
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 467
|
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.
|
15 December 2017, 19:50 | #3 |
Registered User
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 467
|
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. |
15 December 2017, 20:22 | #4 |
Registered User
Join Date: Dec 2013
Location: GR
Age: 47
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.
|
16 December 2017, 18:35 | #5 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
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! |
16 December 2017, 18:54 | #6 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
@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. |
16 December 2017, 19:21 | #7 |
Registered User
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; }; Code:
sampler sourceSampler = sampler_state { Texture = (source_tex); MinFilter = POINT; MagFilter = POINT; }; |
16 December 2017, 22:28 | #8 | |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
Quote:
|
|
17 December 2017, 10:08 | #9 | |
Registered User
Join Date: May 2017
Location: EU
Posts: 342
|
Quote:
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). |
|
17 December 2017, 15:59 | #10 |
Registered User
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 467
|
|
17 December 2017, 16:39 | #11 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
So it is just st some floating math rounding issue then. Ok I will fix the PR and the shader.
|
13 January 2018, 21:56 | #12 |
Registered User
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.
|
14 January 2018, 00:38 | #13 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
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 |
15 January 2018, 07:06 | #14 | |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
Quote:
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. |
|
15 January 2018, 18:20 | #15 | |
Registered User
Join Date: May 2017
Location: EU
Posts: 342
|
Quote:
This shader code must be adjusted to achieve it (copy/paste over existing code): Code:
MinFilter = POINT; MagFilter = POINT; 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). |
|
16 January 2018, 08:41 | #16 |
Registered User
Join Date: Oct 2006
Location: USA
Posts: 1,063
|
I see. What you say might work, it is certainly worth a try.
|
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 |
|
|