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

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th June 2020, 14:34   #1  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
Video player Shaders guide (MPC-HC, mpv)

Video player (unofficial guide) posts index:
# Comparison of shader features in video players
# Mpv shader basics
# Shader support in mpc video renderer (mpc-vr)
# mpv hotkeys
# Shaders Folder, Paths & extensions
# mpv Auto-Profiles
# New Shader features in Mpc-hc (v1.9.8.65)
# Custom hotkeys, Seeking, Chapters, Playlist
# Screenshots
# Comparison of video player features (Win10) https://forum.doom9.org/showthread.p...40#post1932940
# Mpc-hc Command Line Switches https://forum.doom9.org/showthread.p...15#post1927315
# Video Player installation https://forum.doom9.org/showthread.p...73#post1934473
# Color mapping with Shaders https://forum.doom9.org/showthread.p...82#post1935482
# mpv built-in scalers
# How to change settings/properties while playing with mpv


# Cartoon Shaders https://forum.doom9.org/showthread.p...55#post1928755
---


Mpc-hc + Shaders install (with default dx9 EVR-CP renderer) unofficial guide
32 vs 64 bit program version doesn't matter for shaders.

Mpc-hc installs the default shaders in the player directory Shaders subfolder. They are not required to run mpc-hc (they can be modified/deleted as required). It is also possible to download shader files available on the internet or write your own. Files with .hlsl extension in Shaders subfolder are listed in `Option->Shaders` submenu.

Install directory does matter.
To be able to modify shader parameters you need to have write access to the directory where the shader.hlsl file is located (by default the Shaders subfolder).
Also to have the option to use mpc-hc.ini, mpc-hc must have write access to the Install directory (if not the option is greyed out). This will not be the case for a standard user on Win10 by default with a `c:\Program Files\MPC-HC` install. To get around this, you need to either re-install to a user directory or change folder permissions. For testing, the simplest solution is to copy a portable version + mpc.ini in its own directory (no-install required).


How to get corresponding Shaders Menu when you install Shaders files ?
To be able to apply Effects quickly, they need to be saved as Shader Presets. You can then change Effects through the Shaders right-click Menu
Shader presets can be created/saved by using the `Select Shaders...` menu option, but by editing mpc-hc.ini we can get a ready to use Shaders Menu directly.



Mpc-hc Shader Menu mod guide:
Mpc-hc settings are stored either in the registry or in an .ini file, based on setting `Mpc-hc->Options->Player->Store settings in .ini file.`. This option will be greyed out, if mpc-hc doesn't have write access to the install folder.

Editing mpc-hc.ini (Close Mpc-hc before you start. It is advisable to make a backup copy before making any changes)

With a text editor, search for the Shaders\Presets section. Here is an example of what you might have:
[Shaders\Presets]
0= Disable
1=Sepia
2=Luma+Grain
3=Pixelate
PostResize0=
PostResize1=
PostResize2=.\LumaSharpen.hlsl;.\PS_Noise.hlsl
PostResize3=
PreResize0=
PreResize1=.\Sepia.hlsl
PreResize2=
PreResize3=.\bPixelate.hlsl

You can directly edit preset names, Pre and PostResize shader chain filepaths. Be careful that all numbers must remain available: deleting 1=Sepia would cause issue here !
Shaders Menu display order: Preset names are sorted alphabetically. To control the display order, preset names could be numbered (00, 01, etc.).
For more advanced users, Shader Presets can be used to setup Multi-Pass shaders.


Modifying shader files
.hlsl files contain the Shader function and parameter values. In most cases, the effect has parameter values that can be modified. This can be done with any text editor (I use Notepad++, a multitabbed editor which offers c-syntaxic coloring). After saving the changes, they are applied instantly to the video playing.
In the case of LumaSharpen.hlsl which was developed for SweetFX game shaders pack, the default parameter values are not those recommended in this forum for video content playback.
If you want to switch between different parameter values for the same shader without editing, you can create a new shader with the desired parameter values, ex: LumaSharpen_3-1.20-0.015.hlsl. With this approach the Shaders subfolder (and the shader list) can quickly become overcrowded, so it is important to know which shaders you want to use, together with the associated parameter values.

