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 |
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.
|
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 |
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.
|
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! |
@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 |
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 Code:
sampler sourceSampler = sampler_state |
Quote:
|
1 Attachment(s)
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). |
Quote:
|
So it is just st some floating math rounding issue then. Ok I will fix the PR and the shader.
|
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.
|
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 |
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? |
Quote:
This shader code must be adjusted to achieve it (copy/paste over existing code): Code:
MinFilter = 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). |
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.