X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fmixer%2Fimage%2Fblending_glsl.h;h=86b4b9613b10fb925529b175c0b1058092819061;hb=517174ad8f15d5b6f71cdf8bc04a158cbe4bd278;hp=a1072aa2cf9b7302c1cc65d914c365bd6e2e7b04;hpb=c23d77ad73a54d13a3c80a4c77496e509b96941c;p=casparcg diff --git a/core/mixer/image/blending_glsl.h b/core/mixer/image/blending_glsl.h index a1072aa2c..86b4b9613 100644 --- a/core/mixer/image/blending_glsl.h +++ b/core/mixer/image/blending_glsl.h @@ -1,5 +1,49 @@ #pragma once +static std::string get_adjustement_glsl() +{ + return + "\n /* " + "\n ** Contrast, saturation, brightness " + "\n ** Code of this function is from TGM's shader pack " + "\n ** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 " + "\n */ " + "\n " + "\n vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con) " + "\n { " + "\n const float AvgLumR = 0.5; " + "\n const float AvgLumG = 0.5; " + "\n const float AvgLumB = 0.5; " + "\n " + "\n const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); " + "\n " + "\n vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); " + "\n vec3 brtColor = color * brt; " + "\n vec3 intensity = vec3(dot(brtColor, LumCoeff)); " + "\n vec3 satColor = mix(intensity, brtColor, sat); " + "\n vec3 conColor = mix(AvgLumin, satColor, con); " + "\n return conColor; " + "\n } " + "\n " + "\n /* " + "\n ** Gamma correction " + "\n ** Details: http://blog.mouaif.org/2009/01/22/photoshop-gamma-correction-shader/ " + "\n */ " + "\n " + "\n#define GammaCorrection(color, gamma) pow(color, vec3(1.0 / gamma)) \n " + "\n " + "\n /* " + "\n ** Levels control (input (+gamma), output) " + "\n ** Details: http://blog.mouaif.org/2009/01/28/levels-control-shader/ " + "\n */ " + "\n " + "\n#define LevelsControlInputRange(color, minInput, maxInput) min(max(color - vec3(minInput), vec3(0.0)) / (vec3(maxInput) - vec3(minInput)), vec3(1.0)) \n " + "\n#define LevelsControlInput(color, minInput, gamma, maxInput) GammaCorrection(LevelsControlInputRange(color, minInput, maxInput), gamma) \n " + "\n#define LevelsControlOutputRange(color, minOutput, maxOutput) mix(vec3(minOutput), vec3(maxOutput), color) \n " + "\n#define LevelsControl(color, minInput, gamma, maxInput, minOutput, maxOutput) LevelsControlOutputRange(LevelsControlInput(color, minInput, gamma, maxInput), minOutput, maxOutput) \n " + ; +} + static std::string get_blend_glsl() { static std::string glsl = @@ -114,28 +158,7 @@ static std::string get_blend_glsl() "\n return rgb; " "\n } " "\n " - "\n " - "\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 " "\n /* " @@ -194,7 +217,6 @@ static std::string get_blend_glsl() "\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#define BlendInvert(base, blend) (vec3(1.0, 1.0, 1.0) - blend) \n " "\n " "\n " "\n vec3 BlendHue(vec3 base, vec3 blend) " @@ -220,24 +242,7 @@ static std::string get_blend_glsl() "\n vec3 baseHSL = RGBToHSL(base); " "\n return HSLToRGB(vec3(baseHSL.r, baseHSL.g, RGBToHSL(blend).b)); " "\n } " - "\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, 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 " + "\n " ; return glsl;