Last edited by butterw2; 4th March 2021 at 12:04. Reason: +Index
butterw2 is offline   Reply With Quote
Old 30th June 2020, 04:27   #2  |  Link
v0lt
Registered User
 
Join Date: Dec 2008
Posts: 1,514
I think there isn’t enough shader compilation checking.

For DirectX 9
Code:
fxc.exe /T ps_3_0 /Fc "Shader9.txt" "Shader9.hlsl"
For DirectX 11
Code:
fxc.exe /T ps_4_0 /Fc "Shader11.txt" "Shader11.hlsl"
v0lt is offline   Reply With Quote
Old 30th June 2020, 08:31   #3  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
I haven't tried the external dx11 renderer so far, but I understand it requires dx11 shaders, which have a slightly different syntax than dx9 shaders.

Doesn't the compiler have a backwards compatibility mode (fxc /Gec ?) to enable use of dx9 shader files in dx11 ?

All the currently available third party .hlsl shaders available online were written for dx9.
butterw2 is offline   Reply With Quote
Old 7th July 2020, 03:05   #4  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
Optimized 2-pass Gaussian Blur (9-tap) shader:
bShaders\blurGauss.hlsl >> blurGauss_Y.hlsl
the kernel is hardcoded so you can't adjust parameters. Run it multiple times to achieve a stronger effect (ex: 5x).

below are Blur Gaussian and Blur Gaussian (5x) shader presets for mpc-hc.

mpc-hc.ini:
[Shaders\Presets]
0= Disable
1=Blur Gaussian
2=Blur Gaussian (5x)
PostResize0=
PostResize1=
PostResize2=
PreResize0=
PreResize1=.\blurGauss.hlsl;.\blurGauss_Y.hlsl
PreResize2=.\blurGauss.hlsl;.\blurGauss_Y.hlsl;.\blurGauss.hlsl;.\blurGauss_Y.hlsl;.\blurGauss.hlsl;.\blurGauss_Y.hlsl;.\blurGauss.hlsl;.\blurGauss_Y.hlsl;.\blurGauss.hlsl;.\blurGauss_Y.hlsl

For a near gaussian blur with an adjustable parameter, use boxBlur (3x) based on 2pass blurMean.
A multipass Kawase blur, also can approximate a gaussian depending on parameters.
For best performance with Heavy bluring, Dual-Kawase downsizes the video, blurs, and resizes-up.

Last edited by butterw2; 7th July 2020 at 22:18. Reason: added bShaders link + Kawase blur info
butterw2 is offline   Reply With Quote
Old 15th July 2020, 15:43   #5  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
# Pan&Scan Presets (built-in Zoom-Crop vs shaders)

Mpc-hc and mpc-be have a "View>Pan&Scan" zoom-crop built-in feature. This transformation happens before user shaders.

Editing PnS Presets: specify center (x,y) and zoom (x, y).
- center (0.5, 0.5): middle of the screen
- zoomX and zoomY should be equal to keep the source Aspect Ratio. 1: no magnification.

The most useful preset is probably "Zoom to widescreen" which will crop horizontal and vertical borders on the corresponding 4/3 source material when displayed on a 16/9 screen.

- `Numpad 5` hotkey: resets PnS zoom (also displays source AR). PnS zoom is also reset when you close the player.
- You can manually adjust zoom using Numpad 9(+) and 1(-) hotkeys.


Observations:
- Center of Screen PnS fixed zoom works well, whatever the source Aspect Ratio.
- I initially tried to display only part of the source image with Pan&Scan (ex: fill the screen with first quarter of frame), but found pre-resize shaders more capable for this use case.
The issue with PnS (beside the confusing x, y values) is black bars on resize, when the source doesn't have screen 16/9 AR (ex: 21/9 film content, 9/16 vertical video).

Quarter zoom PnS presets: x, y values (zoom: 2, 2), works well for 16/9 input.
- top left Quarter: 1, 1, - top right: 0, 1.
- bottom left Quarter: 1, 0 - bottom right: 0, 0.

Fs2xRightSide PnS preset could be used for right side offset 2x zoom for non 16/9 landscape.

in mpc-hc.ini: [Settings\PnSPresets]
Code:
Preset0=Widescreen zoom,0.500,0.500,1.333,1.333
Preset1=Quarter Top-L,1,1,2,2
Preset2=Fs2xRightSide-L,0,0.5,2,2
You can generally combine user pixel shaders with any mpc-hc zoom feature (including Right-Click: Video Frame > xxx and Zoom > xxx).

"Video Frame > Touch window from outside" is a centered fullscreen crop mode based on the input video Aspect Ratio. Fills the window/screen by zooming and cropping the video.

Last edited by butterw2; 29th November 2020 at 00:19. Reason: PnS manually adjusted zoom : +numpad9 and -1
butterw2 is offline   Reply With Quote
Old 22nd July 2020, 17:44   #6  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
# mpc-hc/be don't support hw linear sampling

Linear sampling is a performance optimization technique for gpu pixel shader. The idea is to reduce the number of pixel (texture) fetches required by an algorithm by sampling between pixels and exploiting hardware linear interpolation.

a 2-pass pre-resize shader test was performed:
https://github.com/butterw/bShaders/...linearSampling
- pass-1 generate a black and white stripe test motif,
- pass-2 use linear sampling

Expected: interpolation, colored Red
Result: no interpolation (Nearest Neighbor). If the offset is set to 0.5 pixel: produces some rounding artefacts !



Software and hardware setup
- mpc-hc v1.9.6 + EVR-CP. Also tested in mpc-be
- old intel igpu (hd4400), not the latest Win10 + drivers


## Linear Sampling (in hlsl): tex2D(s0, tex + k*p1) where k is non integer
the effect of Nearest Neighbor sampling is to round k.x, k.y to the nearest integer. If k.x or k.y is a half, you then get some rounding artefacts.
While it certainly is possible to get rid of the rounding artefacts, they are a symptom of the larger problem: Linear Sampling not being supported, which has major implications for the math analysis.

Linear sampling is exploited by perf optimized convolution kernel shaders (such as: Luma Sharpen, gaussian blur, etc.). If it isn't supported, the shaders still produce an output, but a suboptimal one. The provided test allows for the user to test whether linear sampling is actually supported.

Edit (linear sampling works in mpv): the same test using rgb32 png input was performed on the same configuration with a glsl shader (mpv video player, vo=gpu), and I'm getting the expected result there !
https://github.com/butterw/bShaders/...linearSampling

Edit2 (hw linear sampling isn't supported in mpc-hc/be): hw linear sampling also not working as expected in mpc-hc/be with mpc-vr as video renderer in dx9 and dx11 modes.
https://github.com/clsid2/mpc-hc/issues/748
This impacts shaders such as LumaSharpen.hlsl

Last edited by butterw2; 26th March 2021 at 10:51. Reason: Works as expected in mpv !
butterw2 is offline   Reply With Quote
Old 22nd July 2020, 22:39   #7  |  Link
VictorLS
Registered User
 
Join Date: Mar 2009
Location: Russian Crimea
Posts: 318
I know but result of that translation is bad enough or some 'know how' must be known to get it working well.
Besides - I don't really sure libplacebo (only?) do desirable color transformation (HLGtoSDR) or VLC uses something else - I'm not programmer at all and moreover I'm not shader programmer (
Here's somehow working HLGtoSDR shaders https://transfiles.ru/svler - Convert HDR to SDR.hlsl in HDR folder work well enough but for ordinary HDR files like 23_Samsung_HDR_Wonderland.mkv (97 MB) https://yadi.sk/i/ZgkOWjcEwWQNkQ - not for HLG files like 20190831-160457_RTL UHD.mkv (135 MB) https://yadi.sk/i/SRloXWrOP-L-xA
I even don't know that (not in HDR folder) shaders was taken from libplacebo or somewhere else
PS. Here's long time (more than 4 minutes) test files https://forum.doom9.org/showthread.p...34#post1919134

Last edited by VictorLS; 23rd July 2020 at 00:17.
VictorLS is offline   Reply With Quote
Old 23rd July 2020, 11:32   #8  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
I'm afraid, my experience on the subject of HDR to SDR tonemapping is rather limited.
mpc-be does some tonemapping by default (using hlsl shaders I believe). If I understand you correctly, you claim that the method used by vlc and mpv gives more accurate results ?

If there was a mpv glsl .hook file, that might be a better starting point for a port than libplacebo (c file with inlined GLSL).
I've tried the provided "Convert HDR to SDR.hlsl" shader in mpc-hc. The colors seem oversaturated for my taste (while the colors are washed out without it). The processing is not that complex (~100 lines of actual code), so it should be achievable to get the shader part working if a reference glsl implementation exists.

Regarding the provided sample files:
- 20190831-160457_RTL UHD.mkv is UHD-50 hevc 10bit HDR 41Mbps
- 23_Samsung_HDR_Wonderland.mkv UHD hevc 10bit HDR 22.5Mbps
Without considering the issue of tonemapping, these files do not play smoothly on an old pc/integrated graphics + 1080p SDR screen like mine.

For testing purposes, short samples are probably fine, I would suggest downconverting the most relevant ones to 1080p, reducing the bitrate 10/20x, maybe remove the audio, provide screenshots (with frame timestamp/frame number) of what you regard as desirable (from mpv, avisynth) vs what was achieved and host this with the code on a server that will not delete your files.
butterw2 is offline   Reply With Quote
Old 23rd July 2020, 14:02   #9  |  Link
VictorLS
Registered User
 
Join Date: Mar 2009
Location: Russian Crimea
Posts: 318
Thanks for reply.
Quote:
I'm afraid, my experience on the subject of HDR to SDR tonemapping is rather limited
It's a pity but I believe in you
Btw I have SDR (BT.709) monitor too - that's why I want to find good HLGtoSDR shader but couldn't yet (
Quote:
20190831-160457_RTL UHD.mkv is UHD-50 hevc 10bit HDR 41Mbps
Not only ordinary HDR, but HLG same time - that's why working with ordinary HDR video like
Quote:
23_Samsung_HDR_Wonderland.mkv UHD hevc 10bit HDR 22.5Mbps
Convert HDR to SDR.hlsl shader gives good result but with HLG 20190831-160457_RTL UHD.mkv oversaturated.
Quote:
mpc-be does some tonemapping by default (using hlsl shaders I believe)
Yes, you're quiet right (btw MPC-HC must output to madVR or use Convert HDR to SDR.hlsl shader with any other renderer to achieve such results - am I right?)
Quote:
If there was a mpv glsl .hook file, that might be a better starting point for a port than libplacebo (c file with inlined GLSL)
From MPC-BE developers I've heard mpv does it on a fly so they are couldn't extract using by mpv shader while playing HLG file (btw they are looking at my researching for HLGtoSDR shader and ready to implement it in MPC-BE like now HDR if result will be positive). Besides quality of tonemapping depends of version of mpv - older than August 2019 are better (newer gives some rose instead of red) on my own so I'd prefer shader extracted from VLC
Quote:
For testing purposes, short samples are probably fine
I agree in your case - you can find them in the bottom of first post https://forum.doom9.org/showthread.php?t=176909
Quote:
I would suggest downconverting the most relevant ones to 1080p
I guess it's wrong way because HLG metadata can be lost during any conversion so see first post for your other wishes

Last edited by VictorLS; 23rd July 2020 at 14:04.
VictorLS is offline   Reply With Quote
Old 23rd July 2020, 17:22   #10  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
# HDR to SDR Tone mapping shader

Tone mapping is required to correctly display any HDR encoding (typ 1080p Hevc 10bit HDR encode from UHD bluray) displayed on a Standard Dynamic Range computer screen (almost all current monitors are non-HDR).

mpc-hc doesn't do any tone mapping by default: so colors look washed out. If you enable the provided Convert HDR to SDR.hlsl shader, the results seem quite watchable for HDR content. It's also a reasonably lightweight shader (1 texture, 44 arithmetic).
Edit: the code likely comes from mpc-be and has 2 tuning parameters (LuminancePeak_Gain, Gamma).
Such a shader can improve the viewing of a washed-out color video (ex: encode of an HDR source to SDR with no tonemapping applied, or undersatured SDR video). It shouldn't be used otherwise.

mpc-be and vlc come with built-in SDR Tone mapping, which is applied automatically (there doesn't seem to be a setting to deactivate it !).

The samples (RTL title screen) in your first post here https://forum.doom9.org/showthread.php?t=176909
seem like a good starting point regarding the specific case of Hybrid Log-Gamma (HLG) HDR used in UHD satellite broadcasts .

- 23_Samsung_HDR_Wonderland.mkv (UHD hevc 10bit HDR 22.5Mbps)
-20190831-160457_RTL UHD.mkv (UHD-50 hevc 10bit HLG HDR 41Mbps): quite specific sample because it contains a lot of white smoke. I actually prefer no tone mapping on this sample vs oversaturated result.

Also, on my PC performance is awful with VLC with these 2 samples.

Last edited by butterw2; 19th October 2020 at 17:56.
butterw2 is offline   Reply With Quote
Old 23rd July 2020, 21:26   #11  |  Link
VictorLS
Registered User
 
Join Date: Mar 2009
Location: Russian Crimea
Posts: 318
Quote:
Tone mapping is required to correctly display any HDR encoding (typ 1080p Hevc 10bit HDR encode from UHD bluray) displayed on a Standard Dynamic Range computer screen (almost all current monitors are non-HDR)
mpc-hc doesn't do any tone mapping by default: so colors look washed out. If you enable the provided Convert HDR to SDR.hlsl shader, the results seem quite watchable for HDR content. It's also a reasonably lightweight shader (1 texture, 44 arithmetic).
So, I was right when wrote "MPC-HC must output to madVR or use Convert HDR to SDR.hlsl shader with any other renderer to achieve such results"
Quote:
mpc-be and vlc come with built-in SDR Tone mapping, which is applied automatically (there doesn't seem to be a setting to deactivate it).
You're right.
Quote:
The samples in your first post here https://forum.doom9.org/showthread.php?t=176909
seem like a good starting point regarding the specific case of Hybrid Log-Gamma (HLG) HDR used in some satellite broadcasts(RTL title screen).
Some people said this is bad point so I hard work to write red-flagged F1 to someone do right shader with colorimeter
SDR FullHD H.264 20190511-130113_ARENA HD_flag.ts (38 MB) https://yadi.sk/i/HiuZ5Rb2RKkc0g
HLG 4K H.265 20190511-152944_RTL UHD_flag.ts (67 MB) https://yadi.sk/i/985DVw34OHQrrA
Quote:
-20190831-160457_RTL UHD.mkv (UHD-50 hevc 10bit HLG HDR 41Mbps): quite specific sample because it contains a lot of white smoke.
I've uploaded that to see how new HLGtoSDR shader shows grass - it's looking ugly now with or without tonemapping in ordinary DirectShow players.
Quote:
I actually prefer no tone mapping on this sample vs oversaturated result.
You're right but I'd want get VLC (OpengGL output in Win7 or D3D11 output in Win8-10) colors with HLGtoSDR shader
Quote:
Also, on my PC performance is awful with VLC with these 2 samples.
and weak PC can't stop experiments with colors because of watching mostly in pause mode

Last edited by VictorLS; 23rd July 2020 at 21:32.
VictorLS is offline   Reply With Quote
Old 25th September 2020, 20:13   #12  |  Link
SirMaster
Registered User
 
Join Date: Feb 2019
Posts: 126
Thanks, I actually just e-mailed Jan-Willem Krans this afternoon asking about it and he whipped up a simple shader to do what I wanted in this case.

Code:
#define RedControls 0
#define BlueControls 0
// RedShiftLeftToRight and BlueShiftLeftToRight, a value of 3. will shift three pixels to the right, 0 is disabled
#define RedShiftLeftToRight 0.
#define BlueShiftLeftToRight 0.
// RedShiftTopToBottom and BlueShiftTopToBottom, a value of 3. will shift three pixels to the bottom, 0 is disabled
#define RedShiftTopToBottom 0.
#define BlueShiftTopToBottom 0.

sampler s0;
float2 c1 : register(c1);

float4 main(float2 tex : TEXCOORD0) : COLOR
{
	float4 s1 = tex2D(s0, tex);// base pixel
#if RedControls == 1
	s1.r = tex2D(s0, tex+c1*float2(RedShiftLeftToRight, RedShiftTopToBottom)).r;// base red pixel
#endif
#if BlueControls == 1
	s1.b = tex2D(s0, tex+c1*float2(BlueShiftLeftToRight, BlueShiftTopToBottom)).b;// base blue pixel
#endif
	return s1;
}
And yes, this sort of shader is useful for fixing the RGB panel convergence in 3-chip projectors where the 3 color producing panels are not in perfect alignment.

Basically a projector can look like this:

https://lowtek.ca/roo/wp-content/upl...03/avsbad3.jpg

Some higher end projectors have internal software corrections for this sort of issue that you can adjust, but others do not, and that's where this shader comes in.

I used his shader that you posted, but that one has complex pixel interpolation and breaks the perfect 1:1 pixel mapping that I wanted. this new simple shader he wrote or me does exactly what I wanted now.


I do have some other ideas for some simple shaders that I want to try making and I may post here if I have questions about how to do something as I start tinkering around with them.

Last edited by SirMaster; 26th September 2020 at 17:49.
SirMaster is offline   Reply With Quote
Old 25th September 2020, 21:48   #13  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
You just wanted a configurable (x, y) pixel offset on red and blue channels. Very simple indeed using a pixel shader. This could also be used as an effect of sorts, I suppose.

if I can add anything at all, p1 would be a more common name for the pixel offset:
float2 p1: register(c1);
butterw2 is offline   Reply With Quote
Old 30th September 2020, 17:51   #14  |  Link
SirMaster
Registered User
 
Join Date: Feb 2019
Posts: 126
Here is a shader I made for simple 4 way masking.

Code:
#define width 1920.
#define height 1080.

#define left 0
#define right 0
#define top 0
#define bottom 0

sampler s0;

float4 main(float2 tex : TEXCOORD0) : COLOR
{
	if(tex.x >= (left/width) && tex.x <= 1-(right/width) && tex.y >= (top/height) && tex.y <= 1-(bottom/height)) return tex2D(s0, tex);
	return float4(0, 0, 0, 1);
}
This sort of video masking is a feature found in most higher-end projectors as there can be reasons why you may want to mask parts of the image for certain projection screen sizes and shapes and aspect ratios and such.

This is useful for projectors that don't have a built in 4 way masking control.
SirMaster is offline   Reply With Quote
Old 30th September 2020, 18:27   #15  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
Here's my own optimized implementation from barMask.hlsl (Mode==112)
"if" conditionals are quite inefficient with pixel shaders, so the code uses a boolean insideBox function instead.
All functions in HLSL are inline. An inline function generates a copy of the function body (when compiling) for each function call. #define macro functions are also commonly used.

Quote:
/* Custom Border Mask defined in pixels
(1 texture, 10 arithmetic)
barMask.hlsl (Mode==112)
*/


#define BorderColor 0
#define Top 0
#define Left 0
#define Bottom 0
#define Right 0

sampler s0: register(s0);
float2 p1: register(c1);

bool insideBox(float2 tex, float2 topLeft, float2 bottomRight){
/* returns true if tex coordinates inside the box, returns false otherwise. !insideBox: outsideBox */
float2 s = step(topLeft, tex) - step(bottomRight, tex);
return s.x * s.y;
}

/* --- Main --- */
float4 main(float2 tex: TEXCOORD0): COLOR {
if (insideBox(tex, p1*float2(Left, Top), 1-p1*float2(Right, Bottom))) return tex2D(s0, tex);
return BorderColor;
}

Last edited by butterw2; 30th September 2020 at 20:30. Reason: Code was copy-pasted, hopefully without mistakes
butterw2 is offline   Reply With Quote
Old 30th September 2020, 19:14   #16  |  Link
SirMaster
Registered User
 
Join Date: Feb 2019
Posts: 126
Quote:
Originally Posted by butterw2 View Post
Here's my own optimized implementation from barMask.hlsl (Mode==112)
if conditionals are quite inefficient with pixel shaders.
Oh, awesome!
SirMaster is offline   Reply With Quote
Old 24th November 2020, 15:34   #17  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
# mpv shader hotkeys

Mpv comes with a number of predefined keyboard shortcuts. You can add new shorcuts and individually override pre-existing ones by creating an input.conf file.

./portable_config/input.conf :

Code:
# Display the list of active shaders:
CTRL+0 show-text "Shaders: ${glsl-shaders}"

# Switch to a new shader chain:
CTRL+9 change-list glsl-shaders set "NoChroma.hook"

# Associate a hotkey to a shader, so it can be toggled on/off:
CTRL+1 change-list glsl-shaders toggle "./shaders/gSmooth.hook"

# Clear all Shaders:
CTRL+p change-list glsl-shaders clr all; show-text "Shaders Cleared"
# CTRL+1 change-list glsl-shaders set ""
Switching or Disabling shaders through a hotkey can be done without restarting the player and also works in paused mode.
EDIT:! When shaders are cleared, the previous shader chain is lost (it can't be re-enabled, it has to be re-created). To avoid this the external script shaders-switch.js can be used: https://github.com/mpv-player/mpv/issues/8512 and bound to CTRL-P.
! To force modified shaders to recompile, you have to restart mpv.

Last edited by butterw2; 30th January 2021 at 15:28. Reason: +linked: shaders-switch.js
butterw2 is offline   Reply With Quote
Old 27th November 2020, 13:39   #18  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
#Shaders Folder, Paths and extensions

In mpv
- shaders can use any paths or file extension (.hook is typically used).
- because shaders can be specified at the command line:
---avoid spaces in filepaths.
---keep paths short
examples using a relative path from the program directory:
bw.hook
"shaders/shade.hook"



In Mpc-hc
mpc-hc uses ./Shaders for dx9 shaders.
The Select Shaders... Interface, (O) Options... > Playback > Shaders shows .hlsl files in ./Shaders and its subdirs.
If you have a lot of shaders, it is useful to move the less frequently used ones to subdirs. An empty shader named
z------------------------------------------------------------------------------------.hlsl can be used as a separator.

The interface also allows to load and save Shader presets.

Last edited by butterw2; 20th February 2021 at 17:10.
butterw2 is offline   Reply With Quote
Old 4th December 2020, 20:29   #19  |  Link
butterw2
Registered User
 
Join Date: Jun 2020
Posts: 208
# mpv Auto-Profiles
The following is an example of an automatic profile in mpv.conf based on video file properties.

The profile is triggered when profile-cond (a lua expression based on file properties) is true.
ex: profile-cond=width>=1280

in mpv.conf:
Code:
#mpv auto-profile example
[filename_wsz]
profile-desc= 4/3>>16/9 fullscreen PnS if _wsz in filename
profile-cond= string.match(filename, "_wsz")~=nil 
video-zoom=0.42
fs=yes
profile-restore=copy
When a filename containing the string "_wsz" is opened, the file is automatically displayed in fullscreen with the required Pan&Scan to remove the hardcoded black bars.
Nice.

EDIT: it's also possible to create and use a custom .wsz extension associated with mpv. In which case it's even simpler:
Code:
[extension.wsz]
profile-desc= 4/3>>16/9 PnS for files with .wsz extension
video-zoom=0.42

Last edited by butterw2; 5th December 2020 at 00:41.
butterw2 is offline   Reply With Quote
Old 5th December 2020, 07:58   #20  |  Link
chros
Registered User
 
chros's Avatar
 
Join Date: Mar 2002
Posts: 2,112
I used an auto-profile script (I think) when I played with it, but it was pretty finicky to set up more than 10 profiles based on fps, resolution, hdr, etc. But it worked in the end.
But big question is how to auto change the refresh rate of the display, displays in profiles, etc.
__________________
Ryzen 5 2600,Asus Prime b450-Plus,16GB,MSI GTX 1060 Gaming X 6GB(v398.18),Win10 LTSC 1809,MPC-BEx64+LAV+MadVR,Yamaha RX-A870,LG OLED65B8(2160p@23/24/25/29/30/50/59/60Hz) | madvr config
chros is offline   Reply With Quote
Reply

Tags
hlsl, mpc-be, mpc-hc, mpv, pixel 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 14:41.


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