Closed geextahslex closed 6 months ago
``//!PARAM Strength //!DESC Desat Strength //!TYPE float //!MINIMUM 0 //!MAXIMUM 1 1
//!HOOK MAIN //!BIND HOOKED //!DESC Desaturation smooth
/ desaturate vibrance with smoothstep / vec4 hook() { vec4 c0 = HOOKED_texOff(0); float vibrance = 1.0 - smoothstep(Thresh - w, Thresh + w, dot(c0, CoefLuma));
c0.rgb = mix(vec3(dot(c0, CoefLuma)), c0.rgb, Strength*vibrance);
return c0;
} ``
I did my best on it and it seems to work well when I play my videos. Hope this helps
Thanks for your response. I tried it, it seems to effect the whole image and is not respecting the treshold. You can try this one out.
//!PARAM vibr
//!DESC Saturates/deSaturates
//!TYPE float
//!MINIMUM -1
-0.15
//!HOOK MAIN
//!BIND HOOKED
//!DESC Vibrance
#define CoefLuma vec4(0.2126, 0.7152, 0.0722, 0) //sRGB, HDTV
float Thresh = 45.0/255.0;
float w = 10.0/255.0;
vec4 hook() {
vec4 c0 = HOOKED_texOff(0);
float lum = (c0.r + c0.g + c0.b)/3.0;
float colorSat = max(max(c0.r, c0.g), c0.b) -min(min(c0.r, c0.g), c0.b); // >=0, 5 arithmetic
vec3 sat = mix(vec3(dot(c0, CoefLuma)), c0.rgb, 1+vibr -colorSat*abs(vibr));
float delta = smoothstep( Thresh-w, Thresh+w, lum);
c0.rgb = mix( sat, c0.rgb, delta);
return c0;
}
Yep, after more testing, I could not test it long at work yours works better. 😀
Hi I use this shader to desaturate dark colors in mpv. I want to make something similar but with vibrance instead of saturation. Can you help me out with that? Thank you :)