Skip to content

Instantly share code, notes, and snippets.

@xnoreq
Last active October 17, 2021 09:30
Show Gist options
  • Save xnoreq/355e32e7c97ac50e20941a99965ed652 to your computer and use it in GitHub Desktop.
Save xnoreq/355e32e7c97ac50e20941a99965ed652 to your computer and use it in GitHub Desktop.
EQ glsl shader
//!HOOK MAINPRESUB
//!BIND HOOKED
// Brightness: -1.0 to 1.0, default 0.0
// Contrast: 0.0 to 10.0, default 1.0
// Hue: -180.0 to +180.0, default 0.0
// Saturation: 0.0 to 10.0, default 1.0
#define Brightness 0.0
#define Contrast 1.0
#define Hue 0.0
#define Saturation 1.0
#define PI 3.1415926535897932384626433832795
#define ymin (15 / 255.0)
const mat4 r2y = mat4(
0.299, -0.14713, 0.615, 0.000,
0.587, -0.28886, -0.51499, 0.000,
0.114, 0.436, -0.10001, 0.000,
0.000, 0.000, 0.000, 0.000
);
const mat4 y2r = mat4(
1.000, 1.000, 1.000, 0.000,
0.000, -0.39465, 2.03211, 0.000,
1.13983, -0.58060, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000
);
const mat2 HueMatrix = mat2(
cos(Hue * PI / 180), -sin(Hue * PI / 180),
sin(Hue * PI / 180), cos(Hue * PI / 180)
);
#define Src(a,b) HOOKED_texOff(vec2(a,b))
vec4 hook()
{
vec4 c0 = Src(0,0);
c0 = r2y * c0;
c0.r = Contrast * (c0.r - ymin) + ymin + Brightness;
c0.gb = (HueMatrix * c0.gb) * Saturation;
c0 = y2r * c0;
return c0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment