Fix multiple issues with resampling #879

Open
Filoppi wants to merge 1 commit from Filoppi/patch-3 into main
Filoppi commented 2023-06-26 17:53:24 -04:00 (Migrated from github.com)

1 ) It seems like there's a mistake in the Hermite bicubic filtering implementation. My change is based on the reference sources, and it also seems to make more sense, I don't see how squaring the inverse texture size would make sense. I don't think this change was on purpose, as the variable was called doubleSize, not squaredSize.

Sources:
https://www.shadertoy.com/view/MllSzX
https://www.shadertoy.com/view/XdGXWt

2 ) BicubicHermiteTexture was based on the output resolution instead of the rendering resolution.

3 ) The bilinear filtering was not offet by 0.5 and it would either have wrong results, or shift the output by a pixel.

1 ) It seems like there's a mistake in the Hermite bicubic filtering implementation. My change is based on the reference sources, and it also seems to make more sense, I don't see how squaring the inverse texture size would make sense. I don't think this change was on purpose, as the variable was called doubleSize, not squaredSize. Sources: https://www.shadertoy.com/view/MllSzX https://www.shadertoy.com/view/XdGXWt 2 ) `BicubicHermiteTexture` was based on the output resolution instead of the rendering resolution. 3 ) The bilinear filtering was not offet by 0.5 and it would either have wrong results, or shift the output by a pixel.
Exzap commented 2023-06-27 02:46:03 -04:00 (Migrated from github.com)

Any comparison screenshots?
On a side note, I think bicubic filter doesn't work on the Vulkan renderer at all because it never got proper support for arbitrary upscaling shaders. But I may misremember

Any comparison screenshots? On a side note, I think bicubic filter doesn't work on the Vulkan renderer at all because it never got proper support for arbitrary upscaling shaders. But I may misremember
Filoppi commented 2023-06-27 20:30:00 -04:00 (Migrated from github.com)

Any comparison screenshots?

Sorry, I don't, to be honest I haven't even tried this.
I just implemented all this stuff in Dolphin and spent quite a while making sure all custom resampling algorithms looked right, and that's how I noticed the ones from Cemu (which I used as an example) had some issues with them.

https://github.com/dolphin-emu/dolphin/pull/11999

I'm pretty sure about fix 1 and 3 though, you could run some screenshots yourself if you want.
I'll just leave it here, I don't really use Cemu, I just wanted to share my findings.
Thanks.

> Any comparison screenshots? Sorry, I don't, to be honest I haven't even tried this. I just implemented all this stuff in Dolphin and spent quite a while making sure all custom resampling algorithms looked right, and that's how I noticed the ones from Cemu (which I used as an example) had some issues with them. https://github.com/dolphin-emu/dolphin/pull/11999 I'm pretty sure about fix 1 and 3 though, you could run some screenshots yourself if you want. I'll just leave it here, I don't really use Cemu, I just wanted to share my findings. Thanks.
Exzap commented 2023-06-28 02:25:15 -04:00 (Migrated from github.com)

Ah ok, it's appreciated regardless. I will test it myself when I get a chance.

Ah ok, it's appreciated regardless. I will test it myself when I get a chance.
Filoppi commented 2023-06-28 12:26:04 -04:00 (Migrated from github.com)

I believe that working with the output/target resolution for the Hermite resampling makes it more downsampling friendly, because it picks 16 samples for each output pixel, but these 16 samples aren't aligned with the source image (the emulation output), thus you could be skipping source samples.
This was the first time I dealt with resampling so I'm still figuring things out.
Ideally, it would pick the number of samples to average based on the ratio between the source and target resolution?

I believe that working with the output/target resolution for the Hermite resampling makes it more downsampling friendly, because it picks 16 samples for each output pixel, but these 16 samples aren't aligned with the source image (the emulation output), thus you could be skipping source samples. This was the first time I dealt with resampling so I'm still figuring things out. Ideally, it would pick the number of samples to average based on the ratio between the source and target resolution?
Filoppi commented 2023-08-04 08:18:24 -04:00 (Migrated from github.com)

@Exzap my PR is now ready and tested:
https://github.com/dolphin-emu/dolphin/pull/11999
I won't continue work here but it's a good source of information if you are willing on improving resampling in cemu.

@Exzap my PR is now ready and tested: https://github.com/dolphin-emu/dolphin/pull/11999 I won't continue work here but it's a good source of information if you are willing on improving resampling in cemu.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Filoppi/patch-3:Filoppi/patch-3
git checkout Filoppi/patch-3

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff Filoppi/patch-3
git checkout Filoppi/patch-3
git rebase main
git checkout main
git merge --ff-only Filoppi/patch-3
git checkout Filoppi/patch-3
git rebase main
git checkout main
git merge --no-ff Filoppi/patch-3
git checkout main
git merge --squash Filoppi/patch-3
git checkout main
git merge --ff-only Filoppi/patch-3
git checkout main
git merge Filoppi/patch-3
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cemu-project_Mirror/Cemu-2024-03-05#879
No description provided.