|
|
|
@ -246,52 +246,52 @@ Open(struct vlc_gl_filter *filter, const config_chain_t *config, |
|
|
|
"\n" |
|
|
|
/* expects normalized rgb */ |
|
|
|
"vec3 rgb_to_hsl(float r, float g, float b) {\n" |
|
|
|
" float h = 0.f, s = 0.f, l = 0.f;\n" |
|
|
|
" float h = 0.0, s = 0.0, l = 0.0;\n" |
|
|
|
" float cmin = min(min(r, g), b);\n" |
|
|
|
" float cmax = max(max(r, g), b);\n" |
|
|
|
" l = (cmin + cmax) / 2.f;\n" |
|
|
|
" l = (cmin + cmax) / 2.0;\n" |
|
|
|
" float diff = cmax - cmin;\n" |
|
|
|
" if (diff < 0.001f) {\n" |
|
|
|
" if (diff < 0.001) {\n" |
|
|
|
" return vec3(h, s, l);\n" |
|
|
|
" }\n" |
|
|
|
" s = diff / (1.f - abs(2.f * l - 1.f));\n" |
|
|
|
" s = diff / (1.0 - abs(2.0 * l - 1.0));\n" |
|
|
|
" if (cmax == r) {\n" |
|
|
|
" h = mod((g - b) / diff, 6.f);\n" |
|
|
|
" h = mod((g - b) / diff, 6.0);\n" |
|
|
|
" }\n" |
|
|
|
" else if (cmax == g) {\n" |
|
|
|
" h = 2.f + (b - r) / diff;\n" |
|
|
|
" h = 2.0 + (b - r) / diff;\n" |
|
|
|
" }\n" |
|
|
|
" else {\n" |
|
|
|
" h = 4.f + (r - g) / diff;\n" |
|
|
|
" h = 4.0 + (r - g) / diff;\n" |
|
|
|
" }\n" |
|
|
|
" h *= 60.f;\n" |
|
|
|
" h *= 60.0;\n" |
|
|
|
" return vec3(h, s, l);\n" |
|
|
|
"}\n" |
|
|
|
"\n" |
|
|
|
"vec3 hsl_to_rgb(float h, float s, float l) {\n" |
|
|
|
" vec3 res = vec3(0.f);\n" |
|
|
|
" vec3 res = vec3(0.0);\n" |
|
|
|
" \n" |
|
|
|
" float c = (1 - abs(2 * l - 1)) * s;\n" |
|
|
|
" float x = c * (1 - abs(mod(h / 60.f, 2) - 1));\n" |
|
|
|
" float m = l - c * 0.5f;\n" |
|
|
|
" float c = (1.0 - abs(2.0 * l - 1.0)) * s;\n" |
|
|
|
" float x = c * (1.0 - abs(mod(h / 60.0, 2.0) - 1.0));\n" |
|
|
|
" float m = l - c * 0.5;\n" |
|
|
|
" \n" |
|
|
|
" if (h < 60.f) {\n" |
|
|
|
" res = vec3(c, x, 0);\n" |
|
|
|
" if (h < 60.0) {\n" |
|
|
|
" res = vec3(c, x, 0.0);\n" |
|
|
|
" }\n" |
|
|
|
" else if (h < 120.f) {\n" |
|
|
|
" res = vec3(x, c, 0);\n" |
|
|
|
" else if (h < 120.0) {\n" |
|
|
|
" res = vec3(x, c, 0.0);\n" |
|
|
|
" }\n" |
|
|
|
" else if (h < 180.f) {\n" |
|
|
|
" res = vec3(0, c, x);\n" |
|
|
|
" else if (h < 180.0) {\n" |
|
|
|
" res = vec3(0.0, c, x);\n" |
|
|
|
" }\n" |
|
|
|
" else if (h < 240.f) {\n" |
|
|
|
" res = vec3(0, x, c);\n" |
|
|
|
" else if (h < 240.0) {\n" |
|
|
|
" res = vec3(0.0, x, c);\n" |
|
|
|
" }\n" |
|
|
|
" else if (h < 300.f) {\n" |
|
|
|
" res = vec3(x, 0, c);\n" |
|
|
|
" else if (h < 300.0) {\n" |
|
|
|
" res = vec3(x, 0.0, c);\n" |
|
|
|
" }\n" |
|
|
|
" else if (h < 360.f) {\n" |
|
|
|
" res = vec3(c, 0, x);\n" |
|
|
|
" else if (h < 360.0) {\n" |
|
|
|
" res = vec3(c, 0.0, x);\n" |
|
|
|
" }\n" |
|
|
|
" return res + m;\n" |
|
|
|
"}\n" |
|
|
|
@ -301,18 +301,18 @@ Open(struct vlc_gl_filter *filter, const config_chain_t *config, |
|
|
|
" if (!brightness_threshold) {\n" |
|
|
|
" color = rgb_to_hsl(color.r, color.g, color.b);\n" |
|
|
|
" color = hsl_to_rgb(\n" |
|
|
|
" mod(color.r - hue, 360.f),\n" |
|
|
|
" clamp(color.g * saturation, 0.0f, 1.f),\n" |
|
|
|
" clamp(color.b, 0.f, 1.f)\n" |
|
|
|
" mod(color.r - hue, 360.0),\n" |
|
|
|
" clamp(color.g * saturation, 0.0, 1.0),\n" |
|
|
|
" clamp(color.b, 0.0, 1.0)\n" |
|
|
|
" );\n" |
|
|
|
" color = pow(clamp(contrast * color + brightness + 0.5f\n" |
|
|
|
" - contrast * 0.5f, 0.f, 1.f), vec3(gamma));\n" |
|
|
|
" color = pow(clamp(contrast * color + brightness + 0.5\n" |
|
|
|
" - contrast * 0.5, 0.0, 1.0), vec3(gamma));\n" |
|
|
|
" } else {\n" |
|
|
|
" color.r = color.r < brightness ? 0.f : 1.f;\n" |
|
|
|
" color.g = color.g < brightness ? 0.f : 1.f;\n" |
|
|
|
" color.b = color.b < brightness ? 0.f : 1.f;\n" |
|
|
|
" color.r = color.r < brightness ? 0.0 : 1.0;\n" |
|
|
|
" color.g = color.g < brightness ? 0.0 : 1.0;\n" |
|
|
|
" color.b = color.b < brightness ? 0.0 : 1.0;\n" |
|
|
|
" }\n" |
|
|
|
" gl_FragColor = vec4(color, 0.f);\n" |
|
|
|
" gl_FragColor = vec4(color, 0.0);\n" |
|
|
|
"}\n"; |
|
|
|
|
|
|
|
const char *shader_version; |
|
|
|
|