Skip to content

v0.3.1

Choose a tag to compare

@baronsmv baronsmv released this 03 May 23:52
· 380 commits to main since this release

Changelog

Introducing new pre/post-processing options, adaptive Lanczos scaling and improved CLI help

Pre/Post-processing pipeline

Many optional screen effects now can run before and after Lanczos scaling, controllable via command line, config file, and per-profile overrides. Each effect can be enabled independently and tuned with parameters.

  • Debanding: Smooths harsh colour steps (banding) in smooth gradients, such as skies, fog, or dark menus.
  • Contrast Adaptive Sharpening (CAS): Sharpening after scaling. Enhances text and line art without the halos typical of unsharp masks.
  • Bloom: Soft glow around bright regions. Creates a dreamy look by screening a wide blurred version of the image back onto itself.
  • Radial Vignette: Darkens screen edges, drawing attention to the centre.
  • Film Grain: Slightly jittered noise blended via soft-light, mimicking real film emulsion.
  • 3D LUT Colour Grading: Colour-lookup table at the end of the pipeline. Built-in presets include identity (passthrough), warm, cool, film, vivid, pastel, noir, sepia, bleach, split, cyano, and lofi.

See --help-all for more information on these effects.

Adaptive Lanczos resampler

The upscaling pass now automatically adjusts its filter radius based on the target resolution. This improves the quality of downscaling (e.g., 720p upscaled to 1440p, and then back to 1080p) by preventing aliasing. Two dedicated shaders are used:

  • Upscaling (radius 2) uses lanczos_fixed.spv, identical to the previous Lanczos-2, using a fast hardware-Gather path.
  • Downscaling or non-uniform scaling automatically switches to lanczos_adaptive.spv, a variable-radius kernel that provides anti-aliasing.

Both variants support linear-light processing, anti-ringing clamp, and a tight mode that preserves thin text and line art. These parameters are exposed as new options as well.

Improved CLI help

--help now shows only essential and common options, while --help-all reveals every advanced option (post-processing, tile tuning, Vulkan performance, etc.). This keeps the initial output friendly, while hinting at all possible options in another help menu.

Internal Improvements

  • Most of the pipeline is now model-agnostic, without hardcoded values or model-specific implementation. FSRCNNX (or even ArtCNN) models may be evaluated in the future, so this would ease their integration. Interesting discussion here.
  • TileParams push data is now aligned to prevent out-of-bounds or misaligned variables in the shader values.
  • Shared ShaderPass base class used by all compute effects, reducing code duplication.
  • LanczosScaler automatically selects the correct SPIR-V binary based on computed filter radii.
  • HLSL source files are no longer included in distributions (only compiled .spv), reducing the size of the PyPi package.
  • Batch scripts for compiling HLSL to SPIR-V added to scripts/.

A note on Anime4k

TL;DR: Anime4k was partially integrated but ultimately abandoned and no longer planned.

Anime4k (both CNN and GAN variants) was partially integrated but ultimately abandoned after further testing.

After converting and compiling the Anime4k shaders to pass-per-file SPIR-V files, the shaders appeared to run correctly, but closer inspection revealed that the output was effectively a nearest-neighbour enlargement, each pixel being a 2x2 block of the original color. That could mean the residual computation did not correctly combine with the base image, or another hard-to-diagnose integration problem. The feature maps were generated correctly, but the final composition step did not combine them with the original image at the upscaled resolution.

This points to an Anime4k-specific issue that's not present in CuNNy models, and it probably comes to how the original Anime4k GLSL shaders work. This is unfortunately not easily fixable without further debugging and integration to further match the multi-pass architecture used here.

My conclusion, after extensive testing and debugging the Anime4k shaders, is that it's not worth the trouble as CuNNy surpasses them in visual quality, compatibility, fidelity and design, at least for the goal of this upscaler.

Coupled with the fact that Anime4k is already well-served in Linux by MPV and targets a domain (anime) that is already covered by that player, the implementation was archived under the archive/anime4k-experiment tag for reference, but is no longer planned.