Vapoursynth GLSL

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

GLSL runs a GLSL shader file of your choice on the video through libplacebo. The shader uses mpv's user-shader format, so many mpv shaders (sharpeners, line darkeners, debanders and others) can be used directly.

Filtering → Vapoursynth → Other

GLSL controls in Hybrid
GLSL controls in Hybrid

What it does

The selected shader is executed on the GPU at the hook point it declares (for example on luma or on the RGB image). What it does depends entirely on the shader. The output keeps the input size, so scaling shaders cannot be used to change the resolution here; their result is scaled back to the input size by libplacebo. For upscaling shaders use the GLSL Resizer.

Requirements

  • vs-placebo (libplacebo) and a GPU with Vulkan.
  • A shader file in mpv user-shader format.

Settings

Control Parameter Range / values Hybrid default Meaning
Shader / Select shader .glsl file empty Shader to run; empty = filter skipped.

Example

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

# adjusting color space from YUV420P10 to YUV444P16 for vsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
# GLSL filter: nlmeans.glsl
clip = core.placebo.Shader(clip, shader="F:/Hybrid/64bit/vsfilters/GLSL/nlmeans.glsl", width=640, height=356, matrix=1)

How Hybrid calls it

  • The clip is converted to 16-bit YUV 4:4:4, which vs-placebo needs; the output is 16-bit YUV 4:4:4 as well.
  • Width and height are always the current frame size, and the clip's matrix is passed along.

Background

vs-placebo Shader

vs-placebo's Shader function runs an mpv-syntax user shader, given as a file or as text, inside libplacebo's rendering pipeline. Width and height set the output size and have to be given for scaling shaders; planes the shader does not touch are resampled by libplacebo. For shaders that hook into linear or sigmoidized light, the image is linearized or sigmoidized first.

Sources