View Full Version : Help with placebo.Shader and adaptive-sharpen.glsl
poisondeathray
6th September 2021, 05:10
Can anyone get placebo.Shader and adaptive-sharpen.glsl working ?
It returns image for me, but no difference in image. I tried some switches, specifying width/height, linearizing
Some other .glsl shaders seem to work ok through placebo.Shader, eg. LumaSharpenHook.glsl
I'm using this version of adaptive-sharpen.glsl
version 2020-11-14
https://gist.github.com/igv/8a77e4eb8276753b54bb94c1c50c317e
# clip = some random YUV420P8 source
clip = core.resize.Bicubic(clip, format=vs.YUV444P16)
ps = core.placebo.Shader(clip, shader=r'PATH\adaptive-sharpen.glsl')
#d = core.std.MakeDiff(clip, ps)
#d.set_output()
ps.set_output()
Greenhorn
6th September 2021, 10:41
It doesn't work for me either; perhaps it's because the shader expects RGB input? (It's definitely approximating luma from RGB values, and also runs after YUV to RGB conversion when I load it in mpv-- where it does work.)
Selur
6th September 2021, 12:02
Afaik that shader only works if width&height are different than your input, it needs to be used as a resizer. :)
Also change the settings inside the glsl script:
//--------------------------------------- Settings ------------------------------------------------
#define curve_height 1.0 // Main control of sharpening strength [>0]
// 0.3 <-> 2.0 is a reasonable range of values
#define anime_mode false // Only darken edges
#define overshoot_ctrl false // Allow for higher overshoot if the current edge pixel
// is surrounded by similar edge pixels
#define video_level_out false // True to preserve BTB & WTW (minor summation error)
// Normally it should be set to false
// Defined values under this row are "optimal" DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU ARE DOING!
#define curveslope 0.5 // Sharpening curve slope, high edge values
#define L_overshoot 0.003 // Max light overshoot before compression [>0.001]
#define L_compr_low 0.167 // Light compression, default (0.167=~6x)
#define L_compr_high 0.334 // Light compression, surrounded by edges (0.334=~3x)
#define D_overshoot 0.009 // Max dark overshoot before compression [>0.001]
#define D_compr_low 0.250 // Dark compression, default (0.250=4x)
#define D_compr_high 0.500 // Dark compression, surrounded by edges (0.500=2x)
#define scale_lim 0.1 // Abs max change before compression [>0.01]
#define scale_cs 0.056 // Compression slope above scale_lim
#define pm_p 0.5 // Power mean p-value [>0-1.0]
//-------------------------------------------------------------------------------------------------
Just for a quick check set curve_height to 100, that should definitly noticeably change the appearance. :)
Cu Selur
Ps.: if anyone has a collection of glsl filters that work with vsplacebo would be nice if he could share them.
poisondeathray
6th September 2021, 15:16
Just for a quick check set curve_height to 100, that should definitly noticeably change the appearance.
No effect :(
BTW the avisynth version by Dogway, which is not GPU accelerated - works.
Selur
6th September 2021, 16:33
width=clip.width+1
does not work here it gives:
image dimensions must be divisible by subsampling factor
so instead of +1 one needs to use at least + 4 ;)
poisondeathray
6th September 2021, 17:25
Thanks,
resize workaround.... works . But is that intended behaviour ? You don't need to resize in mpv or avs version
Dogway
6th September 2021, 17:41
Did you try processing in float precision?
poisondeathray
6th September 2021, 17:44
Did you try processing in float precision?
Thanks for your input, your ported version works :)
Yes, I tried RGBS and YUV444PS, but this version requires YUVxxxP16 and you get error msg
Python exception: placebo.Shader: Input should be YUVxxxP16!
https://github.com/Lypheo/vs-placebo
placebo.Shader
Takes a YUVxxxP16 clips as input and outputs YUV444P16
poisondeathray
7th September 2021, 04:52
Hmm...I blindly modified it so it works without needing to resize. Have fun. https://gist.github.com/HolyWu/72fbe92c2b4700243adb502526a88591
BTW, libvs_placebo-20210907-22d56b0.7z (https://www.mediafire.com/file/6qm5jybi2zfohf2/libvs_placebo-20210907-22d56b0.7z/file) built from the latest libplacebo and vs-placebo.
Thanks!
Selur
7th September 2021, 06:41
Nice! Thanks HolyWu :)
poisondeathray
19th December 2022, 04:47
Apparently there is a 2pass adaptive_sharpen from bacondither, but it's hlsl , not glsl. Does anyone have a glsl version suitable for use in placebo.Shader , or know of a way of converting it ?
https://github.com/bacondither/Adaptive-sharpen/blob/0da6654e464c4136e3a68d80f5cd3bd7563762b9/shaders/Adaptive-sharpen%20-%20Pass%20two.hlsl
Dogway based his avisynth version of adaptive_sharpen on the 2pass version , and the results are better in many cases
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.