]> git.sesse.net Git - casparcg/blobdiff - accelerator/ogl/image/blending_glsl.h
set svn:eol-style native on .h and .cpp files
[casparcg] / accelerator / ogl / image / blending_glsl.h
index aab2ae4faf92bb31f60f44fc98e2d9d62b5dbd74..7ccaf40e81f7b0b8f569323408eb89e1bd08a8b7 100644 (file)
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-static std::string get_adjustement_glsl()\r
-{\r
-       return                                                                                                                                                                                                                                                                                                                                                                                                                                          \r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Contrast, saturation, brightness                                                                                                                                                                                                                                                                                                                                                              "\r
-               "\n     ** Code of this function is from TGM's shader pack                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057                                                                                                                                                                                                                                                                                                 "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con)                                                                                                                                                                                                                                                                     "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             const float AvgLumR = 0.5;                                                                                                                                                                                                                                                                                                                                                                         "\r
-               "\n             const float AvgLumG = 0.5;                                                                                                                                                                                                                                                                                                                                                                         "\r
-               "\n             const float AvgLumB = 0.5;                                                                                                                                                                                                                                                                                                                                                                         "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);                                                                                                                                                                                                                                                                                                                           "\r
-               "\n             vec3 brtColor = color * brt;                                                                                                                                                                                                                                                                                                                                                               "\r
-               "\n             vec3 intensity = vec3(dot(brtColor, LumCoeff));                                                                                                                                                                                                                                                                                                                            "\r
-               "\n             vec3 satColor = mix(intensity, brtColor, sat);                                                                                                                                                                                                                                                                                                                             "\r
-               "\n             vec3 conColor = mix(AvgLumin, satColor, con);                                                                                                                                                                                                                                                                                                                              "\r
-               "\n             return conColor;                                                                                                                                                                                                                                                                                                                                                                                           "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                       "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Gamma correction                                                                                                                                                                                                                                                                                                                                                                                                     "\r
-               "\n     ** Details: http://blog.mouaif.org/2009/01/22/photoshop-gamma-correction-shader/                                                                                                                                                                                                                                                                   "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n#define GammaCorrection(color, gamma)                                                                pow(color, vec3(1.0 / gamma))                           \n                                                                                                                                                                                                      "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Levels control (input (+gamma), output)                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Details: http://blog.mouaif.org/2009/01/28/levels-control-shader/                                                                                                                                                                                                                                                                                       "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n#define LevelsControlInputRange(color, minInput, maxInput)                           min(max(color - vec3(minInput), vec3(0.0)) / (vec3(maxInput) - vec3(minInput)), vec3(1.0))              \n                                                                                 "\r
-               "\n#define LevelsControlInput(color, minInput, gamma, maxInput)                         GammaCorrection(LevelsControlInputRange(color, minInput, maxInput), gamma)                                      \n                                                                                              "       \r
-               "\n#define LevelsControlOutputRange(color, minOutput, maxOutput)                        mix(vec3(minOutput), vec3(maxOutput), color)                                                                                                                    \n                                                                 "\r
-               "\n#define LevelsControl(color, minInput, gamma, maxInput, minOutput, maxOutput)        LevelsControlOutputRange(LevelsControlInput(color, minInput, gamma, maxInput), minOutput, maxOutput)    \n                                                      "\r
-               ;\r
-}\r
-\r
-static std::string get_blend_glsl()\r
-{\r
-       static std::string glsl = \r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Photoshop & misc math                                                                                                                                                                                                                                                                                                                                                                                   "\r
-               "\n     ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control                                                                                                                                                                                                                                                                                                     "\r
-               "\n     **                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Romain Dura | Romz                                                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n     ** Blog: http://blog.mouaif.org                                                                                                                                                                                                                                                                                                                                                            "\r
-               "\n     ** Post: http://blog.mouaif.org/?p=94                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Desaturation                                                                                                                                                                                                                                                                                                                                                                                            "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec4 Desaturate(vec3 color, float Desaturation)                                                                                                                                                                                                                                                                                                                            "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 grayXfer = vec3(0.3, 0.59, 0.11);                                                                                                                                                                                                                                                                                                                                             "\r
-               "\n             vec3 gray = vec3(dot(grayXfer, color));                                                                                                                                                                                                                                                                                                                                            "\r
-               "\n             return vec4(mix(color, gray, Desaturation), 1.0);                                                                                                                                                                                                                                                                                                                          "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Hue, saturation, luminance                                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 RGBToHSL(vec3 color)                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 hsl;                                                                                                                                                                                                                                                          "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             float fmin = min(min(color.r, color.g), color.b);                                                                                                                                                                                                                                                                  "\r
-               "\n             float fmax = max(max(color.r, color.g), color.b);                                                                                                                                                                                                                                                                  "\r
-               "\n             float delta = fmax - fmin;                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             hsl.z = (fmax + fmin) / 2.0;                                                                                                                                                                                                                                                                                                                       "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             if (delta == 0.0)                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             {                                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                     hsl.x = 0.0;                                                                                                                                                                                                                                                                                                                                                               "\r
-               "\n                     hsl.y = 0.0;                                                                                                                                                                                                                                                                                                                                                       "\r
-               "\n             }                                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n             else                                                                                                                                                                                                                                                                                                                       "\r
-               "\n             {                                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                     if (hsl.z < 0.5)                                                                                                                                                                                                                                                                                                                                                                                   "\r
-               "\n                             hsl.y = delta / (fmax + fmin);                                                                                                                                                                                                                                                                                             "\r
-               "\n                     else                                                                                                                                                                                                                                                                                                                                                                                                       "\r
-               "\n                             hsl.y = delta / (2.0 - fmax - fmin);                                                                                                                                                                                                                                                                                               "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;                                                                                                                                                                                                                                                                                 "\r
-               "\n                     float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;                                                                                                                                                                                                                                                                                 "\r
-               "\n                     float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     if (color.r == fmax )                                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n                             hsl.x = deltaB - deltaG;                                                                                                                                                                                                                                                                                                                                   "\r
-               "\n                     else if (color.g == fmax)                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                             hsl.x = (1.0 / 3.0) + deltaR - deltaB;                                                                                                                                                                                                                                                                                                     "\r
-               "\n                     else if (color.b == fmax)                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                             hsl.x = (2.0 / 3.0) + deltaG - deltaR;                                                                                                                                                                                                                                                                                                     "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     if (hsl.x < 0.0)                                                                                                                                                                                                                                                                                                                                                                                   "\r
-               "\n                             hsl.x += 1.0;                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n                     else if (hsl.x > 1.0)                                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n                             hsl.x -= 1.0;                                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n             }                                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             return hsl;                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     float HueToRGB(float f1, float f2, float hue)                                                                                                                                                                                                                                                                                                                                      "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             if (hue < 0.0)                                                                                                                                                                                                                                                                                                                                                                                             "\r
-               "\n                     hue += 1.0;                                                                                                                                                                                                                                                                                                                                                                                                "\r
-               "\n             else if (hue > 1.0)                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     hue -= 1.0;                                                                                                                                                                                                                                                                                                                                                                                                "\r
-               "\n             float res;                                                                                                                                                                                                                                                                                                                                                                                                         "\r
-               "\n             if ((6.0 * hue) < 1.0)                                                                                                                                                                                                                                                                                                                                                                             "\r
-               "\n                     res = f1 + (f2 - f1) * 6.0 * hue;                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             else if ((2.0 * hue) < 1.0)                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     res = f2;                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             else if ((3.0 * hue) < 2.0)                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             else                                                                                                                                                                                                                                                                                                                                                                                                               "\r
-               "\n                     res = f1;                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             return res;                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 HSLToRGB(vec3 hsl)                                                                                                                                                                                                                                                                                                                                                                            "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 rgb;                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             if (hsl.y == 0.0)                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                     rgb = vec3(hsl.z);                                                                                                                                                                                                                                                                                                                                         "\r
-               "\n             else                                                                                                                                                                                                                                                                                                                                                                                                               "\r
-               "\n             {                                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                     float f2;                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     if (hsl.z < 0.5)                                                                                                                                                                                                                                                                                                                                                                                   "\r
-               "\n                             f2 = hsl.z * (1.0 + hsl.y);                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     else                                                                                                                                                                                                                                                                                                                                                                                                       "\r
-               "\n                             f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);                                                                                                                                                                                                                                                                                                                            "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     float f1 = 2.0 * hsl.z - f2;                                                                                                                                                                                                                                                                                                                                                       "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                     rgb.r = HueToRGB(f1, f2, hsl.x + (1.0/3.0));                                                                                                                                                                                                                                                                                                                       "\r
-               "\n                     rgb.g = HueToRGB(f1, f2, hsl.x);                                                                                                                                                                                                                                                                                                                                                   "\r
-               "\n                     rgb.b= HueToRGB(f1, f2, hsl.x - (1.0/3.0));                                                                                                                                                                                                                                                                                                                                "\r
-               "\n             }                                                                                                                                                                                                                                                                                                                                                                                                                          "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n             return rgb;                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                                "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Float blending modes                                                                                                                                                                                                                                                                                                                                                                            "\r
-               "\n     ** Adapted from here: http://www.nathanm.com/photoshop-blending-math/                                                                                                                                                                                                                                                                                      "\r
-               "\n     ** But I modified the HardMix (wrong condition), Overlay, SoftLight, ColorDodge, ColorBurn, VividLight, PinLight (inverted layers) ones to have correct results                                                                                            "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                             \n                                         "\r
-               "\n#define BlendLinearDodgef                                    BlendAddf                                                                                                                                                                                                                                                                               \n                                                 "\r
-               "\n#define BlendLinearBurnf                                     BlendSubstractf                                                                                                                                                                                                                                                                 \n                                                 "\r
-               "\n#define BlendAddf(base, blend)                               min(base + blend, 1.0)                                                                                                                                                                                                                                                  \n                                         "\r
-               "\n#define BlendSubstractf(base, blend)                 max(base + blend - 1.0, 0.0)                                                                                                                                                                                                                                    \n                                                 "\r
-               "\n#define BlendLightenf(base, blend)           max(blend, base)                                                                                                                                                                                                                                                                        \n                                 "\r
-               "\n#define BlendDarkenf(base, blend)                    min(blend, base)                                                                                                                                                                                                                                                                \n                                                 "\r
-               "\n#define BlendLinearLightf(base, blend)       (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5))))                                                                                          \n                                 "\r
-               "\n#define BlendScreenf(base, blend)                    (1.0 - ((1.0 - base) * (1.0 - blend)))                                                                                                                                                                                                                  \n                                                 "\r
-               "\n#define BlendOverlayf(base, blend)           (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))                                                                                                                                        \n                                         "\r
-               "\n#define BlendSoftLightf(base, blend)                 ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend)))    \n                                                 "\r
-               "\n#define BlendColorDodgef(base, blend)                ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0))                                                                                                                                                                               \n                                                 "\r
-               "\n#define BlendColorBurnf(base, blend)                 ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0))                                                                                                                                                             \n                                                 "\r
-               "\n#define BlendVividLightf(base, blend)                ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5))))                                                                                  \n                                                 "\r
-               "\n#define BlendPinLightf(base, blend)          ((blend < 0.5) ? BlendDarkenf(base, (2.0 * blend)) : BlendLightenf(base, (2.0 *(blend - 0.5))))                                                                                                         \n                                         "\r
-               "\n#define BlendHardMixf(base, blend)           ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0)                                                                                                                                                                                                     \n                                         "\r
-               "\n#define BlendReflectf(base, blend)           ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0))                                                                                                                                                                        \n                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n     ** Vector3 blending modes                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n#define Blend(base, blend, funcf)                    vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))                            \n                                                                                                                                                         "\r
-               "\n                                                                                                                                                                                                                                                                                     \n                                                                                                                                                 "\r
-               "\n#define BlendNormal(base, blend)                     (blend)                                                                                                                                                                         \n                                                                                                                                                         "\r
-               "\n#define BlendLighten                                         BlendLightenf                                                                                                                                                                   \n                                                                                                                                                         "\r
-               "\n#define BlendDarken                                          BlendDarkenf                                                                                                                                                                    \n                                                                                                                                                         "\r
-               "\n#define BlendMultiply(base, blend)           (base * blend)                                                                                                                                                                  \n                                                                                                                                         "\r
-               "\n#define BlendAverage(base, blend)                    ((base + blend) / 2.0)                                                                                                                                          \n                                                                                                                                                         "\r
-               "\n#define BlendAdd(base, blend)                                min(base + blend, vec3(1.0))                                                                                                                            \n                                                                                                                                                                 "\r
-               "\n#define BlendSubstract(base, blend)          max(base + blend - vec3(1.0), vec3(0.0))                                                                                                                \n                                                                                                                                                 "\r
-               "\n#define BlendDifference(base, blend)                 abs(base - blend)                                                                                                                                                       \n                                                                                                                                                         "\r
-               "\n#define BlendNegation(base, blend)           (vec3(1.0) - abs(vec3(1.0) - base - blend))                                                                                                             \n                                                                                                                                                 "\r
-               "\n#define BlendExclusion(base, blend)          (base + blend - 2.0 * base * blend)                                                                                                                             \n                                                                                                                                                 "\r
-               "\n#define BlendScreen(base, blend)                     Blend(base, blend, BlendScreenf)                                                                                                                        \n                                                                                                                                                         "\r
-               "\n#define BlendOverlay(base, blend)                    Blend(base, blend, BlendOverlayf)                                                                                                                       \n                                                                                                                                                         "\r
-               "\n#define BlendSoftLight(base, blend)          Blend(base, blend, BlendSoftLightf)                                                                                                                             \n                                                                                                                                                 "\r
-               "\n#define BlendHardLight(base, blend)          BlendOverlay(blend, base)                                                                                                                                               \n                                                                                                                                                 "\r
-               "\n#define BlendColorDodge(base, blend)                 Blend(base, blend, BlendColorDodgef)                                                                                                            \n                                                                                                                                                         "\r
-               "\n#define BlendColorBurn(base, blend)          Blend(base, blend, BlendColorBurnf)                                                                                                                             \n                                                                                                                                                 "\r
-               "\n#define BlendLinearDodge                                     BlendAdd                                                                                                                                                                                \n                                                                                                                                                         "\r
-               "\n#define BlendLinearBurn                                      BlendSubstract                                                                                                                                                                  \n                                                                                                                                                         "\r
-               "\n#define BlendLinearLight(base, blend)                Blend(base, blend, BlendLinearLightf)                                                                                                           \n                                                                                                                                                         "\r
-               "\n#define BlendVividLight(base, blend)                 Blend(base, blend, BlendVividLightf)                                                                                                            \n                                                                                                                                                         "\r
-               "\n#define BlendPinLight(base, blend)           Blend(base, blend, BlendPinLightf)                                                                                                                              \n                                                                                                                                         "\r
-               "\n#define BlendHardMix(base, blend)                    Blend(base, blend, BlendHardMixf)                                                                                                                       \n                                                                                                                                                         "\r
-               "\n#define BlendReflect(base, blend)                    Blend(base, blend, BlendReflectf)                                                                                                                       \n                                                                                                                                                         "\r
-               "\n#define BlendGlow(base, blend)                       BlendReflect(blend, base)                                                                                                                                               \n                                                                                                                                                 "\r
-               "\n#define BlendPhoenix(base, blend)                    (min(base, blend) - max(base, blend) + vec3(1.0))                                                                                       \n                                                                                                                                                         "\r
-               "\n#define BlendOpacity(base, blend, F, O)      (F(base, blend) * O + blend * (1.0 - O))                                                                                                                \n                                                                                                                                                         "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 BlendHue(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                                       "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 baseHSL = RGBToHSL(base);                                                                                                                                                                                                                                                                                                                                                             "\r
-               "\n             return HSLToRGB(vec3(RGBToHSL(blend).r, baseHSL.g, baseHSL.b));                                                                                                                                                                                                                                                                                            "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 BlendSaturation(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 baseHSL = RGBToHSL(base);                                                                                                                                                                                                                                                                                                                                                             "\r
-               "\n             return HSLToRGB(vec3(baseHSL.r, RGBToHSL(blend).g, baseHSL.b));                                                                                                                                                                                                                                                                                            "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 BlendColor(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                                     "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 blendHSL = RGBToHSL(blend);                                                                                                                                                                                                                                                                                                                                                           "\r
-               "\n             return HSLToRGB(vec3(blendHSL.r, blendHSL.g, RGBToHSL(base).b));                                                                                                                                                                                                                                                                                           "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     vec3 BlendLuminosity(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                        "\r
-               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n             vec3 baseHSL = RGBToHSL(base);                                                                                                                                                                                                                                                                                                                                                             "\r
-               "\n             return HSLToRGB(vec3(baseHSL.r, baseHSL.g, RGBToHSL(blend).b));                                                                                                                                                                                                                                                                                            "\r
-               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "\r
-               "\n                                                                                                                                                                                                                                                                                                                                                                                                        "\r
-               ;\r
-                                                                                                                                                                                                                                                                                                                                                                                                                                                  \r
-               return glsl;\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+static std::string get_adjustement_glsl()
+{
+       return                                                                                                                                                                                                                                                                                                                                                                                                                                          
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Contrast, saturation, brightness                                                                                                                                                                                                                                                                                                                                                              "
+               "\n     ** Code of this function is from TGM's shader pack                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057                                                                                                                                                                                                                                                                                                 "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con)                                                                                                                                                                                                                                                                     "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             const float AvgLumR = 0.5;                                                                                                                                                                                                                                                                                                                                                                         "
+               "\n             const float AvgLumG = 0.5;                                                                                                                                                                                                                                                                                                                                                                         "
+               "\n             const float AvgLumB = 0.5;                                                                                                                                                                                                                                                                                                                                                                         "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);                                                                                                                                                                                                                                                                                                                           "
+               "\n             vec3 brtColor = color * brt;                                                                                                                                                                                                                                                                                                                                                               "
+               "\n             vec3 intensity = vec3(dot(brtColor, LumCoeff));                                                                                                                                                                                                                                                                                                                            "
+               "\n             vec3 satColor = mix(intensity, brtColor, sat);                                                                                                                                                                                                                                                                                                                             "
+               "\n             vec3 conColor = mix(AvgLumin, satColor, con);                                                                                                                                                                                                                                                                                                                              "
+               "\n             return conColor;                                                                                                                                                                                                                                                                                                                                                                                           "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                       "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Gamma correction                                                                                                                                                                                                                                                                                                                                                                                                     "
+               "\n     ** Details: http://blog.mouaif.org/2009/01/22/photoshop-gamma-correction-shader/                                                                                                                                                                                                                                                                   "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n#define GammaCorrection(color, gamma)                                                                pow(color, vec3(1.0 / gamma))                           \n                                                                                                                                                                                                      "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Levels control (input (+gamma), output)                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Details: http://blog.mouaif.org/2009/01/28/levels-control-shader/                                                                                                                                                                                                                                                                                       "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n#define LevelsControlInputRange(color, minInput, maxInput)                           min(max(color - vec3(minInput), vec3(0.0)) / (vec3(maxInput) - vec3(minInput)), vec3(1.0))              \n                                                                                 "
+               "\n#define LevelsControlInput(color, minInput, gamma, maxInput)                         GammaCorrection(LevelsControlInputRange(color, minInput, maxInput), gamma)                                      \n                                                                                              "       
+               "\n#define LevelsControlOutputRange(color, minOutput, maxOutput)                        mix(vec3(minOutput), vec3(maxOutput), color)                                                                                                                    \n                                                                 "
+               "\n#define LevelsControl(color, minInput, gamma, maxInput, minOutput, maxOutput)        LevelsControlOutputRange(LevelsControlInput(color, minInput, gamma, maxInput), minOutput, maxOutput)    \n                                                      "
+               ;
+}
+
+static std::string get_blend_glsl()
+{
+       static std::string glsl = 
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Photoshop & misc math                                                                                                                                                                                                                                                                                                                                                                                   "
+               "\n     ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control                                                                                                                                                                                                                                                                                                     "
+               "\n     **                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Romain Dura | Romz                                                                                                                                                                                                                                                                                                                                                                                      "
+               "\n     ** Blog: http://blog.mouaif.org                                                                                                                                                                                                                                                                                                                                                            "
+               "\n     ** Post: http://blog.mouaif.org/?p=94                                                                                                                                                                                                                                                                                                                                                      "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Desaturation                                                                                                                                                                                                                                                                                                                                                                                            "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec4 Desaturate(vec3 color, float Desaturation)                                                                                                                                                                                                                                                                                                                            "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 grayXfer = vec3(0.3, 0.59, 0.11);                                                                                                                                                                                                                                                                                                                                             "
+               "\n             vec3 gray = vec3(dot(grayXfer, color));                                                                                                                                                                                                                                                                                                                                            "
+               "\n             return vec4(mix(color, gray, Desaturation), 1.0);                                                                                                                                                                                                                                                                                                                          "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Hue, saturation, luminance                                                                                                                                                                                                                                                                                                                                                                      "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 RGBToHSL(vec3 color)                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 hsl;                                                                                                                                                                                                                                                          "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             float fmin = min(min(color.r, color.g), color.b);                                                                                                                                                                                                                                                                  "
+               "\n             float fmax = max(max(color.r, color.g), color.b);                                                                                                                                                                                                                                                                  "
+               "\n             float delta = fmax - fmin;                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             hsl.z = (fmax + fmin) / 2.0;                                                                                                                                                                                                                                                                                                                       "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             if (delta == 0.0)                                                                                                                                                                                                                                                                                                                  "
+               "\n             {                                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                     hsl.x = 0.0;                                                                                                                                                                                                                                                                                                                                                               "
+               "\n                     hsl.y = 0.0;                                                                                                                                                                                                                                                                                                                                                       "
+               "\n             }                                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n             else                                                                                                                                                                                                                                                                                                                       "
+               "\n             {                                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                     if (hsl.z < 0.5)                                                                                                                                                                                                                                                                                                                                                                                   "
+               "\n                             hsl.y = delta / (fmax + fmin);                                                                                                                                                                                                                                                                                             "
+               "\n                     else                                                                                                                                                                                                                                                                                                                                                                                                       "
+               "\n                             hsl.y = delta / (2.0 - fmax - fmin);                                                                                                                                                                                                                                                                                               "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;                                                                                                                                                                                                                                                                                 "
+               "\n                     float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;                                                                                                                                                                                                                                                                                 "
+               "\n                     float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     if (color.r == fmax )                                                                                                                                                                                                                                                                                                                                                                      "
+               "\n                             hsl.x = deltaB - deltaG;                                                                                                                                                                                                                                                                                                                                   "
+               "\n                     else if (color.g == fmax)                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                             hsl.x = (1.0 / 3.0) + deltaR - deltaB;                                                                                                                                                                                                                                                                                                     "
+               "\n                     else if (color.b == fmax)                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                             hsl.x = (2.0 / 3.0) + deltaG - deltaR;                                                                                                                                                                                                                                                                                                     "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     if (hsl.x < 0.0)                                                                                                                                                                                                                                                                                                                                                                                   "
+               "\n                             hsl.x += 1.0;                                                                                                                                                                                                                                                                                                                                                      "
+               "\n                     else if (hsl.x > 1.0)                                                                                                                                                                                                                                                                                                                                                                      "
+               "\n                             hsl.x -= 1.0;                                                                                                                                                                                                                                                                                                                                                      "
+               "\n             }                                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             return hsl;                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     float HueToRGB(float f1, float f2, float hue)                                                                                                                                                                                                                                                                                                                                      "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             if (hue < 0.0)                                                                                                                                                                                                                                                                                                                                                                                             "
+               "\n                     hue += 1.0;                                                                                                                                                                                                                                                                                                                                                                                                "
+               "\n             else if (hue > 1.0)                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     hue -= 1.0;                                                                                                                                                                                                                                                                                                                                                                                                "
+               "\n             float res;                                                                                                                                                                                                                                                                                                                                                                                                         "
+               "\n             if ((6.0 * hue) < 1.0)                                                                                                                                                                                                                                                                                                                                                                             "
+               "\n                     res = f1 + (f2 - f1) * 6.0 * hue;                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             else if ((2.0 * hue) < 1.0)                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     res = f2;                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             else if ((3.0 * hue) < 2.0)                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;                                                                                                                                                                                                                                                                                                                  "
+               "\n             else                                                                                                                                                                                                                                                                                                                                                                                                               "
+               "\n                     res = f1;                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             return res;                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 HSLToRGB(vec3 hsl)                                                                                                                                                                                                                                                                                                                                                                            "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 rgb;                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             if (hsl.y == 0.0)                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                     rgb = vec3(hsl.z);                                                                                                                                                                                                                                                                                                                                         "
+               "\n             else                                                                                                                                                                                                                                                                                                                                                                                                               "
+               "\n             {                                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                     float f2;                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     if (hsl.z < 0.5)                                                                                                                                                                                                                                                                                                                                                                                   "
+               "\n                             f2 = hsl.z * (1.0 + hsl.y);                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     else                                                                                                                                                                                                                                                                                                                                                                                                       "
+               "\n                             f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);                                                                                                                                                                                                                                                                                                                            "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     float f1 = 2.0 * hsl.z - f2;                                                                                                                                                                                                                                                                                                                                                       "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                     rgb.r = HueToRGB(f1, f2, hsl.x + (1.0/3.0));                                                                                                                                                                                                                                                                                                                       "
+               "\n                     rgb.g = HueToRGB(f1, f2, hsl.x);                                                                                                                                                                                                                                                                                                                                                   "
+               "\n                     rgb.b= HueToRGB(f1, f2, hsl.x - (1.0/3.0));                                                                                                                                                                                                                                                                                                                                "
+               "\n             }                                                                                                                                                                                                                                                                                                                                                                                                                          "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n             return rgb;                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                                "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Float blending modes                                                                                                                                                                                                                                                                                                                                                                            "
+               "\n     ** Adapted from here: http://www.nathanm.com/photoshop-blending-math/                                                                                                                                                                                                                                                                                      "
+               "\n     ** But I modified the HardMix (wrong condition), Overlay, SoftLight, ColorDodge, ColorBurn, VividLight, PinLight (inverted layers) ones to have correct results                                                                                            "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                             \n                                         "
+               "\n#define BlendLinearDodgef                                    BlendAddf                                                                                                                                                                                                                                                                               \n                                                 "
+               "\n#define BlendLinearBurnf                                     BlendSubstractf                                                                                                                                                                                                                                                                 \n                                                 "
+               "\n#define BlendAddf(base, blend)                               min(base + blend, 1.0)                                                                                                                                                                                                                                                  \n                                         "
+               "\n#define BlendSubstractf(base, blend)                 max(base + blend - 1.0, 0.0)                                                                                                                                                                                                                                    \n                                                 "
+               "\n#define BlendLightenf(base, blend)           max(blend, base)                                                                                                                                                                                                                                                                        \n                                 "
+               "\n#define BlendDarkenf(base, blend)                    min(blend, base)                                                                                                                                                                                                                                                                \n                                                 "
+               "\n#define BlendLinearLightf(base, blend)       (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5))))                                                                                          \n                                 "
+               "\n#define BlendScreenf(base, blend)                    (1.0 - ((1.0 - base) * (1.0 - blend)))                                                                                                                                                                                                                  \n                                                 "
+               "\n#define BlendOverlayf(base, blend)           (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))                                                                                                                                        \n                                         "
+               "\n#define BlendSoftLightf(base, blend)                 ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend)))    \n                                                 "
+               "\n#define BlendColorDodgef(base, blend)                ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0))                                                                                                                                                                               \n                                                 "
+               "\n#define BlendColorBurnf(base, blend)                 ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0))                                                                                                                                                             \n                                                 "
+               "\n#define BlendVividLightf(base, blend)                ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5))))                                                                                  \n                                                 "
+               "\n#define BlendPinLightf(base, blend)          ((blend < 0.5) ? BlendDarkenf(base, (2.0 * blend)) : BlendLightenf(base, (2.0 *(blend - 0.5))))                                                                                                         \n                                         "
+               "\n#define BlendHardMixf(base, blend)           ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0)                                                                                                                                                                                                     \n                                         "
+               "\n#define BlendReflectf(base, blend)           ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0))                                                                                                                                                                        \n                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     /*                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n     ** Vector3 blending modes                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n     */                                                                                                                                                                                                                                                                                                                                                                                                                                 "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n#define Blend(base, blend, funcf)                    vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))                            \n                                                                                                                                                         "
+               "\n                                                                                                                                                                                                                                                                                     \n                                                                                                                                                 "
+               "\n#define BlendNormal(base, blend)                     (blend)                                                                                                                                                                         \n                                                                                                                                                         "
+               "\n#define BlendLighten                                         BlendLightenf                                                                                                                                                                   \n                                                                                                                                                         "
+               "\n#define BlendDarken                                          BlendDarkenf                                                                                                                                                                    \n                                                                                                                                                         "
+               "\n#define BlendMultiply(base, blend)           (base * blend)                                                                                                                                                                  \n                                                                                                                                         "
+               "\n#define BlendAverage(base, blend)                    ((base + blend) / 2.0)                                                                                                                                          \n                                                                                                                                                         "
+               "\n#define BlendAdd(base, blend)                                min(base + blend, vec3(1.0))                                                                                                                            \n                                                                                                                                                                 "
+               "\n#define BlendSubstract(base, blend)          max(base + blend - vec3(1.0), vec3(0.0))                                                                                                                \n                                                                                                                                                 "
+               "\n#define BlendDifference(base, blend)                 abs(base - blend)                                                                                                                                                       \n                                                                                                                                                         "
+               "\n#define BlendNegation(base, blend)           (vec3(1.0) - abs(vec3(1.0) - base - blend))                                                                                                             \n                                                                                                                                                 "
+               "\n#define BlendExclusion(base, blend)          (base + blend - 2.0 * base * blend)                                                                                                                             \n                                                                                                                                                 "
+               "\n#define BlendScreen(base, blend)                     Blend(base, blend, BlendScreenf)                                                                                                                        \n                                                                                                                                                         "
+               "\n#define BlendOverlay(base, blend)                    Blend(base, blend, BlendOverlayf)                                                                                                                       \n                                                                                                                                                         "
+               "\n#define BlendSoftLight(base, blend)          Blend(base, blend, BlendSoftLightf)                                                                                                                             \n                                                                                                                                                 "
+               "\n#define BlendHardLight(base, blend)          BlendOverlay(blend, base)                                                                                                                                               \n                                                                                                                                                 "
+               "\n#define BlendColorDodge(base, blend)                 Blend(base, blend, BlendColorDodgef)                                                                                                            \n                                                                                                                                                         "
+               "\n#define BlendColorBurn(base, blend)          Blend(base, blend, BlendColorBurnf)                                                                                                                             \n                                                                                                                                                 "
+               "\n#define BlendLinearDodge                                     BlendAdd                                                                                                                                                                                \n                                                                                                                                                         "
+               "\n#define BlendLinearBurn                                      BlendSubstract                                                                                                                                                                  \n                                                                                                                                                         "
+               "\n#define BlendLinearLight(base, blend)                Blend(base, blend, BlendLinearLightf)                                                                                                           \n                                                                                                                                                         "
+               "\n#define BlendVividLight(base, blend)                 Blend(base, blend, BlendVividLightf)                                                                                                            \n                                                                                                                                                         "
+               "\n#define BlendPinLight(base, blend)           Blend(base, blend, BlendPinLightf)                                                                                                                              \n                                                                                                                                         "
+               "\n#define BlendHardMix(base, blend)                    Blend(base, blend, BlendHardMixf)                                                                                                                       \n                                                                                                                                                         "
+               "\n#define BlendReflect(base, blend)                    Blend(base, blend, BlendReflectf)                                                                                                                       \n                                                                                                                                                         "
+               "\n#define BlendGlow(base, blend)                       BlendReflect(blend, base)                                                                                                                                               \n                                                                                                                                                 "
+               "\n#define BlendPhoenix(base, blend)                    (min(base, blend) - max(base, blend) + vec3(1.0))                                                                                       \n                                                                                                                                                         "
+               "\n#define BlendOpacity(base, blend, F, O)      (F(base, blend) * O + blend * (1.0 - O))                                                                                                                \n                                                                                                                                                         "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 BlendHue(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                                       "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 baseHSL = RGBToHSL(base);                                                                                                                                                                                                                                                                                                                                                             "
+               "\n             return HSLToRGB(vec3(RGBToHSL(blend).r, baseHSL.g, baseHSL.b));                                                                                                                                                                                                                                                                                            "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 BlendSaturation(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                        "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 baseHSL = RGBToHSL(base);                                                                                                                                                                                                                                                                                                                                                             "
+               "\n             return HSLToRGB(vec3(baseHSL.r, RGBToHSL(blend).g, baseHSL.b));                                                                                                                                                                                                                                                                                            "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 BlendColor(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                                     "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 blendHSL = RGBToHSL(blend);                                                                                                                                                                                                                                                                                                                                                           "
+               "\n             return HSLToRGB(vec3(blendHSL.r, blendHSL.g, RGBToHSL(base).b));                                                                                                                                                                                                                                                                                           "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                                                        "
+               "\n     vec3 BlendLuminosity(vec3 base, vec3 blend)                                                                                                                                                                                                                                                                                                                                        "
+               "\n     {                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n             vec3 baseHSL = RGBToHSL(base);                                                                                                                                                                                                                                                                                                                                                             "
+               "\n             return HSLToRGB(vec3(baseHSL.r, baseHSL.g, RGBToHSL(blend).b));                                                                                                                                                                                                                                                                                            "
+               "\n     }                                                                                                                                                                                                                                                                                                                                                                                                                                  "
+               "\n                                                                                                                                                                                                                                                                                                                                                                                                        "
+               ;
+                                                                                                                                                                                                                                                                                                                                                                                                                                                  
+               return glsl;
 }
\ No newline at end of file