Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > Hardware & Software > Software players

Thread Tools Search this Thread Display Modes
Old 28th July 2023, 23:05   #1  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
Video Adjustment shaders Pack 2023-11 Release (dx9, dx11 hlsl and mpv glsl.hook)

[A-Pack] Open-source. Video Adjustments shaders Pack
Available for dx9 hlsl, dx11 hlsl and mpv glsl.hook.

v1.50 by butterw (2023/11)

v1.40 initial release (2023/07)
- mpv version: https://github.com/butterw/bShaders/...0_mpv_glsl.zip

Lightweight shaders for quick Adjustments of (web) video: brightness/contrast curves (tooDark, tooBright, bShadows, levels) and color adjustments (vibrance, dSat, Black&White, etc.).

Shader Adjustments to quickly improve the video being viewed.

Why Shaders ?
- Shaders run directly on the integrated graphics (or discrete video card) and can be very fast for processing video pictures.
- Player integration. Shaders can be toggled on/off from within the video player.

Why are the adjustments necessary ?
- Input video may not have great capture/processing. This is particularly true for home and web videos.
- Display and display settings. Monitor may not be calibrated for color accuracy.
- Lighting conditions. They typically change during the day/night cycle and significantly alter the viewing experience.
- Viewer preference, individual taste.

Simple to use Adjustments
- These shaders are not meant for permanent use. The adjustments should be applied selectively when a video requires it (via menu or keyboard shortcut).
- A key benefit of shaders is that they can easily be turned ON or OFF. Once turned OFF, there are no hidden settings that could degrade your normal viewing experience.
- Shaders are applied directly to the video picture in the player.
- Lightweight gpu pixel shaders with a focus on performance.
- To install, simply copy the shader files to your players shader folder. To uninstall, delete the shader files from your players shader folder.
- Simple code allows for easy modification if required (ex: change parameter values, combine multiple shaders into one). Just edit the shader file with a text editor.
- Tested on intel integrated graphics (intel hd graphics, intel uhd 730) on Win10.

Use cases:
- The video is too dark
- The video is too bright
- The darks are not dark enough
- The video lacks contrast
- The contrast has been pushed too much
- The colors are weak
- The colors are over-saturated
- I want to watch this video in black&white, with a color filter, etc.

Last edited by butterw2; 21st November 2023 at 22:40. Reason: v1.50
butterw2 is offline   Reply With Quote
Old 30th July 2023, 14:45   #2  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
## Video Player and Renderer software

These shaders can be used in any software with user rgb pixel shader integration:
hlsl shaders are supported by Windows players such as mpc-hc, mpc-be, etc.
with the default renderer EVR-Custom Presenter and some other renderers.
- evr-cp (dx9, /Shaders)
- mpc-vr (dx11, /Shaders11, post-resize only)

and glsl .hook shaders are supported by the cross-platform player mpv (and video players built on top of it).
with the renderers vo=gpu or the new libplacebo-based vo=gpu-next.

evr-cp is the default renderer in mpc-hc and mpc-be (dx9).
- It supports pre- and post-resize user shaders. There is no difference between the two unless the video is resized.
- Adjustment shaders are typically used pre-resize, because there are less pixels to process when upscaling (ex: 720p video displayed fullscreen on a 1080p screen).
- Post-resize shaders are applied to the black bars.

mpc-vr (requires an additional download/install)
- Only supports post-resize user shaders. They are not applied to the black bars.

- You can use shader presets to be able to switch between shaders rapidly (via right Click Menu > Shaders).

- Mpc-be v1.6.8 or later is recommended for mpc-vr dx11 on Win10: the shader selector now defaults to the Shaders11 folder.
- Shader changes via the shader selector are applied when the video is playing. In paused mode, you need to disable/enable shaders for the new shaders to be applied (tested with mpc-vr).
- Mpc-be doesn't support shader presets.

- require the .hlsl extension for shaders. Other players may use a .txt extension instead.
- shader folders:
for dx9 shaders: /Shaders
for dx11 shaders: /Shaders11.
Other players may use folders with different names.

- vo=gpu-next is the new under-development libplacebo-based renderer for mpv.
- Shaders which require new features only available in vo_gpu_next are typically postfixed with _next.
- There is no required extension for mpv glsl shaders, I typically use .hk as it is shorter than .glsl.hook.
- There is no default shader folder, shaders could be placed directly in the player folder or a subfolder (ex: /s). You will need to specify a relative path to the shaders to use them so it may be best to keep it short/simple.
- mpv needs to be configured (via input.conf) to be able to toggle shaders on/off via hotkey. Shaders can be toggled individually.
- the provided switch-shaders.js script provides a switch to disable/restore current shaders.

