Skip to content
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

Fix multiple issues with resampling #879

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Filoppi
Copy link

@Filoppi Filoppi commented Jun 26, 2023

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
Copy link
Contributor

Exzap commented Jun 27, 2023

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
Copy link
Author

Filoppi commented Jun 28, 2023

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.

dolphin-emu/dolphin#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
Copy link
Contributor

Exzap commented Jun 28, 2023

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

@Filoppi
Copy link
Author

Filoppi commented Jun 28, 2023

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
Copy link
Author

Filoppi commented Aug 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants