Vapoursynth GLSL Resizer

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

GLSL Resizer runs an mpv-style GLSL scaling shader of your choice (for example FSRCNNX, Anime4K upscale or RAVU) on the GPU through libplacebo and outputs the target size. Hybrid does not ship such a shader; you select a .glsl file yourself.

Filtering → Vapoursynth → Frame → Resize

GLSL Resizer controls in Hybrid
GLSL Resizer controls in Hybrid

What it does

libplacebo renders the clip with the shader hooked into its scaling chain. Planes the shader does not scale are brought to the target size by libplacebo's own scaler. Many shaders have tunable values, written as #define lines in the shader; Hybrid can replace them without editing the file.

Requirements

  • vs-placebo (libplacebo) and a GPU with Vulkan support (macOS via MoltenVK).
  • A scaling shader in mpv syntax.

Settings

Tick Resizer in the Resizer page and pick GLSL Resizer as method.

Control Parameter Range / values Hybrid default Meaning
Shader shader path to a .glsl file empty Shader that does the scaling; chosen with the Select button.
Parameters – read-only empty The shader's default values, read from a .params file with the same name next to the shader (lines like #define NAME value).
Overwrite – on/off off Use the custom values below; only available when Parameters is filled.
Custom parameters shader_s #define lines – Replacement values; Reset copies the defaults back.

Example

Shader F:/Hybrid/64bit/vsfilters/GLSL/ACNet.glsl selected (no shader is set by default), on a 10-bit YUV 4:2:0 source (640x356), resized to 1280x712:

# adjusting color space from YUV420P10 to YUV444P16 for vsGLSLResizer
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
# resizing using GLSL resizer
clip = core.placebo.Shader(clip, shader="F:/Hybrid/64bit/vsfilters/GLSL/ACNet.glsl", width=1280, height=712, matrix=1) # 1280x712

How Hybrid calls it

  • The clip is converted to 16-bit YUV 4:4:4 and passed to libplacebo's shader function with the target width and height from the Crop/Resize tab and the source matrix; everything else uses libplacebo's defaults. Separately filtered fields get half the target height.
  • With Overwrite ticked and both fields filled, the script reads the shader file, replaces each changed #define line with the custom one and passes the shader as text instead of the path.
  • With an empty shader path Hybrid writes a note into the script and resizes with Spline64 instead.

Background

vs-placebo

vs-placebo's shader function runs mpv-syntax GLSL shaders. It takes 16-bit YUV and always returns 16-bit YUV 4:4:4; width and height are required for scaling shaders. Unscaled planes use the ewa_lanczos filter by default, with linearization and sigmoidization on. A shader only runs if the texture it hooks is actually rendered, so shaders that hook linear light need linearization.

Sources