Skip to content

Instantly share code, notes, and snippets.

View butterw's full-sized avatar

butterw butterw

  • France
View GitHub Profile
@butterw
butterw / CAS_dx11.hlsl
Created November 14, 2023 22:02
mpc-hc/be hlsl Contrast Adaptive Sharpening shader (dx9 and dx11 versions)
// $MinimumShaderProfile: ps_4_0
#define CAS 0.35
#define Npixels 1280 //0
#define Show_Edge 0
/* --- CAS_lite (dx11) --- */
/* Contrast Adaptive Sharpening (AMD FidelityFX CAS)
mpc-hc mod by butterw (9 texture, 47 arithmetic) (2023-11)
based on this reshade port: https://gist.github.com/martymcmodding/30304c4bffa6e2bd2eb59ff8bb09d135
@butterw
butterw / resizer_lanczos3_x.hlsl
Last active October 13, 2020 00:07
compensated Lanczos3 pass X (from mpc-be, adapted for mpc-hc user shader)
// compensated Lanczos3, pass X
// originally from mpc-be: https://sourceforge.net/p/mpcbe/code/HEAD/tree/trunk/src/Shaders/Resizers/resizer_lanczos3_x.hlsl
// adapted for use in mpc-hc (as zoomX=2) by butterw (license: GPL v3)
// use as a pre-resize shader, input resolution should match the screen resolution (no player resize involved)
// pass X perf: (6 texture, 79 arithmetic)
// A catmull-rom resizer (true separable kernel) is also available: resizer_catmull4_x.hlsl. Catmull-Rom spline4, pass X: (4 texture, 22 arithmetic)
sampler s0: register(s0);
float2 p0: register(c0); // W, H
float2 p1: register(c1); //px, py
@butterw
butterw / Edge_Sharpen.hlsl
Created October 8, 2020 17:09
mpc-hc Edge Sharpen mod and optimization
#define Show_Edge 20
//[0, 1, 2, 20] default 0: edge sharpen, 1: show edges in Red, 2: show luma edges, 20 luma edges on dark background
#define Show_SplitScreen 1 //[0, 1, 2] default 0: no splitscreen, 1: horizontal split, 2 vertical split
/*
Edge detection and Edge sharpening, using Four 3x3 Prewitt operators.
Software Licence: GPL v3
the original Edge Sharpen is distributed with MPC-HC: https://www.videohelp.com/software/Media-Player-Classic-Home-Cinema
2020: - modification and optimization by butterw (9 texture, 47 arithmetic) >> (9 texture, 34 arithmetic)
@butterw
butterw / edge_freichen.hook
Last active October 8, 2020 12:29
Frei-Chen edge detection in luma (mpv .hook shader)
//!HOOK LUMA
//!BIND HOOKED
//!DESC Frei-Chen Edge Detection
/*
Frei-Chen Edge Detection (in Luma)
original source code (freichen.frag): http://rastergrid.com/blog/2011/01/frei-chen-edge-detector/
glsl-shader adapted to mpv .hook by butterw
best results as a LUMA hook but can also work on MAIN or OUTPUT, can be combined with NoChroma.hook.
@butterw
butterw / NoChroma.hook
Created October 8, 2020 10:35
mpv glsl hook to remove source chroma (UV)
//!HOOK CHROMA
//!BIND HOOKED
//!DESC ChromaOff
/* glsl-shader for mpv video player, removes yuv source chroma (keep luma)*/
vec4 hook(){
return vec4(0.5);
}
Moved to FilmGrain/Noise shader dir: https://github.com/butterw/bShaders/tree/master/FilmGrain_Noise
@butterw
butterw / bar_Mask.hlsl
Last active July 7, 2020 09:13
Image Masking/Shift methods (based on custom border widths, Aspect Ratio, with Offset, BoxMask) for realtime video playback in mpc-hc. Uses: Logo masking, offset 9/16 or 1/1 view, 21/9 view
updated version in https://github.com/butterw/bShaders
@butterw
butterw / bTimeEffect_DePixelate.hlsl
Last active June 19, 2020 16:14
depixelate effect/glitch, strobe. Shows how to control an effect vs time (start, duration, repetition).
/*
bTimeEffect_DePixelate (square pixels)
by butterw
control a video pixel shader effect vs time.
tested in mpc-hc v1.9.3:
- Opening the player by double clicking a video starts the clock
- Short effect/glitch repeats every 10 seconds by default (T).
- Note that Loading another video or Pause/Stop does not reset the clock !
@butterw
butterw / bSide.hlsl
Last active June 20, 2020 13:21
hlsl pixel shader tested in mpc-hc video player. Apply effects to an xy-zone of the video (half the screen, or a box). Use: Side by side effect comparisons. Pixelate zone, Mask logo. Horizontal/Vertical Line.
sampler s0: register(s0);
float4 p1: register(c1);
#define px p1.x //: one_over_width: 1/W
#define py p1.y //: one_over_height: 1/H
/* bSide.hlsl by butterw v1.0 (ZoneShader_mpc)
- this directX pixel shader shows how to apply effects to an xy-zone of the video (half the screen, or a box)
applications:
- half the screen: Side by side effect comparisons.