To try out this shader pack, you can use a standalone video player with portable config (.zip download rather than .exe installer):
- Mpc-hc/be saves its configuration in Windows Registry by default, but an .ini file in the player folder can override this: For this you must put the player files in a folder where your windows user account has write access without admin elevation. So typically not in a protected Windows folders such as C:\Program Files.
- Mpv: on Windows, inside the player folder create a subfolder named portable_config where you should put your input.conf (and mpv.conf) configuration files. These files don't exist by default, so you may need to create them. A basic input.conf with keybindings to try out the shaders is provided.

How to check whether the shaders are working ?
- Try the bw (black&white) shader on a color video.
- For adjustment shaders it may not be so obvious, as only small tweaks are typically required. First pause the video, then try toggling shaders On/Off to see the difference.
- in mpv, the output screen is blue if there is a compilation error (likely be caused by a syntax error).
- in mpc-hc, you can use `Menu > Shaders > Debug Shaders... > then select the desired shader` too see if the shader compiled (in not a compilation error will be reported). Shaders which failed to compile aren't loaded.

mpc-hc shader presets.
To get the Shaders menu featured in the A-pack screenshot, copy the following [Shaders\Presets] text block to your mpc .ini configuration file:

Shader Cache dir
- Recent mpv builds (july 2023) enable caching of compiled shaders to disk by default to improve startup performance. The path to the directory (! write access required) can be set manually in mpv.conf with: gpu-shader-cache-dir=/shader-cache-dir
- mpc-hc with evr-cp. Options (O) > Playback > Output > EVR-CP settings: x Cache compiled shaders.
In portable mode a shadercache subfolder will be created containing the persistent .cso files. The corresponding .ini setting is CacheShaders=1.
- mpc-be and mpc-vr do not cache compiled shaders to disk.

Last edited by butterw2; 2nd August 2023 at 13:58. Reason: +mpv: switch-shaders.js
butterw2 is offline   Reply With Quote
Old 31st July 2023, 19:55   #3  |  Link
Registered User
Join Date: Feb 2019
Posts: 231
Thank you for writing and sharing these!
SirMaster is offline   Reply With Quote
Old 2nd August 2023, 15:14   #4  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
From my testing, these quick adjustements are particularly useful for web video (downloaded or streamed). What adjustment is required will depend on the content and the individual viewing setup.
Typically you will not need more than one shader and changing parameter values isn't required (changing the parameter value in the shader file is easy if desired).

For videos with a poor dynamic range, a small increase to the color contrast can help a lot (using ex: expand10_240). For brightness adjustments tooDark/TooBright are the way to go.
In any case, a shader based approach is very intuitive: Apply the chosen shader on the video being viewed, does it provide an improvement ? If not turn it off (using a hotkey is fastest). You'll learn what works for you pretty quickly.

All these shaders a very fast and should run on any PC.

Last edited by butterw2; 2nd August 2023 at 15:17.
butterw2 is offline   Reply With Quote
Old 24th August 2023, 02:55   #5  |  Link
Registered User
Join Date: Jan 2023
Posts: 2
Is there a chance to make some debanding shaders?
Nolami is offline   Reply With Quote
Old 24th August 2023, 18:57   #6  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
deband isn't something I need or use, it's also not lightweight, so probably not.

You could try the mpv built-in shader --deband, default values (1, 64, 16, 48). Stronger values would be: --deband-iterations=4 --deband-threshold=60 --deband-range=25 --deband-grain=48.
butterw2 is offline   Reply With Quote
Old 6th November 2023, 17:28   #7  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
added sCurve contrast adjustment shader (1 texture, 12 arithmetic): https://github.com/butterw/bShaders/tree/master/A-pack.
butterw2 is offline   Reply With Quote
Old 21st November 2023, 22:45   #8  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
v1.50 (2023-11) Adjustments shader pack for dx9 (mpc-hc/be, etc), dx11 mpc-vr and mpv glsl.hook.
- adds two contrast adjustment shaders (based on s-curve/inverse s-curve): sCurve and deContrast
- some minor cleanup.
butterw2 is offline   Reply With Quote
Old 11th December 2023, 21:22   #9  |  Link
Registered User
Join Date: Jun 2020
Posts: 303
The upcoming A-pack v1.55 release (2023-12) will include mpv shader/OSD scripts & portable config (tested on Windows).

- restart-mpv (recompiles shaders, reloads scripts and config files).
- shaders-On indicator (), ex: displayed in window title when shaders are On.
- show-shaders (displays current shaders list).
- clear shaders, clears shaders list.
- switch-shaders, toggles shaders On-Off.
- store-shaders (stores shaders config when first run, shaders are restored when run again).
butterw2 is offline   Reply With Quote

glsl, hlsl, mpc-hc, mpv, shaders

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 22:35.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.