@vestra-player/sdk - v1.11.3
    Preparing search index...

    Interface VideoShaders

    This plugin's own GPU shaders, from plugin.video.shaders(id) : mpv user shaders (.glsl, //!HOOK …) that the GPU renderer runs on every frame.

    Any number of plugins hold shader handles at the same time (unlike RenderOptions, which has one owner). The player joins every handle's list in a stable order, after the render options' own shaders: built-in plugins first, then installed plugins in the order they were first installed, then development loads (--plugin); ties by plugin id, and a plugin's handles by id. At most 16 shaders across all handles (limit beyond, nothing changes); the render options keep their own 16.

    Files must be this plugin's own: absolute paths inside its package directory or Plugin.dataDirectory after following links, each at most 16 MiB. Elsewhere: invalid; a file that does not exist: missing. The player reads the files when the list is set.

    GPU rendering only (macOS; Windows with the Picture panel's GPU Rendering turned on): under software rendering a non-empty list is failed with unsupported, and a switch to software during the run pushes unsupported to every handle with shaders and removes every list (they no longer count against the 16); set them again once the player draws on the GPU (after a restart). Shaders act when a frame is drawn, so processed snapshots and exports never contain them (use a VideoNode for that). When mpv cannot compile a shader the handle turns failed with failed (pushed later); mpv does not say which file failed, so while several plugins' shaders are on, each of them hears it and the message says the player cannot tell whose.

    set sends the whole list (last write wins); clear and dispose withdraw it; the player removes a stopped plugin's shaders itself.

    After an abnormal end: when the previous run of the player ended while plugin shaders were drawing (a crash, the process being ended, a lost GPU device), the player refuses every non-empty list of every plugin with previous-crash, its message naming the plugins whose shaders were on: one such end keeps them off for the next start only; two within a day keep them off until the GPU, its driver or the player changes, or for 7 days. Clearing ([], clear, dispose) still works. The player shows one OSD line about it itself; the handle is failed with previous-crash and the SDK does not retry it. Do not set the list again in a loop while it is refused, and do not show an OSD line of your own for it; a later start of the player applies lists again once the guard lets it.

    The video looks sharper on the GPU renderer; under software rendering the OSD says why it is not. The shader file lives in the plugin's package, and the player puts it after other plugins' shaders that come earlier in its order.

    const shaders = plugin.video.shaders("sharpen");
    shaders.onStatus((s) => {
    // `unsupported`: software rendering; `failed`: mpv could not compile it.
    if (s.state === "failed") void plugin.osd.show("Sharpen: {}", [s.error.message]);
    });
    shaders.set([join(packageDirectory, "shaders", "sharpen.glsl")]);

    0.5.20

    1.5.39

    interface VideoShaders {
        dispose(): Promise<void>;
        set(paths: readonly string[]): void;
        clear(): void;
        status: FilterStatus;
        onStatus(listener: (status: FilterStatus) => void): Disposable;
    }

    Hierarchy (View Summary)

    Index
    • Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.

      Returns Promise<void>

      Never.

      A "Turn feature off" item removes the feature's own menu item at once, before the plugin stops. dispose takes the command out of the menu and the binding table and resolves once the player confirmed it; the id can be added again later.

      const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
      plugin.commands.add({
      id: "extra-off",
      path: ["Tools", "Turn extra off"],
      run: () => extra.dispose(), // never rejects
      });

      1.0.0

    • Replace this handle's shader list (last write wins); [] withdraws it.

      Parameters

      • paths: readonly string[]

        Absolute paths of shader files in this plugin's package or data directory, in the order they run.

      Returns void

      Never throws: a refused list shows in status (invalid, missing, limit, unsupported, and previous-crash: see the interface's remarks) and goes to Scope.onError, and what the player held stays.

      The plugin offers a light and a strong preset; picking one replaces the handle's list in one request. The files were written to the plugin's data directory when the user imported them.

      const presets: Record<string, string[]> = {
      light: [join(plugin.dataDirectory, "denoise.glsl")],
      strong: [join(plugin.dataDirectory, "denoise.glsl"), join(plugin.dataDirectory, "sharpen.glsl")],
      };
      plugin.video.shaders("presets").set(presets.strong!);

      1.5.39

    • Withdraw this handle's shaders (the same as set([])).

      Returns void

      A Video menu item turns the plugin's shader on and off. Clearing keeps the handle, so the next pick sets the list again.

      const shaders = plugin.video.shaders();
      let on = false;
      plugin.commands.add({
      id: "toggle-shader",
      path: ["@video", "Sharpen (Shader)"],
      checked: () => on,
      run: () => {
      on = !on;
      // Clearing keeps the handle; the next pick sets the list again.
      if (on) shaders.set([file]);
      else shaders.clear();
      },
      });

      1.5.39

    • The status changed, including later pushes (a compile failure, a switch to software rendering).

      Parameters

      Returns Disposable

      The OSD shows mpv's message when the plugin's shader fails to compile. The player pushes that failure after the list was accepted, so it arrives through onStatus, not as a refused set.

      const shaders = plugin.video.shaders();
      shaders.onStatus((status) => {
      if (status.state === "failed") void plugin.osd.show("Shader: {}", [status.error.message]);
      });

      1.5.39

    status: FilterStatus

    Current status: waiting before ready media, applying, applied, or failed with the reason (see the remarks).