-
Notifications
You must be signed in to change notification settings - Fork 214
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:
|
Progress update? |
Is there a way to get this to work? |
Hey, is this PR dead? |
Hello everyone, sorry for not going back to this sooner. I have managed to fix the remaining bugs on the bicubic filter. Bugs Fixed
Recap on what this PR proposesThis PR introduces a bicubic filter for downscaling, as shown in the pictures For the filter option, a novel argument was introduce
Also, you can configure the
You can toggle the bicubic filter with Super + K, if that doesn't work, try grabbing the screen first with Super + G Comparison with Iterative BicubicThe current implementation is based on this one, it is more efficient computationally than other approaches I have tested. Here are some image quality comparisons from the current efficient approach with a heavier one, this is a upscaling test from 960x540 to 1920x1080. OtherI'll take some time tomorrow to rebase the changes to the newest commit. You can compile the current version with:
UpdateRebase complete, compiling instructions updated. I created a dockerfile to simplify the build process. To compile you just need to have docker installed: # Create the gamescope folder
mkdir gamescope && cd gamescope
# Download the dockerfile
wget -O Dockerfile https://gist.githubusercontent.com/ruanformigoni/9521d5a2ff06be07d7000718751fae1d/raw/46c4ebe431999bd94c483b84c9ca4501051b7a82/Dockerfile
# Compile
docker build . -t gamescope
# Copy the compiled binary to outside the container
docker run -it --rm -v "$(pwd)":/workdir gamescope cp /gamescope/build/src/gamescope /workdir/gamescope
docker run -it --rm -v "$(pwd)":/workdir gamescope cp /gamescope/build/src/gamescopereaper /workdir/gamescopereaper |
Thank you so much. |
I have rebased the changes on another branch, unfortunately I am getting a black screen now, probably missed something that was introduced before the rebase. @misyltoad could you take a look at the changes and let me know what you think? Thanks! |
great to see this getting implemented, 4k linux gaming!! |
Thank you Ruan for continuing to work on this! |
b63a552
to
8fa17e4
Compare
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! |
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: