]> git.sesse.net Git - casparcg/commitdiff
Used raw string literals for shader code and regexes.
authorHelge Norberg <helge.norberg@svt.se>
Fri, 13 Feb 2015 09:34:03 +0000 (10:34 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Fri, 13 Feb 2015 09:34:03 +0000 (10:34 +0100)
TODO: timed waiting on deferred futures does not work.

accelerator/ogl/image/blending_glsl.h
accelerator/ogl/image/image_shader.cpp
common/tweener.cpp
modules/ffmpeg/consumer/ffmpeg_consumer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/flash/producer/cg_proxy.cpp
protocol/amcp/AMCPCommandsImpl.cpp

index 7ccaf40e81f7b0b8f569323408eb89e1bd08a8b7..2d5635de8185959cb5cdfcc0b71fcb25762e3196 100644 (file)
 
 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                                                      "
-               ;
+       return R"shader(
+                       /*
+                       ** Contrast, saturation, brightness
+                       ** Code of this function is from TGM's shader pack
+                       ** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
+                       */
+
+                       vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con)
+                       {
+                               const float AvgLumR = 0.5;
+                               const float AvgLumG = 0.5;
+                               const float AvgLumB = 0.5;
+
+                               const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
+
+                               vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
+                               vec3 brtColor = color * brt;
+                               vec3 intensity = vec3(dot(brtColor, LumCoeff));
+                               vec3 satColor = mix(intensity, brtColor, sat);
+                               vec3 conColor = mix(AvgLumin, satColor, con);
+                               return conColor;
+                       }
+
+                       /*
+                       ** Gamma correction
+                       ** Details: http://blog.mouaif.org/2009/01/22/photoshop-gamma-correction-shader/
+                       */
+                       #define GammaCorrection(color, gamma)                                                           pow(color, vec3(1.0 / gamma))
+
+                       /*
+                       ** Levels control (input (+gamma), output)
+                       ** Details: http://blog.mouaif.org/2009/01/28/levels-control-shader/
+                       */
+
+                       #define LevelsControlInputRange(color, minInput, maxInput)                              min(max(color - vec3(minInput), vec3(0.0)) / (vec3(maxInput) - vec3(minInput)), vec3(1.0))
+                       #define LevelsControlInput(color, minInput, gamma, maxInput)                            GammaCorrection(LevelsControlInputRange(color, minInput, maxInput), gamma)
+                       #define LevelsControlOutputRange(color, minOutput, maxOutput)                   mix(vec3(minOutput), vec3(maxOutput), color)
+                       #define LevelsControl(color, minInput, gamma, maxInput, minOutput, maxOutput)   LevelsControlOutputRange(LevelsControlInput(color, minInput, gamma, maxInput), minOutput, maxOutput)
+       )shader";
 }
 
 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
+       static std::string glsl = R"shader(
+                       /*
+                       ** Photoshop & misc math
+                       ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
+                       **
+                       ** Romain Dura | Romz
+                       ** Blog: http://blog.mouaif.org
+                       ** Post: http://blog.mouaif.org/?p=94
+                       */
+
+
+                       /*
+                       ** Desaturation
+                       */
+
+                       vec4 Desaturate(vec3 color, float Desaturation)
+                       {
+                               vec3 grayXfer = vec3(0.3, 0.59, 0.11);
+                               vec3 gray = vec3(dot(grayXfer, color));
+                               return vec4(mix(color, gray, Desaturation), 1.0);
+                       }
+
+
+                       /*
+                       ** Hue, saturation, luminance
+                       */
+
+                       vec3 RGBToHSL(vec3 color)
+                       {
+                               vec3 hsl;
+
+                               float fmin = min(min(color.r, color.g), color.b);
+                               float fmax = max(max(color.r, color.g), color.b);
+                               float delta = fmax - fmin;
+
+                               hsl.z = (fmax + fmin) / 2.0;
+
+                               if (delta == 0.0)
+                               {
+                                       hsl.x = 0.0;
+                                       hsl.y = 0.0;
+                               }
+                               else
+                               {
+                                       if (hsl.z < 0.5)
+                                               hsl.y = delta / (fmax + fmin);
+                                       else
+                                               hsl.y = delta / (2.0 - fmax - fmin);
+
+                                       float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;
+                                       float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;
+                                       float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;
+
+                                       if (color.r == fmax )
+                                               hsl.x = deltaB - deltaG;
+                                       else if (color.g == fmax)
+                                               hsl.x = (1.0 / 3.0) + deltaR - deltaB;
+                                       else if (color.b == fmax)
+                                               hsl.x = (2.0 / 3.0) + deltaG - deltaR;
+
+                                       if (hsl.x < 0.0)
+                                               hsl.x += 1.0;
+                                       else if (hsl.x > 1.0)
+                                               hsl.x -= 1.0;
+                               }
+
+                               return hsl;
+                       }
+
+                       float HueToRGB(float f1, float f2, float hue)
+                       {
+                               if (hue < 0.0)
+                                       hue += 1.0;
+                               else if (hue > 1.0)
+                                       hue -= 1.0;
+                               float res;
+                               if ((6.0 * hue) < 1.0)
+                                       res = f1 + (f2 - f1) * 6.0 * hue;
+                               else if ((2.0 * hue) < 1.0)
+                                       res = f2;
+                               else if ((3.0 * hue) < 2.0)
+                                       res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;
+                               else
+                                       res = f1;
+                               return res;
+                       }
+
+                       vec3 HSLToRGB(vec3 hsl)
+                       {
+                               vec3 rgb;
+
+                               if (hsl.y == 0.0)
+                                       rgb = vec3(hsl.z);
+                               else
+                               {
+                                       float f2;
+
+                                       if (hsl.z < 0.5)
+                                               f2 = hsl.z * (1.0 + hsl.y);
+                                       else
+                                               f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);
+
+                                       float f1 = 2.0 * hsl.z - f2;
+
+                                       rgb.r = HueToRGB(f1, f2, hsl.x + (1.0/3.0));
+                                       rgb.g = HueToRGB(f1, f2, hsl.x);
+                                       rgb.b= HueToRGB(f1, f2, hsl.x - (1.0/3.0));
+                               }
+
+                               return rgb;
+                       }
+
+
+
+
+                       /*
+                       ** Float blending modes
+                       ** Adapted from here: http://www.nathanm.com/photoshop-blending-math/
+                       ** But I modified the HardMix (wrong condition), Overlay, SoftLight, ColorDodge, ColorBurn, VividLight, PinLight (inverted layers) ones to have correct results
+                       */
+
+                       #define BlendLinearDodgef                                       BlendAddf
+                       #define BlendLinearBurnf                                        BlendSubstractf
+                       #define BlendAddf(base, blend)                          min(base + blend, 1.0)
+                       #define BlendSubstractf(base, blend)            max(base + blend - 1.0, 0.0)
+                       #define BlendLightenf(base, blend)              max(blend, base)
+                       #define BlendDarkenf(base, blend)                       min(blend, base)
+                       #define BlendLinearLightf(base, blend)  (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5))))
+                       #define BlendScreenf(base, blend)                       (1.0 - ((1.0 - base) * (1.0 - blend)))
+                       #define BlendOverlayf(base, blend)              (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
+                       #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)))
+                       #define BlendColorDodgef(base, blend)           ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0))
+                       #define BlendColorBurnf(base, blend)            ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0))
+                       #define BlendVividLightf(base, blend)           ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5))))
+                       #define BlendPinLightf(base, blend)             ((blend < 0.5) ? BlendDarkenf(base, (2.0 * blend)) : BlendLightenf(base, (2.0 *(blend - 0.5))))
+                       #define BlendHardMixf(base, blend)              ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0)
+                       #define BlendReflectf(base, blend)              ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0))
+
+
+                       /*
+                       ** Vector3 blending modes
+                       */
+
+                       #define Blend(base, blend, funcf)                       vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
+
+                       #define BlendNormal(base, blend)                        (blend)
+                       #define BlendLighten                                            BlendLightenf
+                       #define BlendDarken                                             BlendDarkenf
+                       #define BlendMultiply(base, blend)              (base * blend)
+                       #define BlendAverage(base, blend)                       ((base + blend) / 2.0)
+                       #define BlendAdd(base, blend)                           min(base + blend, vec3(1.0))
+                       #define BlendSubstract(base, blend)             max(base + blend - vec3(1.0), vec3(0.0))
+                       #define BlendDifference(base, blend)            abs(base - blend)
+                       #define BlendNegation(base, blend)              (vec3(1.0) - abs(vec3(1.0) - base - blend))
+                       #define BlendExclusion(base, blend)             (base + blend - 2.0 * base * blend)
+                       #define BlendScreen(base, blend)                        Blend(base, blend, BlendScreenf)
+                       #define BlendOverlay(base, blend)                       Blend(base, blend, BlendOverlayf)
+                       #define BlendSoftLight(base, blend)             Blend(base, blend, BlendSoftLightf)
+                       #define BlendHardLight(base, blend)             BlendOverlay(blend, base)
+                       #define BlendColorDodge(base, blend)            Blend(base, blend, BlendColorDodgef)
+                       #define BlendColorBurn(base, blend)             Blend(base, blend, BlendColorBurnf)
+                       #define BlendLinearDodge                                        BlendAdd
+                       #define BlendLinearBurn                                 BlendSubstract
+                       #define BlendLinearLight(base, blend)           Blend(base, blend, BlendLinearLightf)
+                       #define BlendVividLight(base, blend)            Blend(base, blend, BlendVividLightf)
+                       #define BlendPinLight(base, blend)              Blend(base, blend, BlendPinLightf)
+                       #define BlendHardMix(base, blend)                       Blend(base, blend, BlendHardMixf)
+                       #define BlendReflect(base, blend)                       Blend(base, blend, BlendReflectf)
+                       #define BlendGlow(base, blend)                  BlendReflect(blend, base)
+                       #define BlendPhoenix(base, blend)                       (min(base, blend) - max(base, blend) + vec3(1.0))
+                       #define BlendOpacity(base, blend, F, O)         (F(base, blend) * O + blend * (1.0 - O))
+
+
+                       vec3 BlendHue(vec3 base, vec3 blend)
+                       {
+                               vec3 baseHSL = RGBToHSL(base);
+                               return HSLToRGB(vec3(RGBToHSL(blend).r, baseHSL.g, baseHSL.b));
+                       }
+
+                       vec3 BlendSaturation(vec3 base, vec3 blend)
+                       {
+                               vec3 baseHSL = RGBToHSL(base);
+                               return HSLToRGB(vec3(baseHSL.r, RGBToHSL(blend).g, baseHSL.b));
+                       }
+
+                       vec3 BlendColor(vec3 base, vec3 blend)
+                       {
+                               vec3 blendHSL = RGBToHSL(blend);
+                               return HSLToRGB(vec3(blendHSL.r, blendHSL.g, RGBToHSL(base).b));
+                       }
+
+                       vec3 BlendLuminosity(vec3 base, vec3 blend)
+                       {
+                               vec3 baseHSL = RGBToHSL(base);
+                               return HSLToRGB(vec3(baseHSL.r, baseHSL.g, RGBToHSL(blend).b));
+                       }
+
+       )shader";
+
+       return glsl;
+}
index 56bee09c0ad7d184e2b43c2a5b1af241f20f008a..e2a2e177e302d622efb55c9d481f7e8f4bbdb09b 100644 (file)
@@ -41,234 +41,241 @@ bool                                      g_blend_modes = false;
 
 std::string get_blend_color_func()
 {
-       return 
-                       
-       get_adjustement_glsl()
-               
-       +
+       return
 
-       get_blend_glsl()
-               
-       +
-                       
-       "vec3 get_blend_color(vec3 back, vec3 fore)                                                                                     \n"
-       "{                                                                                                                                                                      \n"
-       "       switch(blend_mode)                                                                                                                              \n"
-       "       {                                                                                                                                                               \n"
-       "       case  0: return BlendNormal(back, fore);                                                                                \n"
-       "       case  1: return BlendLighten(back, fore);                                                                               \n"
-       "       case  2: return BlendDarken(back, fore);                                                                                \n"
-       "       case  3: return BlendMultiply(back, fore);                                                                              \n"
-       "       case  4: return BlendAverage(back, fore);                                                                               \n"
-       "       case  5: return BlendAdd(back, fore);                                                                                   \n"
-       "       case  6: return BlendSubstract(back, fore);                                                                             \n"
-       "       case  7: return BlendDifference(back, fore);                                                                    \n"
-       "       case  8: return BlendNegation(back, fore);                                                                              \n"
-       "       case  9: return BlendExclusion(back, fore);                                                                             \n"
-       "       case 10: return BlendScreen(back, fore);                                                                                \n"
-       "       case 11: return BlendOverlay(back, fore);                                                                               \n"
-       //"     case 12: return BlendSoftLight(back, fore);                                                                             \n"
-       "       case 13: return BlendHardLight(back, fore);                                                                             \n"
-       "       case 14: return BlendColorDodge(back, fore);                                                                    \n"
-       "       case 15: return BlendColorBurn(back, fore);                                                                             \n"
-       "       case 16: return BlendLinearDodge(back, fore);                                                                   \n"
-       "       case 17: return BlendLinearBurn(back, fore);                                                                    \n"
-       "       case 18: return BlendLinearLight(back, fore);                                                                   \n"
-       "       case 19: return BlendVividLight(back, fore);                                                                    \n"
-       "       case 20: return BlendPinLight(back, fore);                                                                              \n"
-       "       case 21: return BlendHardMix(back, fore);                                                                               \n"
-       "       case 22: return BlendReflect(back, fore);                                                                               \n"
-       "       case 23: return BlendGlow(back, fore);                                                                                  \n"
-       "       case 24: return BlendPhoenix(back, fore);                                                                               \n"
-       "       case 25: return BlendHue(back, fore);                                                                                   \n"
-       "       case 26: return BlendSaturation(back, fore);                                                                    \n"
-       "       case 27: return BlendColor(back, fore);                                                                                 \n"
-       "       case 28: return BlendLuminosity(back, fore);                                                                    \n"
-       "       }                                                                                                                                                               \n"
-       "       return BlendNormal(back, fore);                                                                                                 \n"
-       "}                                                                                                                                                                      \n"
-       "                                                                                                                                                                       \n"                                                                                                                                                       
-       "vec4 blend(vec4 fore)                                                                                                                          \n"
-       "{                                                                                                                                                                      \n"
-       "   vec4 back = texture2D(background, gl_TexCoord[1].st).bgra;                                          \n"
-       "   if(blend_mode != 0)                                                                                                                         \n"
-       "               fore.rgb = get_blend_color(back.rgb/(back.a+0.0000001), fore.rgb/(fore.a+0.0000001))*fore.a;\n"
-       "       switch(keyer)                                                                                                                                   \n"     
-       "       {                                                                                                                                                               \n"     
-       "               case 1:  return fore + back; // additive                                                                        \n"
-       "               default: return fore + (1.0-fore.a)*back; // linear                                                     \n"
-       "       }                                                                                                                                                               \n"
-       "}                                                                                                                                                                      \n";                    
+               get_adjustement_glsl()
+
+               +
+
+               get_blend_glsl()
+
+               +
+
+               R"shader(
+                               vec3 get_blend_color(vec3 back, vec3 fore)
+                               {
+                                       switch(blend_mode)
+                                       {
+                                       case  0: return BlendNormal(back, fore);
+                                       case  1: return BlendLighten(back, fore);
+                                       case  2: return BlendDarken(back, fore);
+                                       case  3: return BlendMultiply(back, fore);
+                                       case  4: return BlendAverage(back, fore);
+                                       case  5: return BlendAdd(back, fore);
+                                       case  6: return BlendSubstract(back, fore);
+                                       case  7: return BlendDifference(back, fore);
+                                       case  8: return BlendNegation(back, fore);
+                                       case  9: return BlendExclusion(back, fore);
+                                       case 10: return BlendScreen(back, fore);
+                                       case 11: return BlendOverlay(back, fore);
+                               //      case 12: return BlendSoftLight(back, fore);
+                                       case 13: return BlendHardLight(back, fore);
+                                       case 14: return BlendColorDodge(back, fore);
+                                       case 15: return BlendColorBurn(back, fore);
+                                       case 16: return BlendLinearDodge(back, fore);
+                                       case 17: return BlendLinearBurn(back, fore);
+                                       case 18: return BlendLinearLight(back, fore);
+                                       case 19: return BlendVividLight(back, fore);
+                                       case 20: return BlendPinLight(back, fore);
+                                       case 21: return BlendHardMix(back, fore);
+                                       case 22: return BlendReflect(back, fore);
+                                       case 23: return BlendGlow(back, fore);
+                                       case 24: return BlendPhoenix(back, fore);
+                                       case 25: return BlendHue(back, fore);
+                                       case 26: return BlendSaturation(back, fore);
+                                       case 27: return BlendColor(back, fore);
+                                       case 28: return BlendLuminosity(back, fore);
+                                       }
+                                       return BlendNormal(back, fore);
+                               }
+
+                               vec4 blend(vec4 fore)
+                               {
+                                  vec4 back = texture2D(background, gl_TexCoord[1].st).bgra;
+                                  if(blend_mode != 0)
+                                               fore.rgb = get_blend_color(back.rgb/(back.a+0.0000001), fore.rgb/(fore.a+0.0000001))*fore.a;
+                                       switch(keyer)
+                                       {
+                                               case 1:  return fore + back; // additive
+                                               default: return fore + (1.0-fore.a)*back; // linear
+                                       }
+                               }
+               )shader";
 }
                
 std::string get_simple_blend_color_func()
 {
-       return  
-               
-       get_adjustement_glsl()
-                       
-       +
+       return
+
+               get_adjustement_glsl()
 
-       "vec4 blend(vec4 fore)                                                                                                                          \n"
-       "{                                                                                                                                                                      \n"
-       "       return fore;                                                                                                                                    \n"
-       "}                                                                                                                                                                      \n";
+               +
+
+               R"shader(
+                               vec4 blend(vec4 fore)
+                               {
+                                       return fore;
+                               }
+               )shader";
 }
 
 std::string get_vertex()
 {
-       return 
-
-       "void main()                                                                                                                                            \n"
-       "{                                                                                                                                                                      \n"
-       "       gl_TexCoord[0] = gl_MultiTexCoord0;                                                                                             \n"
-//     "       gl_TexCoord[1] = gl_MultiTexCoord1;                                                                                             \n"
-       "       vec4 pos = ftransform();                                                                                                                \n"
-       "       gl_TexCoord[1] = vec4(pos.xy, 0.0, 0.0);                                                                                \n"
-       "       pos.x = pos.x*2.0 - 1.0;                                                                                                                \n"
-       "       pos.y = pos.y*2.0 - 1.0;                                                                                                                \n"
-       "       gl_Position    = pos;                                                                                                                   \n"
-       "}                                                                                                                                                                      \n";
+       return R"shader(
+                       void main()
+                       {
+                               gl_TexCoord[0] = gl_MultiTexCoord0;
+                       //      gl_TexCoord[1] = gl_MultiTexCoord1;
+                               vec4 pos = ftransform();
+                               gl_TexCoord[1] = vec4(pos.xy, 0.0, 0.0);
+                               pos.x = pos.x*2.0 - 1.0;
+                               pos.y = pos.y*2.0 - 1.0;
+                               gl_Position    = pos;
+                       }
+       )shader";
 }
 
 std::string get_fragment(bool blend_modes)
 {
-       return
+       return R"shader(
+
+                       #version 130
+                       uniform sampler2D       background;
+                       uniform sampler2D       plane[4];
+                       uniform vec2            plane_size[4];
+                       uniform sampler2D       local_key;
+                       uniform sampler2D       layer_key;
 
-       "#version 130                                                                                                                                           \n"
-       "uniform sampler2D      background;                                                                                                             \n"
-       "uniform sampler2D      plane[4];                                                                                                               \n"
-       "uniform vec2           plane_size[4];                                                                                                  \n"
-       "uniform sampler2D      local_key;                                                                                                              \n"
-       "uniform sampler2D      layer_key;                                                                                                              \n"
-       "                                                                                                                                                                       \n"
-       "uniform bool           is_hd;                                                                                                                  \n"
-       "uniform bool           has_local_key;                                                                                                  \n"
-       "uniform bool           has_layer_key;                                                                                                  \n"
-       "uniform int            blend_mode;                                                                                                             \n"
-       "uniform int            keyer;                                                                                                                  \n"
-       "uniform int            pixel_format;                                                                                                   \n"
-       "uniform int            deinterlace;                                                                                                    \n"
-       "                                                                                                                                                                       \n"
-       "uniform float          opacity;                                                                                                                \n"
-       "uniform bool           levels;                                                                                                                 \n"
-       "uniform float          min_input;                                                                                                              \n"
-       "uniform float          max_input;                                                                                                              \n"
-       "uniform float          gamma;                                                                                                                  \n"
-       "uniform float          min_output;                                                                                                             \n"
-       "uniform float          max_output;                                                                                                             \n"
-       "                                                                                                                                                                       \n"
-       "uniform bool           csb;                                                                                                                    \n"
-       "uniform float          brt;                                                                                                                    \n"
-       "uniform float          sat;                                                                                                                    \n"
-       "uniform float          con;                                                                                                                    \n"
-       "                                                                                                                                                                       \n"     
+                       uniform bool            is_hd;
+                       uniform bool            has_local_key;
+                       uniform bool            has_layer_key;
+                       uniform int                     blend_mode;
+                       uniform int                     keyer;
+                       uniform int                     pixel_format;
+                       uniform int                     deinterlace;
+
+                       uniform float           opacity;
+                       uniform bool            levels;
+                       uniform float           min_input;
+                       uniform float           max_input;
+                       uniform float           gamma;
+                       uniform float           min_output;
+                       uniform float           max_output;
+
+                       uniform bool            csb;
+                       uniform float           brt;
+                       uniform float           sat;
+                       uniform float           con;
+
+       )shader"
 
        +
-               
+
        (blend_modes ? get_blend_color_func() : get_simple_blend_color_func())
 
        +
-       
-       "                                                                                                                                                                       \n"
-       "vec4 ycbcra_to_rgba_sd(float Y, float Cb, float Cr, float A)                                           \n"
-       "{                                                                                                                                                                      \n"
-       "   vec4 rgba;                                                                                                                                          \n"
-       "   rgba.b = (1.164*(Y*255 - 16) + 1.596*(Cr*255 - 128))/255;                                           \n"
-       "   rgba.g = (1.164*(Y*255 - 16) - 0.813*(Cr*255 - 128) - 0.391*(Cb*255 - 128))/255;\n"
-       "   rgba.r = (1.164*(Y*255 - 16) + 2.018*(Cb*255 - 128))/255;                                           \n"
-       "   rgba.a = A;                                                                                                                                         \n"
-       "       return rgba;                                                                                                                                    \n"     
-       "}                                                                                                                                                                      \n"                     
-       "                                                                                                                                                                       \n"
-       "vec4 ycbcra_to_rgba_hd(float Y, float Cb, float Cr, float A)                                           \n"
-       "{                                                                                                                                                                      \n"
-       "   vec4 rgba;                                                                                                                                          \n"
-       "   rgba.b = (1.164*(Y*255 - 16) + 1.793*(Cr*255 - 128))/255;                                           \n"
-       "   rgba.g = (1.164*(Y*255 - 16) - 0.534*(Cr*255 - 128) - 0.213*(Cb*255 - 128))/255;\n"
-       "   rgba.r = (1.164*(Y*255 - 16) + 2.115*(Cb*255 - 128))/255;                                           \n"
-       "   rgba.a = A;                                                                                                                                         \n"
-       "       return rgba;                                                                                                                                    \n"
-       "}                                                                                                                                                                      \n"                                     
-       "                                                                                                                                                                       \n"             
-       "vec4 ycbcra_to_rgba(float y, float cb, float cr, float a)                                                      \n"
-       "{                                                                                                                                                                      \n"
-       "       if(is_hd)                                                                                                                                               \n"
-       "               return ycbcra_to_rgba_hd(y, cb, cr, a);                                                                         \n"
-       "       else                                                                                                                                                    \n"
-       "               return ycbcra_to_rgba_sd(y, cb, cr, a);                                                                         \n"
-       "}                                                                                                                                                                      \n"
-       "                                                                                                                                                                       \n"
-       "vec4 get_sample(sampler2D sampler, vec2 coords, vec2 size)                                                     \n"
-       "{                                                                                                                                                                      \n"
-       "       switch(deinterlace)                                                                                                                             \n"
-       "       {                                                                                                                                                               \n"
-       "       case 1: // upper                                                                                                                                \n"
-       "               return texture2D(sampler, coords);                                                                                      \n"
-       "       case 2: // lower                                                                                                                                \n"
-       "               return texture2D(sampler, coords);                                                                                      \n"
-       "       default:                                                                                                                                                \n"
-       "               return texture2D(sampler, coords);                                                                                      \n"
-       "       }                                                                                                                                                               \n"
-       "}                                                                                                                                                                      \n"
-       "                                                                                                                                                                       \n"
-       "vec4 get_rgba_color()                                                                                                                          \n"
-       "{                                                                                                                                                                      \n"
-       "       switch(pixel_format)                                                                                                                    \n"
-       "       {                                                                                                                                                               \n"
-       "       case 0:         //gray                                                                                                                          \n"
-       "               return vec4(get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rrr, 1.0);\n"
-       "       case 1:         //bgra,                                                                                                                         \n"
-       "               return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).bgra;                     \n"
-       "       case 2:         //rgba,                                                                                                                         \n"
-       "               return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rgba;                     \n"
-       "       case 3:         //argb,                                                                                                                         \n"
-       "               return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).argb;                     \n"
-       "       case 4:         //abgr,                                                                                                                         \n"
-       "               return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).gbar;                     \n"
-       "       case 5:         //ycbcr,                                                                                                                        \n"
-       "               {                                                                                                                                                       \n"
-       "                       float y  = get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       float cb = get_sample(plane[1], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       float cr = get_sample(plane[2], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       return ycbcra_to_rgba(y, cb, cr, 1.0);                                                                  \n"
-       "               }                                                                                                                                                       \n"
-       "       case 6:         //ycbcra                                                                                                                        \n"
-       "               {                                                                                                                                                       \n"
-       "                       float y  = get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       float cb = get_sample(plane[1], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       float cr = get_sample(plane[2], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       float a  = get_sample(plane[3], gl_TexCoord[0].st, plane_size[0]).r;    \n"
-       "                       return ycbcra_to_rgba(y, cb, cr, a);                                                                    \n"
-       "               }                                                                                                                                                       \n"
-       "       case 7:         //luma                                                                                                                          \n"
-       "               {                                                                                                                                                       \n"
-       "                       vec3 y3 = get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rrr;   \n"
-       "                       return vec4((y3-0.065)/0.859, 1.0);                                                                             \n"
-       "               }                                                                                                                                                       \n"
-       "       case 8:         //bgr,                                                                                                                          \n"
-       "               return vec4(get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).bgr, 1.0);\n"
-       "       case 9:         //rgb,                                                                                                                          \n"
-       "               return vec4(get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rgb, 1.0);\n"
-       "       }                                                                                                                                                               \n"
-       "       return vec4(0.0, 0.0, 0.0, 0.0);                                                                                                \n"
-       "}                                                                                                                                                                      \n"
-       "                                                                                                                                                                       \n"
-       "void main()                                                                                                                                            \n"
-       "{                                                                                                                                                                      \n"
-       "       vec4 color = get_rgba_color();                                                                                                  \n"
-       "   if(levels)                                                                                                                                          \n"
-       "               color.rgb = LevelsControl(color.rgb, min_input, gamma, max_input, min_output, max_output); \n"
-       "       if(csb)                                                                                                                                                 \n"
-       "               color.rgb = ContrastSaturationBrightness(color.rgb, brt, sat, con);                     \n"
-       "       if(has_local_key)                                                                                                                               \n"
-       "               color *= texture2D(local_key, gl_TexCoord[1].st).r;                                                     \n"
-       "       if(has_layer_key)                                                                                                                               \n"
-       "               color *= texture2D(layer_key, gl_TexCoord[1].st).r;                                                     \n"
-       "       color *= opacity;                                                                                                                               \n"
-       "       color = blend(color);                                                                                                                   \n"
-       "       gl_FragColor = color.bgra;                                                                                                              \n"
-       "}                                                                                                                                                                      \n";
+
+       R"shader(
+
+                       vec4 ycbcra_to_rgba_sd(float Y, float Cb, float Cr, float A)
+                       {
+                               vec4 rgba;
+                               rgba.b = (1.164*(Y*255 - 16) + 1.596*(Cr*255 - 128))/255;
+                               rgba.g = (1.164*(Y*255 - 16) - 0.813*(Cr*255 - 128) - 0.391*(Cb*255 - 128))/255;
+                               rgba.r = (1.164*(Y*255 - 16) + 2.018*(Cb*255 - 128))/255;
+                               rgba.a = A;
+                               return rgba;
+                       }
+
+                       vec4 ycbcra_to_rgba_hd(float Y, float Cb, float Cr, float A)
+                       {
+                               vec4 rgba;
+                               rgba.b = (1.164*(Y*255 - 16) + 1.793*(Cr*255 - 128))/255;
+                               rgba.g = (1.164*(Y*255 - 16) - 0.534*(Cr*255 - 128) - 0.213*(Cb*255 - 128))/255;
+                               rgba.r = (1.164*(Y*255 - 16) + 2.115*(Cb*255 - 128))/255;
+                               rgba.a = A;
+                               return rgba;
+                       }
+
+                       vec4 ycbcra_to_rgba(float y, float cb, float cr, float a)
+                       {
+                               if(is_hd)
+                                       return ycbcra_to_rgba_hd(y, cb, cr, a);
+                               else
+                                       return ycbcra_to_rgba_sd(y, cb, cr, a);
+                       }
+
+                       vec4 get_sample(sampler2D sampler, vec2 coords, vec2 size)
+                       {
+                               switch(deinterlace)
+                               {
+                               case 1: // upper
+                                       return texture2D(sampler, coords);
+                               case 2: // lower
+                                       return texture2D(sampler, coords);
+                               default:
+                                       return texture2D(sampler, coords);
+                               }
+                       }
+
+                       vec4 get_rgba_color()
+                       {
+                               switch(pixel_format)
+                               {
+                               case 0:         //gray
+                                       return vec4(get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rrr, 1.0);
+                               case 1:         //bgra,
+                                       return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).bgra;
+                               case 2:         //rgba,
+                                       return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rgba;
+                               case 3:         //argb,
+                                       return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).argb;
+                               case 4:         //abgr,
+                                       return get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).gbar;
+                               case 5:         //ycbcr,
+                                       {
+                                               float y  = get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).r;
+                                               float cb = get_sample(plane[1], gl_TexCoord[0].st, plane_size[0]).r;
+                                               float cr = get_sample(plane[2], gl_TexCoord[0].st, plane_size[0]).r;
+                                               return ycbcra_to_rgba(y, cb, cr, 1.0);
+                                       }
+                               case 6:         //ycbcra
+                                       {
+                                               float y  = get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).r;
+                                               float cb = get_sample(plane[1], gl_TexCoord[0].st, plane_size[0]).r;
+                                               float cr = get_sample(plane[2], gl_TexCoord[0].st, plane_size[0]).r;
+                                               float a  = get_sample(plane[3], gl_TexCoord[0].st, plane_size[0]).r;
+                                               return ycbcra_to_rgba(y, cb, cr, a);
+                                       }
+                               case 7:         //luma
+                                       {
+                                               vec3 y3 = get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rrr;
+                                               return vec4((y3-0.065)/0.859, 1.0);
+                                       }
+                               case 8:         //bgr,
+                                       return vec4(get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).bgr, 1.0);
+                               case 9:         //rgb,
+                                       return vec4(get_sample(plane[0], gl_TexCoord[0].st, plane_size[0]).rgb, 1.0);
+                               }
+                               return vec4(0.0, 0.0, 0.0, 0.0);
+                       }
+
+                       void main()
+                       {
+                               vec4 color = get_rgba_color();
+                          if(levels)
+                                       color.rgb = LevelsControl(color.rgb, min_input, gamma, max_input, min_output, max_output);
+                               if(csb)
+                                       color.rgb = ContrastSaturationBrightness(color.rgb, brt, sat, con);
+                               if(has_local_key)
+                                       color *= texture2D(local_key, gl_TexCoord[1].st).r;
+                               if(has_layer_key)
+                                       color *= texture2D(layer_key, gl_TexCoord[1].st).r;
+                               color *= opacity;
+                               color = blend(color);
+                               gl_FragColor = color.bgra;
+                       }
+       )shader";
 }
 
 std::shared_ptr<shader> get_image_shader(
index 87462391dd5f8a73d3f125d1e3ff1f08c111eb98..872ebfd772292acaf037d1adbbc523c1fec5f299 100644 (file)
@@ -442,7 +442,7 @@ tweener_t get_tweener(std::wstring name)
        
        std::vector<double> params;
        
-       static const boost::wregex expr(L"(?<NAME>\\w*)(:(?<V0>\\d+\\.?\\d?))?(:(?<V1>\\d+\\.?\\d?))?"); // boost::regex has no repeated captures?
+       static const boost::wregex expr(LR"((?<NAME>\w*)(:(?<V0>\d+\.?\d?))?(:(?<V1>\d+\.?\d?))?)"); // boost::regex has no repeated captures?
        boost::wsmatch what;
        if(boost::regex_match(name, what, expr))
        {
index 496a555f5f5c7db3ad6aa979be640baf768c17ae..2ab9ba2469e644927adfb6f74137cdb1ef05529a 100644 (file)
@@ -863,13 +863,13 @@ spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wst
 
        auto str = std::accumulate(params2.begin(), params2.end(), std::wstring(), [](const std::wstring& lhs, const std::wstring& rhs) {return lhs + L" " + rhs;});
        
-       boost::wregex path_exp(L"\\s*FILE(\\s(?<PATH>.+\\.[^\\s]+))?.*", boost::regex::icase);
+       boost::wregex path_exp(LR"(\s*FILE(\s(?<PATH>.+\.[^\s]+))?.*)", boost::regex::icase);
 
        boost::wsmatch path;
        if(!boost::regex_match(str, path, path_exp))
                return core::frame_consumer::empty();
        
-       boost::wregex opt_exp(L"-((?<NAME>[^\\s]+)\\s+(?<VALUE>[^\\s]+))");     
+       boost::wregex opt_exp(LR"(-((?<NAME>[^\s]+)\s+(?<VALUE>[^\s]+)))");     
        
        std::vector<option> options;
        for(boost::wsregex_iterator it(str.begin(), str.end(), opt_exp); it != boost::wsregex_iterator(); ++it)
index 64be5c78efb95755aa67fadddc295ad0363b7a99..f8e0913da2ee66a5dd16826f6662be6852baefa1 100644 (file)
@@ -252,10 +252,10 @@ public:
                
        std::future<std::wstring> call(const std::vector<std::wstring>& params) override
        {
-               static const boost::wregex loop_exp(L"LOOP\\s*(?<VALUE>\\d?)?", boost::regex::icase);
-               static const boost::wregex seek_exp(L"SEEK\\s+(?<VALUE>\\d+)", boost::regex::icase);
-               static const boost::wregex length_exp(L"LENGTH\\s+(?<VALUE>\\d+)?", boost::regex::icase);
-               static const boost::wregex start_exp(L"START\\s+(?<VALUE>\\d+)?", boost::regex::icase);
+               static const boost::wregex loop_exp(LR"(LOOP\s*(?<VALUE>\d?)?)", boost::regex::icase);
+               static const boost::wregex seek_exp(LR"(SEEK\s+(?<VALUE>\d+))", boost::regex::icase);
+               static const boost::wregex length_exp(LR"(LENGTH\s+(?<VALUE>\d+)?)", boost::regex::icase);
+               static const boost::wregex start_exp(LR"(START\\s+(?<VALUE>\\d+)?)", boost::regex::icase);
 
                auto param = boost::algorithm::join(params, L" ");
                
index 83dfe39390ef65ef5f47e5f01666ddf1a2763111..7698d1a0399231f5cd25d65d59dd5283b3700384 100644 (file)
@@ -137,23 +137,26 @@ public:
        std::wstring timed_invoke(int layer, const std::wstring& label)
        {
                auto result = invoke(layer, label);
-               if(result.wait_for(std::chrono::seconds(2)) == std::future_status::ready)
+               // TODO: because of std::async deferred timed waiting does not work
+               //if (result.wait_for(std::chrono::seconds(2)) != std::future_status::timeout)
                        return result.get();
-               return L"";
+               //return L"";
        }
        std::wstring timed_description(int layer)
        {
                auto result = description(layer);
-               if (result.wait_for(std::chrono::seconds(2)) == std::future_status::ready)
+               // TODO: because of std::async deferred timed waiting does not work
+               //if (result.wait_for(std::chrono::seconds(2)) != std::future_status::timeout)
                        return result.get();
-               return L"";
+               //return L"";
        }
        std::wstring timed_template_host_info()
        {
                auto result = template_host_info();
-               if (result.wait_for(std::chrono::seconds(2)) == std::future_status::ready)
+               // TODO: because of std::async deferred timed waiting does not work
+               //if (result.wait_for(std::chrono::seconds(2)) != std::future_status::timeout)
                        return result.get();
-               return L"";
+               //return L"";
        }
 
        core::monitor::subject& monitor_output()
index 7f2b1263d3c32d67c05ae0689ff5b477a240acbc..d52ed7ed3ecd405c2f1efdc39f67fe1b8b0d167e 100644 (file)
@@ -371,8 +371,11 @@ bool CallCommand::DoExecute()
        {
                auto result = channel()->stage().call(layer_index(), parameters());
                
-               if (result.wait_for(std::chrono::seconds(2)) != std::future_status::ready)
-                       CASPAR_THROW_EXCEPTION(timed_out());
+               // TODO: because of std::async deferred timed waiting does not work
+
+               /*auto wait_res = result.wait_for(std::chrono::seconds(2));
+               if (wait_res == std::future_status::timeout)
+                       CASPAR_THROW_EXCEPTION(timed_out());*/
                                
                std::wstringstream replyString;
                if(result.get().empty())
@@ -799,7 +802,7 @@ bool LoadbgCommand::DoExecute()
        for(size_t n = 0; n < parameters().size(); ++n)
                message += boost::to_upper_copy(parameters()[n]) + L" ";
                
-       static const boost::wregex expr(L".*(?<TRANSITION>CUT|PUSH|SLIDE|WIPE|MIX)\\s*(?<DURATION>\\d+)\\s*(?<TWEEN>(LINEAR)|(EASE[^\\s]*))?\\s*(?<DIRECTION>FROMLEFT|FROMRIGHT|LEFT|RIGHT)?.*");
+       static const boost::wregex expr(LR"(.*(?<TRANSITION>CUT|PUSH|SLIDE|WIPE|MIX)\s*(?<DURATION>\d+)\s*(?<TWEEN>(LINEAR)|(EASE[^\s]*))?\s*(?<DIRECTION>FROMLEFT|FROMRIGHT|LEFT|RIGHT)?.*)");
        boost::wsmatch what;
        if(boost::regex_match(message, what, expr))
        {
@@ -835,7 +838,7 @@ bool LoadbgCommand::DoExecute()
        {
                std::shared_ptr<core::frame_producer> pFP;
                
-               static boost::wregex expr(L"\\[(?<CHANNEL>\\d+)\\]", boost::regex::icase);
+               static boost::wregex expr(LR"(\[(?<CHANNEL>\d+)\])", boost::regex::icase);
                        
                boost::wsmatch what;
                if(boost::regex_match(parameters().at(0), what, expr))