bloc97 / Anime4K

A High-Quality Real Time Upscaler for Anime Video
https://bloc97.github.io/Anime4K/
MIT License
17.98k stars 1.34k forks source link

Best chain of shaders for highest quality and upscaling #216

Closed arianaa30 closed 6 months ago

arianaa30 commented 7 months ago

Wondering, what is the best chain of shaders to get the highest quality? What is the upscaler shader so far? Can we apply 4x here as well? I'm not concerned on the compution at this point. I'll play with it.

Currently, I'm applying this as instructions guide us:

glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_VL.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_VL.glsl;~~/shaders/Anime4K_AutoDownscalePre_x2.glsl;~~/shaders/Anime4K_AutoDownscalePre_x4.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl"

Tama47 commented 7 months ago

The best chain of shaders to get the highest quality would be to run through a VL or UL Restore Shader, then through a 2x or 4x Upscale Shader, and then run through a VL or UL Restore shader again. You could even try the UUL Restore Shader, but you might not be getting real-time performance anymore.

Here's an example: glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_UL.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_VL.glsl;~~/shaders/Anime4K_Restore_CNN_VL.glsl"

arianaa30 commented 7 months ago

Cool. What is thais autodownscale thing in the tutorial? Anime4K_AutoDownscalePre_x4.glsl

Is it even needed?

Tama47 commented 7 months ago

What is this autodownscale thing in the tutorial? Anime4K_AutoDownscalePre_x4.glsl

Downscale is done to make the shader faster. For example, if you upscale 1080p to 2160p and then run the restore shader again on the 2160p output, it will be very slow.

Like this: 1080p -> restore -> upscale x2 -> 2160p -> restore Vs. 1080p -> restore -> upscale x2 -> 2160p -> downscale x2 -> 1080p -> restore

Or if you use x4: 1080p -> restore -> upscale x4 -> 4320p -> downscale x4 -> 1080p -> restore

The restore shader first fixes the bad stuff in anime, and then it is upscaled. Then it is downscaled to make the next restore shader work faster. This will keep the quality of the first restore, and then you run the restore shader again to get the highest quality.

Is it even needed?

Not necessarily, but it can make your shader run faster.

arianaa30 commented 7 months ago

I see..thanks for the info. I'll try your example above. If too slow maybe I should add the autodownscale option there.

AziRizvi commented 7 months ago

Try your hand at my combos.

CTRL+6 osd-msg change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_UL.glsl;~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_UL.glsl;~~/shaders/Anime4K_Restore_CNN_VL.glsl;~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_UL.glsl"; show-text "Anime4K: (Restore UL) + Upscale Denoise (UL) + Restore (VL) + Upscale Denoise (UL)"

CTRL+7 osd-msg change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_UL.glsl;~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_UL.glsl;~~/shaders/Anime4K_Restore_CNN_VL.glsl;~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_UL.glsl;~~/shaders/Anime4K_Thin_HQ.glsl"; show-text "Anime4K: (Restore UL) + Upscale Denoise (UL) + Restore (VL) + Upscale Denoise (UL) + Thinlines"

CTRL+8 osd-msg change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_UL.glsl;~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_UL.glsl;~~/shaders/Anime4K_Restore_CNN_VL.glsl;~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_UL.glsl;~~/shaders/Anime4K_Darken_HQ.glsl"; show-text "Anime4K: (Restore UL) + Upscale Denoise (UL) + Restore (VL) + Upscale Denoise (UL) + Darklines"
arianaa30 commented 7 months ago

Cool. I will try these as well. Should I put place this in mpv.conf or input?

AziRizvi commented 7 months ago

Cool. I will try these as well. Should I put place this in mpv.conf or input?

In input.conf.

Input.conf is for the Keybinds that you want to use MPV with, MPV.conf is for settings that you want to launch MPV with. I had confusion too when I initially started out but it went away after a bit of research.

arianaa30 commented 7 months ago

Ok. So in your case, you do upscale twice, meaning it's actually a 4x upscale?

AziRizvi commented 7 months ago

Ok. So in your case, you do upscale twice, meaning it's actually a 4x upscale?

Yes, it's a 4x upscale, I think. 2x once and then 2x again, but I think it's also possible that it first upscales 2x and then gets downscaled and then gets upscaled again.

Now in the end, after all the upscaling is done, MPV downscales it back to the native resolution. I'm not too sure about what is happening but I use these shader combinations because visually they look the best to me.