-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented bicubic downscaling #740
base: master
Are you sure you want to change the base?
Implemented bicubic downscaling #740
Conversation
you should probably look into Catmull-Rom (Bicubic with b=0 and c=0.5, rather than than b=0.33 and c=0.33) for downscaling rather than using normal bicubic. it's sharper and preserves edges the same as the default. |
I can confirm that resolutions that aren't double the monitor resolution look weird. |
90163e2
to
1acf8bb
Compare
Hey @EndlesslyFlowering , I've included the Catmull-Rom algorithm, thanks for bringing it to my attention. Thanks for the heads up @rKsanu2MMYvypWePtQWM, I've fixed this in the latest commits. Here's the ranges of are shown below, the numbers represent the resolution multiplier from the monitor resolution and the render resolution, e.g., render at 2160p and display in 1080p == 2160/1080 == 2.
You can toggle the downscaling effect with |
Definitely making really great progress. I think to cap it all off you should add the ability for user to adjust the bicubic parameters of B and C. Catmull-rom has ringing, which increases perceived sharpness but I want to be able to adjust it. Examples of different bicubic setups with the 2 parameters: B-Spline(blur only): B1 C0 Hermite(blocking only): B0 C0 Mitchell(balanced minor amounts of blocking, aliasing, and ringing): B0.33 C0.33 Catmull-Rom(balance of ringing and blocking): B0 C0.5 Explanation of different scalers: Image showing the effects of different bicubic parameters on scaled quality: Also, if it's not too far out of scope, these scalers(especially the ringy ones like catmull-rom or lanzcos) work better when you convert gamma to sigmoid light before scaling, and back to the native gamma afterwards. Pic showing that with upscaling: This applies also to the downscaling(your PR can be used as both an upscaler or downscaler, if it still works like the first iteration) |
@Displaysguy thanks a ton for the explanation and resources! I'll study how to implement this properly and look into the possible method for argument passing you mentioned here. |
Another tidbit, this one is specifically on sigmoidization: "You may decrease halos and increase perceptual sharpness by increasing the sigmoidal contrast (up to 11.5, say). Higher contrasts are especially recommended with greyscale images (even “false RGB greyscale” that have three proportional color channels). The downside of sigmoidization is that it sometimes produces “color bleed” artefacts that look a bit like cheap flexographic (”gummidruck”) printing or chromatic aberration. In addition, sigmoidization’s “fattening” of extreme light and dark values may not work for your image content. If such artefacts are obvious, push the contrast value down from 7.5 (to 5, for example, or even lower). Setting the contrast to 0 is equivalent to enlarging through linear RGB. (Robidoux, 2012)" From this(and the MPV scaling article) we know that sigmoidization can lower both light and dark overshoot(overshoot=ringing) with ringy scalers on both upscaling and downscaling. It's always superior to linearization because linearization only accounts for light overshoot and not dark overshoot. However, it is not without downside. It has negative effects on the image and in certain situations(even where using it makes sense, which is only when using ringy scaling configurations) might not even be a net benefit. Because of this I wouldn't make adding sigmoidization a priority, and if you do add it make sure it is user-adustable and can be disabled(and is not enabled by default). https://guide.encode.moe/encoding/resampling.html (ctrl-f sigmoid to find the quote) |
I've had a chance to test this out a bit. Here's some test screenshots. |
Hi @specfreq , could you also include a screenshot with the downsampling algorithm disabled? |
@ruanformigoni Here's some new test screenshots. Launch options: Let me know if I don't have it set up correctly. |
Thanks for the followup @specfreq. I did the same as you (change the desktop resolution and downscale) and got way better results, here is a comparison. Did you set the in-game render resolution to 4096x3072 in the resolution settings? |
Are you able to toggle it with |
I am not able to toggle it with |
That should be fine, make sure that lines 176-179 of the file src/sdlwindow.cpp are these: case KEY_K:
g_wantedUpscaleFilter = (g_wantedUpscaleFilter == GamescopeUpscaleFilter::BICUBIC) ?
GamescopeUpscaleFilter::LINEAR : GamescopeUpscaleFilter::BICUBIC;
break; In your launch command Edit: You can also try with other keys, maybe change |
I just rebuilt it and it is working now. |
Here's a test video: And high quality: I'd love to be able to use this with the integer scaling. |
a617cd8
to
44e844b
Compare
src/shaders/cs_bicubic.comp
Outdated
( -18 + 12 * B + 6 *C ) * ( f * f ) + | ||
( 6 - 2 * B ) ) / 6.0; | ||
} | ||
else if( f >= 1.0 && f < 2.0 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure about it but, this branch seems unreachable?
You pass in f (x) as a fract of a pixel coordinates, thus it will never be beyond 0-1?
The original implementation, which I reimplemented here
https://github.com/dolphin-emu/dolphin/pull/11999/files#diff-368d3b7ce4f1890976b9f3b3d7f59df06cc906721d2dd882552a8503b3a40d7bR240
actually passed in fract*m (or n) here, effectively using all branches as it spanned from -1 to 2.
Thought to be honest I haven't 100% understood what the algorithm does so maybe my implementation is all wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this, I've updated the code and now it calculates the weights as described here.
any news? would love to see this finally merged... |
I highly suggest to take a look at this more advanced downsampling method: |
I don't understand why you are still running the whole RCAS pass, surely we don't want sharpening after doing downscaling? What's the rationale behind doing FSR for bilinear at certain ranges? Does it look better? I have my doubts there. I think it also makes sense to have a g_wantedDownscaleFilter and g_downscaleFilter. Shouldn't affect upscaling at all. I would be happy to default downscaling method. Then do like:
|
Ok, I managed to fix the black screen issue @misyltoad, and also rebased the project to have no conflicts with master. I have modified how the arguments work to fit more what gamescope is doing right now with the |
@ruanformigoni nice work on this! something I've found while testing:
I will try to test some with the DRM backend sometime later today. |
Hi @matte-schwartz , thanks! I do not think this is related to the filter, since I also have this issue with the current implementation of FSR: |
Interesting, was not seeing the same on my rig with FSR although I was not testing in-game quite yet... just with vkcube. Could have just been a desktop compositor issue or something on my end I suppose. In general it's not a huge deal when that error appears but figured I'd make a note of it anyway. |
I've found a strange bug. Enabling the bicubic filter destroys the gamma in some games, lowering contrast and making the colors washed out. It seems to affect all the Unreal Engine games I've tried. EDIT: It appears that this is related to 10-bit formats. Disabling Gamescope's WSI layer restores the gamma, but then you don't have 10-bit color of course. |
(The image link is dead but it's still available in the wayback machine, or e.g. at https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Mitchell-Netravali_artifacts.svg/1280px-Mitchell-Netravali_artifacts.svg.png ) Note that this graph (and the survey it's based on) is for upscaling. When downscaling, the parameters can have very different effects (depending on how the kernel is scaled with the downscaling ratio). |
I realise I'm replying to a very old message, but I just wanted to point out that the information previously contained in the linked page has been somewhat moved to this other page. The content itself is different, but it covers the same topics. |
lets get this merged asap pls, linux gamers deserve hq super sampling :< |
The help output needs to be updated, there isn't a Wayland keybind for this and Nvidia seems to have issues with this for whatever reason as @gnusenpai said. |
I build the project and installed the binaries to test it on my 7900XTX, sadly it does not seem to run. The version I had before from my package manager (pacman) does seem to work (gamescope-3.15.14-1-x86_64). Not sure what additional details you might need but I still have X11 instead of Wayland. When I run it on my terminal without any extra parameters: |
@Sp3ci3s8472 that's unrelated, you need #1548 |
Thanks that indeed solved it! |
How do I apply that PR's changes when building this one with docker? |
I found a scuffed way to do this, copy this PR's |
Please merge this. |
Very excited about this and hoping it gets merged soon |
Me too...
…On 17 December 2024 01:13:01 EET, Reonu ***@***.***> wrote:
Very excited about this and hoping it gets merged soon
--
Reply to this email directly or view it on GitHub:
#740 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
This is actually what im waiting for also, Bicubic does a much better job of preserving shapes in the image even if the image is softer vs FSR/NIS which both tend to round corners or have some nasty ringing |
This PR implements a bicubic filter to remedy issue #692.
Update 10-mar-2023
Nier Automata (2160p)
Current gamescope result:

Proposal:

Need for Speed ProStreet (2160p)
Current gamescope result:

Proposal:

GTA IV (4320p)
Current gamescope result:

Proposal:

Dark Souls II (4320p)
Current gamescope result:

Proposal:
