Vapoursynth Deblur (GLSL-A4K)

From wiki.selur.net
Jump to navigation Jump to search

Deblur (GLSL-A4K) sharpens soft line art on the GPU with the Anime4K Deblur Original shader.

Filtering → Vapoursynth → Line

Deblur (GLSL-A4K) controls in Hybrid
Deblur (GLSL-A4K) controls in Hybrid

What it does

The shader measures the edge strength of the luma with Sobel kernels and maps it through a fitted curve to a refinement amount. Where that amount is high, the edges are steepened. It works best on blurry anime and cartoon lines.

Requirements

  • vs-placebo (libplacebo) and a GPU with Vulkan support.
  • The GLSL shader folder in Hybrid's VapourSynth plugins; without it the filter is locked.

Settings

Control Parameter Range / values Hybrid default Meaning
Strength REFINE_STRENGTH 0.01 – 100 1.0 Strength of the edge refinement; good values are about 0.2 – 4.
Bias REFINE_BIAS 0 – 100 0 Offset added to the refinement amount; good values are about 0 – 1.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# adjusting color space from YUV420P10 to YUV444P16 for vsGLSLDeblur
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/Anime4K_Deblur_Original.glsl") as glslf:
  glsl = glslf.read()
glsl = glsl.replace('#define REFINE_STRENGTH 1.0', '#define REFINE_STRENGTH 1')
glsl = glsl.replace('#define REFINE_BIAS 0.0', '#define REFINE_BIAS 0')
clip = core.placebo.Shader(clip, shader_s=glsl, width=clip.width, height=clip.height, matrix=1)

How Hybrid calls it

  • The clip is converted to YUV 4:4:4 16 bit, the only format the shader filter accepts; the output stays in that format and size.
  • Hybrid writes Strength and Bias into the shader text and runs it with the input width and height and the clip's color matrix.
  • Both values are always written. They work on normalized values and are not scaled to the bit depth.
  • Deblur (GLSL-A4K) also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The shader

Hybrid uses the Anime4K v3.2 Deblur-Original shader by bloc97 (MIT license). It computes the Sobel kernels at twice the size and resamples the result back to the input size. The refinement amount (curve × Strength + Bias) is clamped to 0 – 1, so a Bias of 1 or more already means full refinement everywhere. Related shaders: Darken (GLSL-A4K) and Thin (GLSL-A4K).

Sources