public let AdaptiveThresholdFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2; \n \n void main()\n {\n     highp float blurredInput = texture2D(inputImageTexture, textureCoordinate).r;\n     highp float localLuminance = texture2D(inputImageTexture2, textureCoordinate2).r;\n     highp float thresholdResult = step(blurredInput - 0.05, localLuminance);\n     \n     gl_FragColor = vec4(vec3(thresholdResult), 1.0);\n }\n "
public let AddBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n   lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n   lowp vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n  \n   mediump float r;\n   if (overlay.r * base.a + base.r * overlay.a >= overlay.a * base.a) {\n     r = overlay.a * base.a + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n   } else {\n     r = overlay.r + base.r;\n   }\n \n   mediump float g;\n   if (overlay.g * base.a + base.g * overlay.a >= overlay.a * base.a) {\n     g = overlay.a * base.a + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n   } else {\n     g = overlay.g + base.g;\n   }\n \n   mediump float b;\n   if (overlay.b * base.a + base.b * overlay.a >= overlay.a * base.a) {\n     b = overlay.a * base.a + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n   } else {\n     b = overlay.b + base.b;\n   }\n \n   mediump float a = overlay.a + base.a - overlay.a * base.a;\n   \n   gl_FragColor = vec4(r, g, b, a);\n }\n "
public let AlphaBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n uniform lowp float mixturePercent;\n \n void main()\n {\n  lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n  lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n  \n  gl_FragColor = vec4(mix(textureColor.rgb, textureColor2.rgb, textureColor2.a * mixturePercent), textureColor.a);\n }\n "
public let AlphaTestFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 color = texture2D(inputImageTexture, textureCoordinate);\n     if (color.a < 0.5) \n     {\n         discard;\n     } \n     else\n     {\n         gl_FragColor = color;\n     }\n }\n "
public let AverageColorVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 upperLeftInputTextureCoordinate;\n varying vec2 upperRightInputTextureCoordinate;\n varying vec2 lowerLeftInputTextureCoordinate;\n varying vec2 lowerRightInputTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     upperLeftInputTextureCoordinate = inputTextureCoordinate.xy + vec2(-texelWidth, -texelHeight);\n     upperRightInputTextureCoordinate = inputTextureCoordinate.xy + vec2(texelWidth, -texelHeight);\n     lowerLeftInputTextureCoordinate = inputTextureCoordinate.xy + vec2(-texelWidth, texelHeight);\n     lowerRightInputTextureCoordinate = inputTextureCoordinate.xy + vec2(texelWidth, texelHeight);\n }\n "
public let AverageColorFragmentShader = "precision highp float;\n \n uniform sampler2D inputImageTexture;\n \n varying highp vec2 outputTextureCoordinate;\n \n varying highp vec2 upperLeftInputTextureCoordinate;\n varying highp vec2 upperRightInputTextureCoordinate;\n varying highp vec2 lowerLeftInputTextureCoordinate;\n varying highp vec2 lowerRightInputTextureCoordinate;\n \n void main()\n {\n     highp vec4 upperLeftColor = texture2D(inputImageTexture, upperLeftInputTextureCoordinate);\n     highp vec4 upperRightColor = texture2D(inputImageTexture, upperRightInputTextureCoordinate);\n     highp vec4 lowerLeftColor = texture2D(inputImageTexture, lowerLeftInputTextureCoordinate);\n     highp vec4 lowerRightColor = texture2D(inputImageTexture, lowerRightInputTextureCoordinate);\n     \n     gl_FragColor = 0.25 * (upperLeftColor + upperRightColor + lowerLeftColor + lowerRightColor);\n }\n "
public let AverageLuminanceFragmentShader = "precision highp float;\n \n uniform sampler2D inputImageTexture;\n \n varying highp vec2 outputTextureCoordinate;\n \n varying highp vec2 upperLeftInputTextureCoordinate;\n varying highp vec2 upperRightInputTextureCoordinate;\n varying highp vec2 lowerLeftInputTextureCoordinate;\n varying highp vec2 lowerRightInputTextureCoordinate;\n \n void main()\n {\n     highp float upperLeftLuminance = texture2D(inputImageTexture, upperLeftInputTextureCoordinate).r;\n     highp float upperRightLuminance = texture2D(inputImageTexture, upperRightInputTextureCoordinate).r;\n     highp float lowerLeftLuminance = texture2D(inputImageTexture, lowerLeftInputTextureCoordinate).r;\n     highp float lowerRightLuminance = texture2D(inputImageTexture, lowerRightInputTextureCoordinate).r;\n     \n     highp float luminosity = 0.25 * (upperLeftLuminance + upperRightLuminance + lowerLeftLuminance + lowerRightLuminance);\n     gl_FragColor = vec4(luminosity, luminosity, luminosity, 1.0);\n }\n "
public let BilateralBlurVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n const int GAUSSIAN_SAMPLES = 9;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 textureCoordinate;\n varying vec2 blurCoordinates[GAUSSIAN_SAMPLES];\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = inputTextureCoordinate.xy;\n     \n     // Calculate the positions for the blur\n     int multiplier = 0;\n     vec2 blurStep;\n     vec2 singleStepOffset = vec2(texelWidth, texelHeight);\n     \n     for (int i = 0; i < GAUSSIAN_SAMPLES; i++)\n     {\n         multiplier = (i - ((GAUSSIAN_SAMPLES - 1) / 2));\n         // Blur in x (horizontal)\n         blurStep = float(multiplier) * singleStepOffset;\n         blurCoordinates[i] = inputTextureCoordinate.xy + blurStep;\n     }\n }\n "
public let BilateralBlurFragmentShader = "uniform sampler2D inputImageTexture;\n \n const lowp int GAUSSIAN_SAMPLES = 9;\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 blurCoordinates[GAUSSIAN_SAMPLES];\n \n uniform mediump float distanceNormalizationFactor;\n \n void main()\n {\n     lowp vec4 centralColor;\n     lowp float gaussianWeightTotal;\n     lowp vec4 sum;\n     lowp vec4 sampleColor;\n     lowp float distanceFromCentralColor;\n     lowp float gaussianWeight;\n     \n     centralColor = texture2D(inputImageTexture, blurCoordinates[4]);\n     gaussianWeightTotal = 0.18;\n     sum = centralColor * 0.18;\n     \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[0]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.05 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[1]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.09 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[2]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.12 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[3]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.15 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[5]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.15 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[6]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.12 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[7]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.09 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n \n     sampleColor = texture2D(inputImageTexture, blurCoordinates[8]);\n     distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n     gaussianWeight = 0.05 * (1.0 - distanceFromCentralColor);\n     gaussianWeightTotal += gaussianWeight;\n     sum += sampleColor * gaussianWeight;\n     \n     gl_FragColor = sum / gaussianWeightTotal;\n }\n "
public let BrightnessFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float brightness;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);\n }\n "
public let BulgeDistortionFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float aspectRatio;\n uniform highp vec2 center;\n uniform highp float radius;\n uniform highp float scale;\n \n void main()\n {\n    highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, ((textureCoordinate.y - center.y) * aspectRatio) + center.y);\n    highp float dist = distance(center, textureCoordinateToUse);\n    textureCoordinateToUse = textureCoordinate;\n    \n    if (dist < radius)\n    {\n        textureCoordinateToUse -= center;\n        highp float percent = 1.0 - ((radius - dist) / radius) * scale;\n        percent = percent * percent;\n        \n        textureCoordinateToUse = textureCoordinateToUse * percent;\n        textureCoordinateToUse += center;\n    }\n    \n    gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );    \n }\n "
public let CGAColorspaceFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     highp vec2 sampleDivisor = vec2(1.0 / 200.0, 1.0 / 320.0);\n     //highp vec4 colorDivisor = vec4(colorDepth);\n     \n     highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor);\n     highp vec4 color = texture2D(inputImageTexture, samplePos );\n     \n     //gl_FragColor = texture2D(inputImageTexture, samplePos );\n     mediump vec4 colorCyan = vec4(85.0 / 255.0, 1.0, 1.0, 1.0);\n     mediump vec4 colorMagenta = vec4(1.0, 85.0 / 255.0, 1.0, 1.0);\n     mediump vec4 colorWhite = vec4(1.0, 1.0, 1.0, 1.0);\n     mediump vec4 colorBlack = vec4(0.0, 0.0, 0.0, 1.0);\n     \n     mediump vec4 endColor;\n     highp float blackDistance = distance(color, colorBlack);\n     highp float whiteDistance = distance(color, colorWhite);\n     highp float magentaDistance = distance(color, colorMagenta);\n     highp float cyanDistance = distance(color, colorCyan);\n     \n     mediump vec4 finalColor;\n     \n     highp float colorDistance = min(magentaDistance, cyanDistance);\n     colorDistance = min(colorDistance, whiteDistance);\n     colorDistance = min(colorDistance, blackDistance); \n     \n     if (colorDistance == blackDistance) {\n         finalColor = colorBlack;\n     } else if (colorDistance == whiteDistance) {\n         finalColor = colorWhite;\n     } else if (colorDistance == cyanDistance) {\n         finalColor = colorCyan;\n     } else {\n         finalColor = colorMagenta;\n     }\n     \n     gl_FragColor = finalColor;\n }\n "
public let ChromaKeyBlendFragmentShader = "// Shader code based on Apple's CIChromaKeyFilter example: https://developer.apple.com/library/mac/#samplecode/CIChromaKeyFilter/Introduction/Intro.html\n \n  precision highp float;\n  \n  varying highp vec2 textureCoordinate;\n  varying highp vec2 textureCoordinate2;\n \n  uniform float thresholdSensitivity;\n  uniform float smoothing;\n  uniform vec3 colorToReplace;\n  uniform sampler2D inputImageTexture;\n  uniform sampler2D inputImageTexture2;\n  \n  void main()\n  {\n      vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n      vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n      \n      float maskY = 0.2989 * colorToReplace.r + 0.5866 * colorToReplace.g + 0.1145 * colorToReplace.b;\n      float maskCr = 0.7132 * (colorToReplace.r - maskY);\n      float maskCb = 0.5647 * (colorToReplace.b - maskY);\n      \n      float Y = 0.2989 * textureColor.r + 0.5866 * textureColor.g + 0.1145 * textureColor.b;\n      float Cr = 0.7132 * (textureColor.r - Y);\n      float Cb = 0.5647 * (textureColor.b - Y);\n      \n //     float blendValue = 1.0 - smoothstep(thresholdSensitivity - smoothing, thresholdSensitivity , abs(Cr - maskCr) + abs(Cb - maskCb));\n      float blendValue = 1.0 - smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb)));\n      gl_FragColor = mix(textureColor, textureColor2, blendValue);\n  }\n "
public let ChromaKeyFragmentShader = "// Shader code based on Apple's CIChromaKeyFilter example: https://developer.apple.com/library/mac/#samplecode/CIChromaKeyFilter/Introduction/Intro.html\n \n precision highp float;\n \n varying highp vec2 textureCoordinate;\n \n uniform float thresholdSensitivity;\n uniform float smoothing;\n uniform vec3 colorToReplace;\n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     float maskY = 0.2989 * colorToReplace.r + 0.5866 * colorToReplace.g + 0.1145 * colorToReplace.b;\n     float maskCr = 0.7132 * (colorToReplace.r - maskY);\n     float maskCb = 0.5647 * (colorToReplace.b - maskY);\n     \n     float Y = 0.2989 * textureColor.r + 0.5866 * textureColor.g + 0.1145 * textureColor.b;\n     float Cr = 0.7132 * (textureColor.r - Y);\n     float Cb = 0.5647 * (textureColor.b - Y);\n     \n     //     float blendValue = 1.0 - smoothstep(thresholdSensitivity - smoothing, thresholdSensitivity , abs(Cr - maskCr) + abs(Cb - maskCb));\n     float blendValue = smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb)));\n     gl_FragColor = vec4(textureColor.rgb, textureColor.a * blendValue);\n }\n "
public let CircleVertexShader = "attribute vec4 position;\n varying vec2 currentPosition;\n uniform float aspectRatio;\n \n void main()\n {\n     currentPosition = vec2(position.x, position.y * aspectRatio);\n     gl_Position = position;\n }\n "
public let CircleFragmentShader = "uniform lowp vec4 circleColor;\n uniform lowp vec4 backgroundColor;\n uniform highp vec2 center;\n uniform highp float radius;\n \n varying highp vec2 currentPosition;\n \n void main()\n {\n     highp float distanceFromCenter = distance(center, currentPosition);\n     highp float checkForPresenceWithinCircle = step(distanceFromCenter, radius);\n \n     gl_FragColor = mix(backgroundColor, circleColor, checkForPresenceWithinCircle);\n }\n "
public let ColorBlendFragmentShader = "// Color blend mode based upon pseudo code from the PDF specification.\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n highp float lum(lowp vec3 c) {\n     return dot(c, vec3(0.3, 0.59, 0.11));\n }\n \n lowp vec3 clipcolor(lowp vec3 c) {\n     highp float l = lum(c);\n     lowp float n = min(min(c.r, c.g), c.b);\n     lowp float x = max(max(c.r, c.g), c.b);\n     \n     if (n < 0.0) {\n         c.r = l + ((c.r - l) * l) / (l - n);\n         c.g = l + ((c.g - l) * l) / (l - n);\n         c.b = l + ((c.b - l) * l) / (l - n);\n     }\n     if (x > 1.0) {\n         c.r = l + ((c.r - l) * (1.0 - l)) / (x - l);\n         c.g = l + ((c.g - l) * (1.0 - l)) / (x - l);\n         c.b = l + ((c.b - l) * (1.0 - l)) / (x - l);\n     }\n     \n     return c;\n }\n \n lowp vec3 setlum(lowp vec3 c, highp float l) {\n     highp float d = l - lum(c);\n     c = c + vec3(d);\n     return clipcolor(c);\n }\n \n void main()\n {\n  highp vec4 baseColor = texture2D(inputImageTexture, textureCoordinate);\n  highp vec4 overlayColor = texture2D(inputImageTexture2, textureCoordinate2);\n \n     gl_FragColor = vec4(baseColor.rgb * (1.0 - overlayColor.a) + setlum(overlayColor.rgb, lum(baseColor.rgb)) * overlayColor.a, baseColor.a);\n }\n "
public let ColorBurnBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n    mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n    mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n    mediump vec4 whiteColor = vec4(1.0);\n    gl_FragColor = whiteColor - (whiteColor - textureColor) / textureColor2;\n }\n "
public let ColorDodgeBlendFragmentShader = "precision mediump float;\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     vec4 base = texture2D(inputImageTexture, textureCoordinate);\n     vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     vec3 baseOverlayAlphaProduct = vec3(overlay.a * base.a);\n     vec3 rightHandProduct = overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a);\n     \n     vec3 firstBlendColor = baseOverlayAlphaProduct + rightHandProduct;\n     vec3 overlayRGB = clamp((overlay.rgb / clamp(overlay.a, 0.01, 1.0)) * step(0.0, overlay.a), 0.0, 0.99);\n     \n     vec3 secondBlendColor = (base.rgb * overlay.a) / (1.0 - overlayRGB) + rightHandProduct;\n     \n     vec3 colorChoice = step((overlay.rgb * base.a + base.rgb * overlay.a), baseOverlayAlphaProduct);\n     \n     gl_FragColor = vec4(mix(firstBlendColor, secondBlendColor, colorChoice), 1.0);\n }\n "
public let ColorInvertFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n    lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n    \n    gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);\n }\n "
public let ColorLocalBinaryPatternFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec3 centerColor = texture2D(inputImageTexture, textureCoordinate).rgb;\n     lowp vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;\n     lowp vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;\n     lowp vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;\n     lowp vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;\n     lowp vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;\n     lowp vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;\n     lowp vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;\n     lowp vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;\n \n     lowp float redByteTally = 1.0 / 255.0 * step(centerColor.r, topRightColor.r);\n     redByteTally += 2.0 / 255.0 * step(centerColor.r, topColor.r);\n     redByteTally += 4.0 / 255.0 * step(centerColor.r, topLeftColor.r);\n     redByteTally += 8.0 / 255.0 * step(centerColor.r, leftColor.r);\n     redByteTally += 16.0 / 255.0 * step(centerColor.r, bottomLeftColor.r);\n     redByteTally += 32.0 / 255.0 * step(centerColor.r, bottomColor.r);\n     redByteTally += 64.0 / 255.0 * step(centerColor.r, bottomRightColor.r);\n     redByteTally += 128.0 / 255.0 * step(centerColor.r, rightColor.r);\n \n     lowp float blueByteTally = 1.0 / 255.0 * step(centerColor.b, topRightColor.b);\n     blueByteTally += 2.0 / 255.0 * step(centerColor.b, topColor.b);\n     blueByteTally += 4.0 / 255.0 * step(centerColor.b, topLeftColor.b);\n     blueByteTally += 8.0 / 255.0 * step(centerColor.b, leftColor.b);\n     blueByteTally += 16.0 / 255.0 * step(centerColor.b, bottomLeftColor.b);\n     blueByteTally += 32.0 / 255.0 * step(centerColor.b, bottomColor.b);\n     blueByteTally += 64.0 / 255.0 * step(centerColor.b, bottomRightColor.b);\n     blueByteTally += 128.0 / 255.0 * step(centerColor.b, rightColor.b);\n \n     lowp float greenByteTally = 1.0 / 255.0 * step(centerColor.g, topRightColor.g);\n     greenByteTally += 2.0 / 255.0 * step(centerColor.g, topColor.g);\n     greenByteTally += 4.0 / 255.0 * step(centerColor.g, topLeftColor.g);\n     greenByteTally += 8.0 / 255.0 * step(centerColor.g, leftColor.g);\n     greenByteTally += 16.0 / 255.0 * step(centerColor.g, bottomLeftColor.g);\n     greenByteTally += 32.0 / 255.0 * step(centerColor.g, bottomColor.g);\n     greenByteTally += 64.0 / 255.0 * step(centerColor.g, bottomRightColor.g);\n     greenByteTally += 128.0 / 255.0 * step(centerColor.g, rightColor.g);\n \n     // TODO: Replace the above with a dot product and two vec4s\n     // TODO: Apply step to a matrix, rather than individually\n     \n     gl_FragColor = vec4(redByteTally, blueByteTally, greenByteTally, 1.0);\n }\n "
public let ColorMatrixFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform lowp mat4 colorMatrix;\n uniform lowp float intensity;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp vec4 outputColor = textureColor * colorMatrix;\n     \n     gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);\n }\n "
public let ColorSwizzlingFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     gl_FragColor = texture2D(inputImageTexture, textureCoordinate).bgra;\n }\n "
public let ColourFASTDecriptorVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n attribute vec4 inputTextureCoordinate2;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 textureCoordinate;\n varying vec2 pointATextureCoordinate;\n varying vec2 pointBTextureCoordinate;\n varying vec2 pointCTextureCoordinate;\n varying vec2 pointDTextureCoordinate;\n varying vec2 pointETextureCoordinate;\n varying vec2 pointFTextureCoordinate;\n varying vec2 pointGTextureCoordinate;\n varying vec2 pointHTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     float tripleTexelWidth = 3.0 * texelWidth;\n     float tripleTexelHeight = 3.0 * texelHeight;\n     \n     textureCoordinate = inputTextureCoordinate.xy;\n     \n     pointATextureCoordinate = vec2(inputTextureCoordinate2.x + tripleTexelWidth, textureCoordinate.y + texelHeight);\n     pointBTextureCoordinate = vec2(inputTextureCoordinate2.x + texelWidth, textureCoordinate.y + tripleTexelHeight);\n     pointCTextureCoordinate = vec2(inputTextureCoordinate2.x - texelWidth, textureCoordinate.y + tripleTexelHeight);\n     pointDTextureCoordinate = vec2(inputTextureCoordinate2.x - tripleTexelWidth, textureCoordinate.y + texelHeight);\n     pointETextureCoordinate = vec2(inputTextureCoordinate2.x - tripleTexelWidth, textureCoordinate.y - texelHeight);\n     pointFTextureCoordinate = vec2(inputTextureCoordinate2.x - texelWidth, textureCoordinate.y - tripleTexelHeight);\n     pointGTextureCoordinate = vec2(inputTextureCoordinate2.x + texelWidth, textureCoordinate.y - tripleTexelHeight);\n     pointHTextureCoordinate = vec2(inputTextureCoordinate2.x + tripleTexelWidth, textureCoordinate.y - texelHeight);\n }\n "
public let ColourFASTDecriptorFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 pointATextureCoordinate;\n varying vec2 pointBTextureCoordinate;\n varying vec2 pointCTextureCoordinate;\n varying vec2 pointDTextureCoordinate;\n varying vec2 pointETextureCoordinate;\n varying vec2 pointFTextureCoordinate;\n varying vec2 pointGTextureCoordinate;\n varying vec2 pointHTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n const float PITwo = 6.2832;\n const float PI = 3.1416;\n void main()\n {\n     vec3 centerColor = texture2D(inputImageTexture, textureCoordinate).rgb;\n     \n     vec3 pointAColor = texture2D(inputImageTexture2, pointATextureCoordinate).rgb;\n     vec3 pointBColor = texture2D(inputImageTexture2, pointBTextureCoordinate).rgb;\n     vec3 pointCColor = texture2D(inputImageTexture2, pointCTextureCoordinate).rgb;\n     vec3 pointDColor = texture2D(inputImageTexture2, pointDTextureCoordinate).rgb;\n     vec3 pointEColor = texture2D(inputImageTexture2, pointETextureCoordinate).rgb;\n     vec3 pointFColor = texture2D(inputImageTexture2, pointFTextureCoordinate).rgb;\n     vec3 pointGColor = texture2D(inputImageTexture2, pointGTextureCoordinate).rgb;\n     vec3 pointHColor = texture2D(inputImageTexture2, pointHTextureCoordinate).rgb;\n \n     vec3 colorComparison = ((pointAColor + pointBColor + pointCColor + pointDColor + pointEColor + pointFColor + pointGColor + pointHColor) * 0.125) - centerColor;\n \n     // Direction calculation drawn from Appendix B of Seth Hall's Ph.D. thesis\n     \n     vec3 dirX = (pointAColor*0.94868) + (pointBColor*0.316227) - (pointCColor*0.316227) - (pointDColor*0.94868) - (pointEColor*0.94868) - (pointFColor*0.316227) + (pointGColor*0.316227) + (pointHColor*0.94868);\n     vec3 dirY = (pointAColor*0.316227) + (pointBColor*0.94868) + (pointCColor*0.94868) + (pointDColor*0.316227) - (pointEColor*0.316227) - (pointFColor*0.94868) - (pointGColor*0.94868) - (pointHColor*0.316227);\n     vec3 absoluteDifference = abs(colorComparison);\n     float componentLength = length(colorComparison);\n     float avgX = dot(absoluteDifference, dirX) / componentLength;\n     float avgY = dot(absoluteDifference, dirY) / componentLength;\n     float angle = atan(avgY, avgX);\n     \n     vec3 normalizedColorComparison = (colorComparison + 1.0) * 0.5;\n     \n     gl_FragColor = vec4(normalizedColorComparison, (angle+PI)/PITwo);\n }\n "
public let ContrastFragmentShader = "varying highp vec2 textureCoordinate;\n  \n uniform sampler2D inputImageTexture;\n uniform lowp float contrast;\n \n void main()\n {\n  lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n  \n  gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);\n }\n "
public let Convolution3x3FragmentShader = "precision highp float;\n \n uniform sampler2D inputImageTexture;\n \n uniform mediump mat3 convolutionMatrix;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n void main()\n {\n     mediump vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;\n     mediump vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;\n     mediump vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;\n     mediump vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;\n     mediump vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;\n     mediump vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;\n     mediump vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;\n     mediump vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;\n \n     mediump vec3 resultColor = topLeftColor * convolutionMatrix[0][0] + topColor * convolutionMatrix[0][1] + topRightColor * convolutionMatrix[0][2];\n     resultColor += leftColor * convolutionMatrix[1][0] + centerColor.rgb * convolutionMatrix[1][1] + rightColor * convolutionMatrix[1][2];\n     resultColor += bottomLeftColor * convolutionMatrix[2][0] + bottomColor * convolutionMatrix[2][1] + bottomRightColor * convolutionMatrix[2][2];\n \n     gl_FragColor = vec4(resultColor, centerColor.a);\n }\n "
public let CrosshairVertexShader = "attribute vec4 position;\n \n uniform float crosshairWidth;\n \n varying vec2 centerLocation;\n varying float pointSpacing;\n \n void main()\n {\n     gl_Position = vec4(((position.xy * 2.0) - 1.0), 0.0, 1.0);\n     gl_PointSize = crosshairWidth + 1.0;\n     pointSpacing = 1.0 / crosshairWidth;\n     centerLocation = vec2(pointSpacing * ceil(crosshairWidth / 2.0), pointSpacing * ceil(crosshairWidth / 2.0));\n }\n "
public let CrosshairFragmentShader = "uniform lowp vec3 crosshairColor;\n \n varying highp vec2 centerLocation;\n varying highp float pointSpacing;\n \n void main()\n {\n     lowp vec2 distanceFromCenter = abs(centerLocation - gl_PointCoord.xy);\n     lowp float axisTest = step(pointSpacing, gl_PointCoord.y) * step(distanceFromCenter.x, 0.09) + step(pointSpacing, gl_PointCoord.x) * step(distanceFromCenter.y, 0.09);\n \n     gl_FragColor = vec4(crosshairColor * axisTest, axisTest);\n //     gl_FragColor = vec4(distanceFromCenterInX, distanceFromCenterInY, 0.0, 1.0);\n }\n "
public let CrosshatchFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float crossHatchSpacing;\n uniform highp float lineWidth;\n \n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     highp float luminance = dot(texture2D(inputImageTexture, textureCoordinate).rgb, W);\n     \n     lowp vec4 colorToDisplay = vec4(1.0, 1.0, 1.0, 1.0);\n     if (luminance < 1.00) \n     {\n         if (mod(textureCoordinate.x + textureCoordinate.y, crossHatchSpacing) <= lineWidth) \n         {\n             colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0);\n         }\n     }\n     if (luminance < 0.75) \n     {\n         if (mod(textureCoordinate.x - textureCoordinate.y, crossHatchSpacing) <= lineWidth) \n         {\n             colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0);\n         }\n     }\n     if (luminance < 0.50) \n     {\n         if (mod(textureCoordinate.x + textureCoordinate.y - (crossHatchSpacing / 2.0), crossHatchSpacing) <= lineWidth) \n         {\n             colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0);\n         }\n     }\n     if (luminance < 0.3) \n     {\n         if (mod(textureCoordinate.x - textureCoordinate.y - (crossHatchSpacing / 2.0), crossHatchSpacing) <= lineWidth) \n         {\n             colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0);\n         }\n     }\n \n     gl_FragColor = colorToDisplay;\n }\n "
public let DarkenBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n    lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n    lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);\n    \n    gl_FragColor = vec4(min(overlayer.rgb * base.a, base.rgb * overlayer.a) + overlayer.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlayer.a), 1.0);\n }\n "
public let DifferenceBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n     gl_FragColor = vec4(abs(textureColor2.rgb - textureColor.rgb), textureColor.a);\n }\n "
public let Dilation1FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     \n     lowp vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);\n     \n     gl_FragColor = max(maxValue, oneStepNegativeIntensity);\n }\n "
public let Dilation2FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);\n     lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);\n     \n     lowp vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);\n     maxValue = max(maxValue, oneStepNegativeIntensity);\n     maxValue = max(maxValue, twoStepsPositiveIntensity);\n     maxValue = max(maxValue, twoStepsNegativeIntensity);\n     \n     gl_FragColor = max(maxValue, twoStepsNegativeIntensity);\n }\n "
public let Dilation3FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n varying vec2 threeStepsPositiveTextureCoordinate;\n varying vec2 threeStepsNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);\n     lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);\n     lowp vec4 threeStepsPositiveIntensity = texture2D(inputImageTexture, threeStepsPositiveTextureCoordinate);\n     lowp vec4 threeStepsNegativeIntensity = texture2D(inputImageTexture, threeStepsNegativeTextureCoordinate);\n     \n     lowp vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);\n     maxValue = max(maxValue, oneStepNegativeIntensity);\n     maxValue = max(maxValue, twoStepsPositiveIntensity);\n     maxValue = max(maxValue, twoStepsNegativeIntensity);\n     maxValue = max(maxValue, threeStepsPositiveIntensity);\n     \n     gl_FragColor = max(maxValue, threeStepsNegativeIntensity);\n }\n "
public let Dilation4FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n varying vec2 threeStepsPositiveTextureCoordinate;\n varying vec2 threeStepsNegativeTextureCoordinate;\n varying vec2 fourStepsPositiveTextureCoordinate;\n varying vec2 fourStepsNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);\n     lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);\n     lowp vec4 threeStepsPositiveIntensity = texture2D(inputImageTexture, threeStepsPositiveTextureCoordinate);\n     lowp vec4 threeStepsNegativeIntensity = texture2D(inputImageTexture, threeStepsNegativeTextureCoordinate);\n     lowp vec4 fourStepsPositiveIntensity = texture2D(inputImageTexture, fourStepsPositiveTextureCoordinate);\n     lowp vec4 fourStepsNegativeIntensity = texture2D(inputImageTexture, fourStepsNegativeTextureCoordinate);\n     \n     lowp vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);\n     maxValue = max(maxValue, oneStepNegativeIntensity);\n     maxValue = max(maxValue, twoStepsPositiveIntensity);\n     maxValue = max(maxValue, twoStepsNegativeIntensity);\n     maxValue = max(maxValue, threeStepsPositiveIntensity);\n     maxValue = max(maxValue, threeStepsNegativeIntensity);\n     maxValue = max(maxValue, fourStepsPositiveIntensity);\n     \n     gl_FragColor = max(maxValue, fourStepsNegativeIntensity);\n }\n "
public let DirectionalNonMaximumSuppressionFragmentShader = "precision mediump float;\n \n varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform highp float texelWidth; \n uniform highp float texelHeight; \n uniform mediump float upperThreshold; \n uniform mediump float lowerThreshold; \n \n void main()\n {\n     vec3 currentGradientAndDirection = texture2D(inputImageTexture, textureCoordinate).rgb;\n     vec2 gradientDirection = ((currentGradientAndDirection.gb * 2.0) - 1.0) * vec2(texelWidth, texelHeight);\n     \n     float firstSampledGradientMagnitude = texture2D(inputImageTexture, textureCoordinate + gradientDirection).r;\n     float secondSampledGradientMagnitude = texture2D(inputImageTexture, textureCoordinate - gradientDirection).r;\n     \n     float multiplier = step(firstSampledGradientMagnitude, currentGradientAndDirection.r);\n     multiplier = multiplier * step(secondSampledGradientMagnitude, currentGradientAndDirection.r);\n     \n     float thresholdCompliance = smoothstep(lowerThreshold, upperThreshold, currentGradientAndDirection.r);\n     multiplier = multiplier * thresholdCompliance;\n     \n     gl_FragColor = vec4(multiplier, multiplier, multiplier, 1.0);\n }\n "
public let DirectionalSobelEdgeDetectionFragmentShader = "precision mediump float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     \n     vec2 gradientDirection;\n     gradientDirection.x = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;\n     gradientDirection.y = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;\n     \n     float gradientMagnitude = length(gradientDirection);\n     vec2 normalizedDirection = normalize(gradientDirection);\n     normalizedDirection = sign(normalizedDirection) * floor(abs(normalizedDirection) + 0.617316); // Offset by 1-sin(pi/8) to set to 0 if near axis, 1 if away\n     normalizedDirection = (normalizedDirection + 1.0) * 0.5; // Place -1.0 - 1.0 within 0 - 1.0\n     \n     gl_FragColor = vec4(gradientMagnitude, normalizedDirection.x, normalizedDirection.y, 1.0);\n }\n "
public let DissolveBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n uniform lowp float mixturePercent;\n \n void main()\n {\n    lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n    lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n    \n    gl_FragColor = mix(textureColor, textureColor2, mixturePercent);\n }\n "
public let DivideBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n  mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n  mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n   \n   mediump float ra;\n   if (overlay.a == 0.0 || ((base.r / overlay.r) > (base.a / overlay.a)))\n     ra = overlay.a * base.a + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n   else\n     ra = (base.r * overlay.a * overlay.a) / overlay.r + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n   \n \n   mediump float ga;\n   if (overlay.a == 0.0 || ((base.g / overlay.g) > (base.a / overlay.a)))\n     ga = overlay.a * base.a + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n   else\n     ga = (base.g * overlay.a * overlay.a) / overlay.g + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n \n   \n   mediump float ba;\n   if (overlay.a == 0.0 || ((base.b / overlay.b) > (base.a / overlay.a)))\n     ba = overlay.a * base.a + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n   else\n     ba = (base.b * overlay.a * overlay.a) / overlay.b + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n \n   mediump float a = overlay.a + base.a - overlay.a * base.a;\n   \n  gl_FragColor = vec4(ra, ga, ba, a);\n }\n "
public let Erosion1FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     \n     lowp vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);\n     \n     gl_FragColor = min(minValue, oneStepNegativeIntensity);\n }\n "
public let Erosion2FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);\n     lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);\n     \n     lowp vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);\n     minValue = min(minValue, oneStepNegativeIntensity);\n     minValue = min(minValue, twoStepsPositiveIntensity);\n     \n     gl_FragColor = min(minValue, twoStepsNegativeIntensity);\n }\n "
public let Erosion3FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n varying vec2 threeStepsPositiveTextureCoordinate;\n varying vec2 threeStepsNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);\n     lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);\n     lowp vec4 threeStepsPositiveIntensity = texture2D(inputImageTexture, threeStepsPositiveTextureCoordinate);\n     lowp vec4 threeStepsNegativeIntensity = texture2D(inputImageTexture, threeStepsNegativeTextureCoordinate);\n     \n     lowp vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);\n     minValue = min(minValue, oneStepNegativeIntensity);\n     minValue = min(minValue, twoStepsPositiveIntensity);\n     minValue = min(minValue, twoStepsNegativeIntensity);\n     minValue = min(minValue, threeStepsPositiveIntensity);\n     \n     gl_FragColor = min(minValue, threeStepsNegativeIntensity);\n }\n "
public let Erosion4FragmentShader = "precision highp float;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n varying vec2 threeStepsPositiveTextureCoordinate;\n varying vec2 threeStepsNegativeTextureCoordinate;\n varying vec2 fourStepsPositiveTextureCoordinate;\n varying vec2 fourStepsNegativeTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);\n     lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);\n     lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);\n     lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);\n     lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);\n     lowp vec4 threeStepsPositiveIntensity = texture2D(inputImageTexture, threeStepsPositiveTextureCoordinate);\n     lowp vec4 threeStepsNegativeIntensity = texture2D(inputImageTexture, threeStepsNegativeTextureCoordinate);\n     lowp vec4 fourStepsPositiveIntensity = texture2D(inputImageTexture, fourStepsPositiveTextureCoordinate);\n     lowp vec4 fourStepsNegativeIntensity = texture2D(inputImageTexture, fourStepsNegativeTextureCoordinate);\n     \n     lowp vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);\n     minValue = min(minValue, oneStepNegativeIntensity);\n     minValue = min(minValue, twoStepsPositiveIntensity);\n     minValue = min(minValue, twoStepsNegativeIntensity);\n     minValue = min(minValue, threeStepsPositiveIntensity);\n     minValue = min(minValue, threeStepsNegativeIntensity);\n     minValue = min(minValue, fourStepsPositiveIntensity);\n     \n     gl_FragColor = min(minValue, fourStepsNegativeIntensity);\n }\n "
public let ErosionDilation1VertexShader = "attribute vec4 position;\n attribute vec2 inputTextureCoordinate;\n \n uniform float texelWidth; \n uniform float texelHeight; \n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 offset = vec2(texelWidth, texelHeight);\n     \n     centerTextureCoordinate = inputTextureCoordinate;\n     oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;\n     oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;\n }\n "
public let ErosionDilation2VertexShader = "attribute vec4 position;\n attribute vec2 inputTextureCoordinate;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 offset = vec2(texelWidth, texelHeight);\n     \n     centerTextureCoordinate = inputTextureCoordinate;\n     oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;\n     oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;\n     twoStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 2.0);\n     twoStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 2.0);\n }\n "
public let ErosionDilation3VertexShader = "attribute vec4 position;\n attribute vec2 inputTextureCoordinate;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n varying vec2 threeStepsPositiveTextureCoordinate;\n varying vec2 threeStepsNegativeTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 offset = vec2(texelWidth, texelHeight);\n     \n     centerTextureCoordinate = inputTextureCoordinate;\n     oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;\n     oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;\n     twoStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 2.0);\n     twoStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 2.0);\n     threeStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 3.0);\n     threeStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 3.0);\n }\n "
public let ErosionDilation4VertexShader = "attribute vec4 position;\n attribute vec2 inputTextureCoordinate;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepPositiveTextureCoordinate;\n varying vec2 oneStepNegativeTextureCoordinate;\n varying vec2 twoStepsPositiveTextureCoordinate;\n varying vec2 twoStepsNegativeTextureCoordinate;\n varying vec2 threeStepsPositiveTextureCoordinate;\n varying vec2 threeStepsNegativeTextureCoordinate;\n varying vec2 fourStepsPositiveTextureCoordinate;\n varying vec2 fourStepsNegativeTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 offset = vec2(texelWidth, texelHeight);\n     \n     centerTextureCoordinate = inputTextureCoordinate;\n     oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;\n     oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;\n     twoStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 2.0);\n     twoStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 2.0);\n     threeStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 3.0);\n     threeStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 3.0);\n     fourStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 4.0);\n     fourStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 4.0);\n }\n "
public let ExclusionBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     //     Dca = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)\n     \n     gl_FragColor = vec4((overlay.rgb * base.a + base.rgb * overlay.a - 2.0 * overlay.rgb * base.rgb) + overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a), base.a);\n }\n "
public let ExposureFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform highp float exposure;\n \n void main()\n {\n     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);\n }\n "
public let FalseColorFragmentShader = "precision lowp float;\n \n varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform float intensity;\n uniform vec3 firstColor;\n uniform vec3 secondColor;\n \n const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     float luminance = dot(textureColor.rgb, luminanceWeighting);\n     \n     gl_FragColor = vec4( mix(firstColor.rgb, secondColor.rgb, luminance), textureColor.a);\n }\n "
public let FiveInputVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n attribute vec4 inputTextureCoordinate2;\n attribute vec4 inputTextureCoordinate3;\n attribute vec4 inputTextureCoordinate4;\n attribute vec4 inputTextureCoordinate5;\n \n varying vec2 textureCoordinate;\n varying vec2 textureCoordinate2;\n varying vec2 textureCoordinate3;\n varying vec2 textureCoordinate4;\n varying vec2 textureCoordinate5;\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = inputTextureCoordinate.xy;\n     textureCoordinate2 = inputTextureCoordinate2.xy;\n     textureCoordinate3 = inputTextureCoordinate3.xy;\n     textureCoordinate4 = inputTextureCoordinate4.xy;\n     textureCoordinate5 = inputTextureCoordinate5.xy;\n }\n "
public let FourInputVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n attribute vec4 inputTextureCoordinate2;\n attribute vec4 inputTextureCoordinate3;\n attribute vec4 inputTextureCoordinate4;\n \n varying vec2 textureCoordinate;\n varying vec2 textureCoordinate2;\n varying vec2 textureCoordinate3;\n varying vec2 textureCoordinate4;\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = inputTextureCoordinate.xy;\n     textureCoordinate2 = inputTextureCoordinate2.xy;\n     textureCoordinate3 = inputTextureCoordinate3.xy;\n     textureCoordinate4 = inputTextureCoordinate4.xy;\n }\n "
public let GammaFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float gamma;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);\n }\n "
public let GlassSphereFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp vec2 center;\n uniform highp float radius;\n uniform highp float aspectRatio;\n uniform highp float refractiveIndex;\n // uniform vec3 lightPosition;\n const highp vec3 lightPosition = vec3(-0.5, 0.5, 1.0);\n const highp vec3 ambientLightPosition = vec3(0.0, 0.0, 1.0);\n \n void main()\n {\n  highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n  highp float distanceFromCenter = distance(center, textureCoordinateToUse);\n  lowp float checkForPresenceWithinSphere = step(distanceFromCenter, radius);\n  \n  distanceFromCenter = distanceFromCenter / radius;\n  \n  highp float normalizedDepth = radius * sqrt(1.0 - distanceFromCenter * distanceFromCenter);\n  highp vec3 sphereNormal = normalize(vec3(textureCoordinateToUse - center, normalizedDepth));\n  \n  highp vec3 refractedVector = 2.0 * refract(vec3(0.0, 0.0, -1.0), sphereNormal, refractiveIndex);\n  refractedVector.xy = -refractedVector.xy;\n  \n  highp vec3 finalSphereColor = texture2D(inputImageTexture, (refractedVector.xy + 1.0) * 0.5).rgb;\n  \n  // Grazing angle lighting\n  highp float lightingIntensity = 2.5 * (1.0 - pow(clamp(dot(ambientLightPosition, sphereNormal), 0.0, 1.0), 0.25));\n  finalSphereColor += lightingIntensity;\n  \n  // Specular lighting\n  lightingIntensity  = clamp(dot(normalize(lightPosition), sphereNormal), 0.0, 1.0);\n  lightingIntensity  = pow(lightingIntensity, 15.0);\n  finalSphereColor += vec3(0.8, 0.8, 0.8) * lightingIntensity;\n  \n  gl_FragColor = vec4(finalSphereColor, 1.0) * checkForPresenceWithinSphere;\n }\n "
public let HalftoneFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float fractionalWidthOfPixel;\n uniform highp float aspectRatio;\n uniform highp float dotScaling;\n \n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);\n     \n     highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;\n     highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n     highp vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n     highp float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse);\n     \n     lowp vec3 sampledColor = texture2D(inputImageTexture, samplePos ).rgb;\n     highp float dotScaling = 1.0 - dot(sampledColor, W);\n    \n     lowp float checkForPresenceWithinDot = 1.0 - step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling);\n     \n     gl_FragColor = vec4(vec3(checkForPresenceWithinDot), 1.0);\n }\n "
public let HardLightBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n \n     highp float ra;\n     if (2.0 * overlay.r < overlay.a) {\n         ra = 2.0 * overlay.r * base.r + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n     } else {\n         ra = overlay.a * base.a - 2.0 * (base.a - base.r) * (overlay.a - overlay.r) + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n     }\n     \n     highp float ga;\n     if (2.0 * overlay.g < overlay.a) {\n         ga = 2.0 * overlay.g * base.g + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n     } else {\n         ga = overlay.a * base.a - 2.0 * (base.a - base.g) * (overlay.a - overlay.g) + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n     }\n     \n     highp float ba;\n     if (2.0 * overlay.b < overlay.a) {\n         ba = 2.0 * overlay.b * base.b + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n     } else {\n         ba = overlay.a * base.a - 2.0 * (base.a - base.b) * (overlay.a - overlay.b) + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n     }\n     \n     gl_FragColor = vec4(ra, ga, ba, 1.0);\n }\n "
public let HarrisCornerDetectorFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float sensitivity;\n \n const mediump float harrisConstant = 0.04;\n \n void main()\n {\n     mediump vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;\n     \n     mediump float derivativeSum = derivativeElements.x + derivativeElements.y;\n     \n     mediump float zElement = (derivativeElements.z * 2.0) - 1.0;\n \n     // R = Ix^2 * Iy^2 - Ixy * Ixy - k * (Ix^2 + Iy^2)^2\n     mediump float cornerness = derivativeElements.x * derivativeElements.y - (zElement * zElement) - harrisConstant * derivativeSum * derivativeSum;\n     \n     gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);\n }\n "
public let HazeFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform lowp float hazeDistance;\n uniform highp float slope;\n \n void main()\n {\n //todo reconsider precision modifiers\n  highp vec4 color = vec4(1.0);//todo reimplement as a parameter\n  \n  highp float  d = textureCoordinate.y * slope  +  hazeDistance;\n  \n  highp vec4 c = texture2D(inputImageTexture, textureCoordinate) ; // consider using unpremultiply\n  \n  c = (c - d * color) / (1.0 -d);\n  \n  gl_FragColor = c; //consider using premultiply(c);\n }\n "
public let HighlightShadowTintFragmentShader = "precision lowp float;\n \n varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float shadowTintIntensity;\n uniform lowp float highlightTintIntensity;\n uniform highp vec3 shadowTintColor;\n uniform highp vec3 highlightTintColor;\n \n const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n    lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n    highp float luminance = dot(textureColor.rgb, luminanceWeighting);\n     \n    highp vec4 shadowResult = mix(textureColor, max(textureColor, vec4( mix(shadowTintColor, textureColor.rgb, luminance), textureColor.a)), shadowTintIntensity);\n    highp vec4 highlightResult = mix(textureColor, min(shadowResult, vec4( mix(shadowResult.rgb, highlightTintColor, luminance), textureColor.a)), highlightTintIntensity);\n \n    gl_FragColor = vec4( mix(shadowResult.rgb, highlightResult.rgb, luminance), textureColor.a);\n }\n "
public let HighlightShadowFragmentShader = "uniform sampler2D inputImageTexture;\n varying highp vec2 textureCoordinate;\n  \n uniform lowp float shadows;\n uniform lowp float highlights;\n \n const mediump vec3 luminanceWeighting = vec3(0.3, 0.3, 0.3);\n \n void main()\n {\n     lowp vec4 source = texture2D(inputImageTexture, textureCoordinate);\n     mediump float luminance = dot(source.rgb, luminanceWeighting);\n \n     mediump float shadow = clamp((pow(luminance, 1.0/(shadows+1.0)) + (-0.76)*pow(luminance, 2.0/(shadows+1.0))) - luminance, 0.0, 1.0);\n     mediump float highlight = clamp((1.0 - (pow(1.0-luminance, 1.0/(2.0-highlights)) + (-0.8)*pow(1.0-luminance, 2.0/(2.0-highlights)))) - luminance, -1.0, 0.0);\n     lowp vec3 result = vec3(0.0, 0.0, 0.0) + ((luminance + shadow + highlight) - 0.0) * ((source.rgb - vec3(0.0, 0.0, 0.0))/(luminance - 0.0));\n     gl_FragColor = vec4(result.rgb, source.a);\n }\n "
public let HistogramAccumulationFragmentShader = "const lowp float scalingFactor = 1.0 / 256.0;\n \n varying lowp vec3 colorFactor;\n \n void main()\n {\n     gl_FragColor = vec4(colorFactor * scalingFactor , 1.0);\n }\n "
public let HistogramBlueSamplingVertexShader = "attribute vec4 position;\n \n varying vec3 colorFactor;\n \n void main()\n {\n     colorFactor = vec3(0.0, 0.0, 1.0);\n     gl_Position = vec4(-1.0 + (position.z * 0.0078125), 0.0, 0.0, 1.0);\n     gl_PointSize = 1.0;\n }\n "
public let HistogramDisplayVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n varying vec2 textureCoordinate;\n varying float height;\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = vec2(inputTextureCoordinate.x, 0.5);\n     height = 1.0 - inputTextureCoordinate.y;\n }\n "
public let HistogramDisplayFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp float height;\n \n uniform sampler2D inputImageTexture;\n lowp vec4 backgroundColor = vec4(0.0, 0.0, 0.0, 0.0);\n \n void main()\n {\n     lowp vec3 colorChannels = texture2D(inputImageTexture, textureCoordinate).rgb;\n     lowp vec4 heightTest = vec4(step(height, colorChannels), 1.0);\n     gl_FragColor = mix(backgroundColor, heightTest, heightTest.r + heightTest.g + heightTest.b);\n }\n "
public let HistogramEqualizationBlueFragmentShader = "varying highp vec2 textureCoordinate;\n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float blueCurveValue = texture2D(inputImageTexture2, vec2(textureColor.b, 0.0)).b;\n     \n     gl_FragColor = vec4(textureColor.r, textureColor.g, blueCurveValue, textureColor.a);\n }\n "
public let HistogramEqualizationGreenFragmentShader = "varying highp vec2 textureCoordinate;\n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float greenCurveValue = texture2D(inputImageTexture2, vec2(textureColor.g, 0.0)).g;\n     \n     gl_FragColor = vec4(textureColor.r, greenCurveValue, textureColor.b, textureColor.a);\n }\n "
public let HistogramEqualizationLuminanceFragmentShader = "varying highp vec2 textureCoordinate;\n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n const lowp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float luminance = dot(textureColor.rgb, W);\n     lowp float newLuminance = texture2D(inputImageTexture2, vec2(luminance, 0.0)).r;\n     lowp float deltaLuminance = newLuminance - luminance;\n     \n     lowp float red   = clamp(textureColor.r + deltaLuminance, 0.0, 1.0);\n     lowp float green = clamp(textureColor.g + deltaLuminance, 0.0, 1.0);\n     lowp float blue  = clamp(textureColor.b + deltaLuminance, 0.0, 1.0);\n \n     gl_FragColor = vec4(red, green, blue, textureColor.a);\n }\n "
public let HistogramEqualizationRGBFragmentShader = "varying highp vec2 textureCoordinate; \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float redCurveValue = texture2D(inputImageTexture2, vec2(textureColor.r, 0.0)).r;\n     lowp float greenCurveValue = texture2D(inputImageTexture2, vec2(textureColor.g, 0.0)).g;\n     lowp float blueCurveValue = texture2D(inputImageTexture2, vec2(textureColor.b, 0.0)).b;\n     \n     gl_FragColor = vec4(redCurveValue, greenCurveValue, blueCurveValue, textureColor.a);\n }\n "
public let HistogramEqualizationRedFragmentShader = "varying highp vec2 textureCoordinate;\n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float redCurveValue = texture2D(inputImageTexture2, vec2(textureColor.r, 0.0)).r;\n     \n     gl_FragColor = vec4(redCurveValue, textureColor.g, textureColor.b, textureColor.a);\n }\n "
public let HistogramGreenSamplingVertexShader = "attribute vec4 position;\n \n varying vec3 colorFactor;\n \n void main()\n {\n     colorFactor = vec3(0.0, 1.0, 0.0);\n     gl_Position = vec4(-1.0 + (position.y * 0.0078125), 0.0, 0.0, 1.0);\n     gl_PointSize = 1.0;\n }\n "
public let HistogramLuminanceSamplingVertexShader = "attribute vec4 position;\n \n varying vec3 colorFactor;\n \n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     float luminance = dot(position.xyz, W);\n \n     colorFactor = vec3(1.0, 1.0, 1.0);\n     gl_Position = vec4(-1.0 + (luminance * 0.0078125), 0.0, 0.0, 1.0);\n     gl_PointSize = 1.0;\n }\n "
public let HistogramRedSamplingVertexShader = "attribute vec4 position;\n \n varying vec3 colorFactor;\n \n void main()\n {\n     colorFactor = vec3(1.0, 0.0, 0.0);\n     gl_Position = vec4(-1.0 + (position.x * 0.0078125), 0.0, 0.0, 1.0);\n     gl_PointSize = 1.0;\n }\n "
public let HueBlendFragmentShader = "// Hue blend mode based upon pseudo code from the PDF specification.\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n highp float lum(lowp vec3 c) {\n     return dot(c, vec3(0.3, 0.59, 0.11));\n }\n \n lowp vec3 clipcolor(lowp vec3 c) {\n     highp float l = lum(c);\n     lowp float n = min(min(c.r, c.g), c.b);\n     lowp float x = max(max(c.r, c.g), c.b);\n     \n     if (n < 0.0) {\n         c.r = l + ((c.r - l) * l) / (l - n);\n         c.g = l + ((c.g - l) * l) / (l - n);\n         c.b = l + ((c.b - l) * l) / (l - n);\n     }\n     if (x > 1.0) {\n         c.r = l + ((c.r - l) * (1.0 - l)) / (x - l);\n         c.g = l + ((c.g - l) * (1.0 - l)) / (x - l);\n         c.b = l + ((c.b - l) * (1.0 - l)) / (x - l);\n     }\n     \n     return c;\n }\n \n lowp vec3 setlum(lowp vec3 c, highp float l) {\n     highp float d = l - lum(c);\n     c = c + vec3(d);\n     return clipcolor(c);\n }\n \n highp float sat(lowp vec3 c) {\n     lowp float n = min(min(c.r, c.g), c.b);\n     lowp float x = max(max(c.r, c.g), c.b);\n     return x - n;\n }\n \n lowp float mid(lowp float cmin, lowp float cmid, lowp float cmax, highp float s) {\n     return ((cmid - cmin) * s) / (cmax - cmin);\n }\n \n lowp vec3 setsat(lowp vec3 c, highp float s) {\n     if (c.r > c.g) {\n         if (c.r > c.b) {\n             if (c.g > c.b) {\n                 /* g is mid, b is min */\n                 c.g = mid(c.b, c.g, c.r, s);\n                 c.b = 0.0;\n             } else {\n                 /* b is mid, g is min */\n                 c.b = mid(c.g, c.b, c.r, s);\n                 c.g = 0.0;\n             }\n             c.r = s;\n         } else {\n             /* b is max, r is mid, g is min */\n             c.r = mid(c.g, c.r, c.b, s);\n             c.b = s;\n             c.r = 0.0;\n         }\n     } else if (c.r > c.b) {\n         /* g is max, r is mid, b is min */\n         c.r = mid(c.b, c.r, c.g, s);\n         c.g = s;\n         c.b = 0.0;\n     } else if (c.g > c.b) {\n         /* g is max, b is mid, r is min */\n         c.b = mid(c.r, c.b, c.g, s);\n         c.g = s;\n         c.r = 0.0;\n     } else if (c.b > c.g) {\n         /* b is max, g is mid, r is min */\n         c.g = mid(c.r, c.g, c.b, s);\n         c.b = s;\n         c.r = 0.0;\n     } else {\n         c = vec3(0.0);\n     }\n     return c;\n }\n \n void main()\n {\n  highp vec4 baseColor = texture2D(inputImageTexture, textureCoordinate);\n  highp vec4 overlayColor = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     gl_FragColor = vec4(baseColor.rgb * (1.0 - overlayColor.a) + setlum(setsat(overlayColor.rgb, sat(baseColor.rgb)), lum(baseColor.rgb)) * overlayColor.a, baseColor.a);\n }\n "
public let HueFragmentShader = "precision highp float;\n varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform mediump float hueAdjust;\n const highp  vec4  kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);\n const highp  vec4  kRGBToI     = vec4 (0.595716, -0.274453, -0.321263, 0.0);\n const highp  vec4  kRGBToQ     = vec4 (0.211456, -0.522591, 0.31135, 0.0);\n \n const highp  vec4  kYIQToR   = vec4 (1.0, 0.9563, 0.6210, 0.0);\n const highp  vec4  kYIQToG   = vec4 (1.0, -0.2721, -0.6474, 0.0);\n const highp  vec4  kYIQToB   = vec4 (1.0, -1.1070, 1.7046, 0.0);\n \n void main ()\n {\n     // Sample the input pixel\n     highp vec4 color   = texture2D(inputImageTexture, textureCoordinate);\n     \n     // Convert to YIQ\n     highp float   YPrime  = dot (color, kRGBToYPrime);\n     highp float   I      = dot (color, kRGBToI);\n     highp float   Q      = dot (color, kRGBToQ);\n     \n     // Calculate the hue and chroma\n     highp float   hue     = atan (Q, I);\n     highp float   chroma  = sqrt (I * I + Q * Q);\n     \n     // Make the user's adjustments\n     hue += (-hueAdjust); //why negative rotation?\n     \n     // Convert back to YIQ\n     Q = chroma * sin (hue);\n     I = chroma * cos (hue);\n     \n     // Convert back to RGB\n     highp vec4    yIQ   = vec4 (YPrime, I, Q, 0.0);\n     color.r = dot (yIQ, kYIQToR);\n     color.g = dot (yIQ, kYIQToG);\n     color.b = dot (yIQ, kYIQToB);\n     \n     // Save the result\n     gl_FragColor = color;\n }\n "
public let KuwaharaRadius3FragmentShader = "// Sourced from Kyprianidis, J. E., Kang, H., and Doellner, J. \"Anisotropic Kuwahara Filtering on the GPU,\" GPU Pro p.247 (2010).\n // \n // Original header:\n // \n // Anisotropic Kuwahara Filtering on the GPU\n // by Jan Eric Kyprianidis <www.kyprianidis.com>\n \n varying highp vec2 textureCoordinate;\n uniform sampler2D inputImageTexture;\n \n precision highp float;\n \n const vec2 src_size = vec2 (1.0 / 768.0, 1.0 / 1024.0);\n \n void main (void)\n {\n     vec2 uv = textureCoordinate;\n     float n = float(16); // radius is assumed to be 3\n     vec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);\n     vec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);\n     vec3 c;\n     vec3 cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(-3,-3) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-3,-2) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-3,-1) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-3,0) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m1 += c;\n     s1 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(-2,-3) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-2,-2) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-2,-1) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-2,0) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m1 += c;\n     s1 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(-1,-3) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-1,-2) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-1,-1) * src_size).rgb;\n     m0 += c;\n     s0 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-1,0) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m1 += c;\n     s1 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(0,-3) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m3 += c;\n     s3 += cSq;\n     c = texture2D(inputImageTexture, uv + vec2(0,-2) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m3 += c;\n     s3 += cSq;\n     c = texture2D(inputImageTexture, uv + vec2(0,-1) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m3 += c;\n     s3 += cSq;\n     c = texture2D(inputImageTexture, uv + vec2(0,0) * src_size).rgb;\n     cSq = c * c;\n     m0 += c;\n     s0 += cSq;\n     m1 += c;\n     s1 += cSq;\n     m2 += c;\n     s2 += cSq;\n     m3 += c;\n     s3 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(-3,3) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-3,2) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-3,1) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n \n     c = texture2D(inputImageTexture, uv + vec2(-2,3) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-2,2) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-2,1) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n \n     c = texture2D(inputImageTexture, uv + vec2(-1,3) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-1,2) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(-1,1) * src_size).rgb;\n     m1 += c;\n     s1 += c * c;\n \n     c = texture2D(inputImageTexture, uv + vec2(0,3) * src_size).rgb;\n     cSq = c * c;\n     m1 += c;\n     s1 += cSq;\n     m2 += c;\n     s2 += cSq;\n     c = texture2D(inputImageTexture, uv + vec2(0,2) * src_size).rgb;\n     cSq = c * c;\n     m1 += c;\n     s1 += cSq;\n     m2 += c;\n     s2 += cSq;\n     c = texture2D(inputImageTexture, uv + vec2(0,1) * src_size).rgb;\n     cSq = c * c;\n     m1 += c;\n     s1 += cSq;\n     m2 += c;\n     s2 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(3,3) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(3,2) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(3,1) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(3,0) * src_size).rgb;\n     cSq = c * c;\n     m2 += c;\n     s2 += cSq;\n     m3 += c;\n     s3 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(2,3) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(2,2) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(2,1) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(2,0) * src_size).rgb;\n     cSq = c * c;\n     m2 += c;\n     s2 += cSq;\n     m3 += c;\n     s3 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(1,3) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(1,2) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(1,1) * src_size).rgb;\n     m2 += c;\n     s2 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(1,0) * src_size).rgb;\n     cSq = c * c;\n     m2 += c;\n     s2 += cSq;\n     m3 += c;\n     s3 += cSq;\n \n     c = texture2D(inputImageTexture, uv + vec2(3,-3) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(3,-2) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(3,-1) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n \n     c = texture2D(inputImageTexture, uv + vec2(2,-3) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(2,-2) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(2,-1) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n \n     c = texture2D(inputImageTexture, uv + vec2(1,-3) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(1,-2) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n     c = texture2D(inputImageTexture, uv + vec2(1,-1) * src_size).rgb;\n     m3 += c;\n     s3 += c * c;\n \n     float min_sigma2 = 1e+2;\n     m0 /= n;\n     s0 = abs(s0 / n - m0 * m0);\n \n     float sigma2 = s0.r + s0.g + s0.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m0, 1.0);\n     }\n \n     m1 /= n;\n     s1 = abs(s1 / n - m1 * m1);\n \n     sigma2 = s1.r + s1.g + s1.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m1, 1.0);\n     }\n \n     m2 /= n;\n     s2 = abs(s2 / n - m2 * m2);\n \n     sigma2 = s2.r + s2.g + s2.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m2, 1.0);\n     }\n \n     m3 /= n;\n     s3 = abs(s3 / n - m3 * m3);\n \n     sigma2 = s3.r + s3.g + s3.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m3, 1.0);\n     }\n }\n "
public let KuwaharaFragmentShader = "// Sourced from Kyprianidis, J. E., Kang, H., and Doellner, J. \"Anisotropic Kuwahara Filtering on the GPU,\" GPU Pro p.247 (2010).\n // \n // Original header:\n // \n // Anisotropic Kuwahara Filtering on the GPU\n // by Jan Eric Kyprianidis <www.kyprianidis.com>\n \n varying highp vec2 textureCoordinate;\n uniform sampler2D inputImageTexture;\n uniform int radius;\n \n precision highp float;\n \n const vec2 src_size = vec2 (1.0 / 768.0, 1.0 / 1024.0);\n \n void main (void) \n {\n     vec2 uv = textureCoordinate;\n     float n = float((radius + 1) * (radius + 1));\n     int i; int j;\n     vec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);\n     vec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);\n     vec3 c;\n \n     for (j = -radius; j <= 0; ++j)  {\n         for (i = -radius; i <= 0; ++i)  {\n             c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;\n             m0 += c;\n             s0 += c * c;\n         }\n     }\n \n     for (j = -radius; j <= 0; ++j)  {\n         for (i = 0; i <= radius; ++i)  {\n             c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;\n             m1 += c;\n             s1 += c * c;\n         }\n     }\n \n     for (j = 0; j <= radius; ++j)  {\n         for (i = 0; i <= radius; ++i)  {\n             c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;\n             m2 += c;\n             s2 += c * c;\n         }\n     }\n \n     for (j = 0; j <= radius; ++j)  {\n         for (i = -radius; i <= 0; ++i)  {\n             c = texture2D(inputImageTexture, uv + vec2(i,j) * src_size).rgb;\n             m3 += c;\n             s3 += c * c;\n         }\n     }\n \n \n     float min_sigma2 = 1e+2;\n     m0 /= n;\n     s0 = abs(s0 / n - m0 * m0);\n \n     float sigma2 = s0.r + s0.g + s0.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m0, 1.0);\n     }\n \n     m1 /= n;\n     s1 = abs(s1 / n - m1 * m1);\n \n     sigma2 = s1.r + s1.g + s1.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m1, 1.0);\n     }\n \n     m2 /= n;\n     s2 = abs(s2 / n - m2 * m2);\n \n     sigma2 = s2.r + s2.g + s2.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m2, 1.0);\n     }\n \n     m3 /= n;\n     s3 = abs(s3 / n - m3 * m3);\n \n     sigma2 = s3.r + s3.g + s3.b;\n     if (sigma2 < min_sigma2) {\n         min_sigma2 = sigma2;\n         gl_FragColor = vec4(m3, 1.0);\n     }\n }\n "
public let LanczosResamplingVertexShader = "attribute vec4 position;\n attribute vec2 inputTextureCoordinate;\n \n uniform float texelWidth;\n uniform float texelHeight;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepLeftTextureCoordinate;\n varying vec2 twoStepsLeftTextureCoordinate;\n varying vec2 threeStepsLeftTextureCoordinate;\n varying vec2 fourStepsLeftTextureCoordinate;\n varying vec2 oneStepRightTextureCoordinate;\n varying vec2 twoStepsRightTextureCoordinate;\n varying vec2 threeStepsRightTextureCoordinate;\n varying vec2 fourStepsRightTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 firstOffset = vec2(texelWidth, texelHeight);\n     vec2 secondOffset = vec2(2.0 * texelWidth, 2.0 * texelHeight);\n     vec2 thirdOffset = vec2(3.0 * texelWidth, 3.0 * texelHeight);\n     vec2 fourthOffset = vec2(4.0 * texelWidth, 4.0 * texelHeight);\n     \n     centerTextureCoordinate = inputTextureCoordinate;\n     oneStepLeftTextureCoordinate = inputTextureCoordinate - firstOffset;\n     twoStepsLeftTextureCoordinate = inputTextureCoordinate - secondOffset;\n     threeStepsLeftTextureCoordinate = inputTextureCoordinate - thirdOffset;\n     fourStepsLeftTextureCoordinate = inputTextureCoordinate - fourthOffset;\n     oneStepRightTextureCoordinate = inputTextureCoordinate + firstOffset;\n     twoStepsRightTextureCoordinate = inputTextureCoordinate + secondOffset;\n     threeStepsRightTextureCoordinate = inputTextureCoordinate + thirdOffset;\n     fourStepsRightTextureCoordinate = inputTextureCoordinate + fourthOffset;\n }\n "
public let LanczosResamplingFragmentShader = "precision highp float;\n \n uniform sampler2D inputImageTexture;\n \n varying vec2 centerTextureCoordinate;\n varying vec2 oneStepLeftTextureCoordinate;\n varying vec2 twoStepsLeftTextureCoordinate;\n varying vec2 threeStepsLeftTextureCoordinate;\n varying vec2 fourStepsLeftTextureCoordinate;\n varying vec2 oneStepRightTextureCoordinate;\n varying vec2 twoStepsRightTextureCoordinate;\n varying vec2 threeStepsRightTextureCoordinate;\n varying vec2 fourStepsRightTextureCoordinate;\n \n // sinc(x) * sinc(x/a) = (a * sin(pi * x) * sin(pi * x / a)) / (pi^2 * x^2)\n // Assuming a Lanczos constant of 2.0, and scaling values to max out at x = +/- 1.5\n \n void main()\n {\n     lowp vec4 fragmentColor = texture2D(inputImageTexture, centerTextureCoordinate) * 0.38026;\n     \n     fragmentColor += texture2D(inputImageTexture, oneStepLeftTextureCoordinate) * 0.27667;\n     fragmentColor += texture2D(inputImageTexture, oneStepRightTextureCoordinate) * 0.27667;\n     \n     fragmentColor += texture2D(inputImageTexture, twoStepsLeftTextureCoordinate) * 0.08074;\n     fragmentColor += texture2D(inputImageTexture, twoStepsRightTextureCoordinate) * 0.08074;\n \n     fragmentColor += texture2D(inputImageTexture, threeStepsLeftTextureCoordinate) * -0.02612;\n     fragmentColor += texture2D(inputImageTexture, threeStepsRightTextureCoordinate) * -0.02612;\n \n     fragmentColor += texture2D(inputImageTexture, fourStepsLeftTextureCoordinate) * -0.02143;\n     fragmentColor += texture2D(inputImageTexture, fourStepsRightTextureCoordinate) * -0.02143;\n \n     gl_FragColor = fragmentColor;\n }\n "
public let LaplacianFragmentShader = "precision highp float;\n \n uniform sampler2D inputImageTexture;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n void main()\n {\n     mediump vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;\n     mediump vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;\n     mediump vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;\n     mediump vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;\n     mediump vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;\n     mediump vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;\n     mediump vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;\n     mediump vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;\n     \n     mediump vec3 resultColor = topLeftColor * 0.5 + topColor * 1.0 + topRightColor * 0.5;\n     resultColor += leftColor * 1.0 + centerColor.rgb * (-6.0) + rightColor * 1.0;\n     resultColor += bottomLeftColor * 0.5 + bottomColor * 1.0 + bottomRightColor * 0.5;\n     \n     // Normalize the results to allow for negative gradients in the 0.0-1.0 colorspace\n     resultColor = resultColor + 0.5;\n     \n     gl_FragColor = vec4(resultColor, centerColor.a);\n }\n "
public let LevelsFragmentShader = "/*\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  ** 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 - minInput, vec3(0.0)) / (maxInput - minInput), vec3(1.0))\n #define LevelsControlInput(color, minInput, gamma, maxInput)    GammaCorrection(LevelsControlInputRange(color, minInput, maxInput), gamma)\n #define LevelsControlOutputRange(color, minOutput, maxOutput)   mix(minOutput, maxOutput, color)\n #define LevelsControl(color, minInput, gamma, maxInput, minOutput, maxOutput)  LevelsControlOutputRange(LevelsControlInput(color, minInput, gamma, maxInput), minOutput, maxOutput)\n \n varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform mediump vec3 levelMinimum;\n uniform mediump vec3 levelMiddle;\n uniform mediump vec3 levelMaximum;\n uniform mediump vec3 minOutput;\n uniform mediump vec3 maxOutput;\n \n void main()\n {\n     mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = vec4(LevelsControl(textureColor.rgb, levelMinimum, levelMiddle, levelMaximum, minOutput, maxOutput), textureColor.a);\n }\n "
public let LightenBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n    lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n    lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n    \n    gl_FragColor = max(textureColor, textureColor2);\n }\n "
public let LineVertexShader = "attribute vec4 position;\n \n void main()\n {\n     gl_Position = position;\n }\n "
public let LineFragmentShader = "uniform lowp vec3 lineColor;\n \n void main()\n {\n     gl_FragColor = vec4(lineColor, 1.0);\n }\n "
public let LinearBurnBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     gl_FragColor = vec4(clamp(textureColor.rgb + textureColor2.rgb - vec3(1.0), vec3(0.0), vec3(1.0)), textureColor.a);\n }\n "
public let LocalBinaryPatternFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     lowp float centerIntensity = texture2D(inputImageTexture, textureCoordinate).r;\n     lowp float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     lowp float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     lowp float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     lowp float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     lowp float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     lowp float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     lowp float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     lowp float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n \n     lowp float byteTally = 1.0 / 255.0 * step(centerIntensity, topRightIntensity);\n     byteTally += 2.0 / 255.0 * step(centerIntensity, topIntensity);\n     byteTally += 4.0 / 255.0 * step(centerIntensity, topLeftIntensity);\n     byteTally += 8.0 / 255.0 * step(centerIntensity, leftIntensity);\n     byteTally += 16.0 / 255.0 * step(centerIntensity, bottomLeftIntensity);\n     byteTally += 32.0 / 255.0 * step(centerIntensity, bottomIntensity);\n     byteTally += 64.0 / 255.0 * step(centerIntensity, bottomRightIntensity);\n     byteTally += 128.0 / 255.0 * step(centerIntensity, rightIntensity);\n          \n     // TODO: Replace the above with a dot product and two vec4s\n     // TODO: Apply step to a matrix, rather than individually\n     \n     gl_FragColor = vec4(byteTally, byteTally, byteTally, 1.0);\n }\n "
public let LookupFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2; // lookup texture\n \n uniform lowp float intensity;\n \n void main()\n {\n     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     highp float blueColor = textureColor.b * 63.0;\n     \n     highp vec2 quad1;\n     quad1.y = floor(floor(blueColor) / 8.0);\n     quad1.x = floor(blueColor) - (quad1.y * 8.0);\n     \n     highp vec2 quad2;\n     quad2.y = floor(ceil(blueColor) / 8.0);\n     quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n     \n     highp vec2 texPos1;\n     texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n     texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);\n     \n     highp vec2 texPos2;\n     texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n     texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);\n     \n     lowp vec4 newColor1 = texture2D(inputImageTexture2, texPos1);\n     lowp vec4 newColor2 = texture2D(inputImageTexture2, texPos2);\n     \n     lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n     gl_FragColor = mix(textureColor, vec4(newColor.rgb, textureColor.w), intensity);\n }\n "
public let LuminanceRangeFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float rangeReduction;\n \n // Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     mediump float luminance = dot(textureColor.rgb, luminanceWeighting);\n     mediump float luminanceRatio = ((0.5 - luminance) * rangeReduction);\n     \n     gl_FragColor = vec4((textureColor.rgb) + (luminanceRatio), textureColor.w);\n }\n "
public let LuminanceThresholdFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform highp float threshold;\n \n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     highp float luminance = dot(textureColor.rgb, W);\n     highp float thresholdResult = step(threshold, luminance);\n     \n     gl_FragColor = vec4(vec3(thresholdResult), textureColor.w);\n }\n "
public let LuminanceFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n // Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     float luminance = dot(textureColor.rgb, W);\n     \n     gl_FragColor = vec4(vec3(luminance), textureColor.a);\n }\n "
public let LuminosityBlendFragmentShader = "// Luminosity blend mode based upon pseudo code from the PDF specification.\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n highp float lum(lowp vec3 c) {\n     return dot(c, vec3(0.3, 0.59, 0.11));\n }\n \n lowp vec3 clipcolor(lowp vec3 c) {\n     highp float l = lum(c);\n     lowp float n = min(min(c.r, c.g), c.b);\n     lowp float x = max(max(c.r, c.g), c.b);\n     \n     if (n < 0.0) {\n         c.r = l + ((c.r - l) * l) / (l - n);\n         c.g = l + ((c.g - l) * l) / (l - n);\n         c.b = l + ((c.b - l) * l) / (l - n);\n     }\n     if (x > 1.0) {\n         c.r = l + ((c.r - l) * (1.0 - l)) / (x - l);\n         c.g = l + ((c.g - l) * (1.0 - l)) / (x - l);\n         c.b = l + ((c.b - l) * (1.0 - l)) / (x - l);\n     }\n     \n     return c;\n }\n \n lowp vec3 setlum(lowp vec3 c, highp float l) {\n     highp float d = l - lum(c);\n     c = c + vec3(d);\n     return clipcolor(c);\n }\n \n void main()\n {\n  highp vec4 baseColor = texture2D(inputImageTexture, textureCoordinate);\n  highp vec4 overlayColor = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     gl_FragColor = vec4(baseColor.rgb * (1.0 - overlayColor.a) + setlum(baseColor.rgb, lum(overlayColor.rgb)) * overlayColor.a, baseColor.a);\n }\n "
public let MedianFragmentShader = "/*\n  3x3 median filter, adapted from \"A Fast, Small-Radius GPU Median Filter\" by Morgan McGuire in ShaderX6\n  http://graphics.cs.williams.edu/papers/MedianShaderX6/\n  \n  Morgan McGuire and Kyle Whitson\n  Williams College\n  \n  Register allocation tips by Victor Huang Xiaohuang\n  University of Illinois at Urbana-Champaign\n  \n  http://graphics.cs.williams.edu\n  \n  \n  Copyright (c) Morgan McGuire and Williams College, 2006\n  All rights reserved.\n  \n  Redistribution and use in source and binary forms, with or without\n  modification, are permitted provided that the following conditions are\n  met:\n  \n  Redistributions of source code must retain the above copyright notice,\n  this list of conditions and the following disclaimer.\n  \n  Redistributions in binary form must reproduce the above copyright\n  notice, this list of conditions and the following disclaimer in the\n  documentation and/or other materials provided with the distribution.\n  \n  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n  \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n  */\n \n  precision highp float;\n  \n  varying vec2 textureCoordinate;\n  varying vec2 leftTextureCoordinate;\n  varying vec2 rightTextureCoordinate;\n  \n  varying vec2 topTextureCoordinate;\n  varying vec2 topLeftTextureCoordinate;\n  varying vec2 topRightTextureCoordinate;\n  \n  varying vec2 bottomTextureCoordinate;\n  varying vec2 bottomLeftTextureCoordinate;\n  varying vec2 bottomRightTextureCoordinate;\n  \n  uniform sampler2D inputImageTexture;\n  \n #define s2(a, b)                temp = a; a = min(a, b); b = max(temp, b);\n #define mn3(a, b, c)            s2(a, b); s2(a, c);\n #define mx3(a, b, c)            s2(b, c); s2(a, c);\n  \n #define mnmx3(a, b, c)          mx3(a, b, c); s2(a, b);                                   // 3 exchanges\n #define mnmx4(a, b, c, d)       s2(a, b); s2(c, d); s2(a, c); s2(b, d);                   // 4 exchanges\n #define mnmx5(a, b, c, d, e)    s2(a, b); s2(c, d); mn3(a, c, e); mx3(b, d, e);           // 6 exchanges\n #define mnmx6(a, b, c, d, e, f) s2(a, d); s2(b, e); s2(c, f); mn3(a, b, c); mx3(d, e, f); // 7 exchanges\n \n  void main()\n  {\n      vec3 v[6];\n \n      v[0] = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;\n      v[1] = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;\n      v[2] = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;\n      v[3] = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;\n      v[4] = texture2D(inputImageTexture, leftTextureCoordinate).rgb;\n      v[5] = texture2D(inputImageTexture, rightTextureCoordinate).rgb;\n //     v[6] = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;\n //     v[7] = texture2D(inputImageTexture, topTextureCoordinate).rgb;\n      vec3 temp;\n \n      mnmx6(v[0], v[1], v[2], v[3], v[4], v[5]);\n      \n      v[5] = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;\n                   \n      mnmx5(v[1], v[2], v[3], v[4], v[5]);\n                   \n      v[5] = texture2D(inputImageTexture, topTextureCoordinate).rgb;\n                                \n      mnmx4(v[2], v[3], v[4], v[5]);\n                                \n      v[5] = texture2D(inputImageTexture, textureCoordinate).rgb;\n                                             \n      mnmx3(v[3], v[4], v[5]);\n     \n      gl_FragColor = vec4(v[4], 1.0);\n  }\n "
public let MonochromeFragmentShader = "precision lowp float;\n \n varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform float intensity;\n uniform vec3 filterColor;\n \n const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     //desat, then apply overlay blend\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     float luminance = dot(textureColor.rgb, luminanceWeighting);\n \n     lowp vec4 desat = vec4(vec3(luminance), 1.0);\n \n     //overlay\n     lowp vec4 outputColor = vec4(\n                                     (desat.r < 0.5 ? (2.0 * desat.r * filterColor.r) : (1.0 - 2.0 * (1.0 - desat.r) * (1.0 - filterColor.r))),\n                                     (desat.g < 0.5 ? (2.0 * desat.g * filterColor.g) : (1.0 - 2.0 * (1.0 - desat.g) * (1.0 - filterColor.g))),\n                                     (desat.b < 0.5 ? (2.0 * desat.b * filterColor.b) : (1.0 - 2.0 * (1.0 - desat.b) * (1.0 - filterColor.b))),\n                                     1.0\n                                     );\n \n     //which is better, or are they equal?\n     gl_FragColor = vec4( mix(textureColor.rgb, outputColor.rgb, intensity), textureColor.a);\n }\n "
public let MotionBlurVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n uniform vec2 directionalTexelStep;\n \n varying vec2 textureCoordinate;\n varying vec2 oneStepBackTextureCoordinate;\n varying vec2 twoStepsBackTextureCoordinate;\n varying vec2 threeStepsBackTextureCoordinate;\n varying vec2 fourStepsBackTextureCoordinate;\n varying vec2 oneStepForwardTextureCoordinate;\n varying vec2 twoStepsForwardTextureCoordinate;\n varying vec2 threeStepsForwardTextureCoordinate;\n varying vec2 fourStepsForwardTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     textureCoordinate = inputTextureCoordinate.xy;\n     oneStepBackTextureCoordinate = inputTextureCoordinate.xy - directionalTexelStep;\n     twoStepsBackTextureCoordinate = inputTextureCoordinate.xy - 2.0 * directionalTexelStep;\n     threeStepsBackTextureCoordinate = inputTextureCoordinate.xy - 3.0 * directionalTexelStep;\n     fourStepsBackTextureCoordinate = inputTextureCoordinate.xy - 4.0 * directionalTexelStep;\n     oneStepForwardTextureCoordinate = inputTextureCoordinate.xy + directionalTexelStep;\n     twoStepsForwardTextureCoordinate = inputTextureCoordinate.xy + 2.0 * directionalTexelStep;\n     threeStepsForwardTextureCoordinate = inputTextureCoordinate.xy + 3.0 * directionalTexelStep;\n     fourStepsForwardTextureCoordinate = inputTextureCoordinate.xy + 4.0 * directionalTexelStep;\n }\n "
public let MotionBlurFragmentShader = "precision highp float;\n \n uniform sampler2D inputImageTexture;\n \n varying vec2 textureCoordinate;\n varying vec2 oneStepBackTextureCoordinate;\n varying vec2 twoStepsBackTextureCoordinate;\n varying vec2 threeStepsBackTextureCoordinate;\n varying vec2 fourStepsBackTextureCoordinate;\n varying vec2 oneStepForwardTextureCoordinate;\n varying vec2 twoStepsForwardTextureCoordinate;\n varying vec2 threeStepsForwardTextureCoordinate;\n varying vec2 fourStepsForwardTextureCoordinate;\n \n void main()\n {\n     lowp vec4 fragmentColor = texture2D(inputImageTexture, textureCoordinate) * 0.18;\n     fragmentColor += texture2D(inputImageTexture, oneStepBackTextureCoordinate) * 0.15;\n     fragmentColor += texture2D(inputImageTexture, twoStepsBackTextureCoordinate) *  0.12;\n     fragmentColor += texture2D(inputImageTexture, threeStepsBackTextureCoordinate) * 0.09;\n     fragmentColor += texture2D(inputImageTexture, fourStepsBackTextureCoordinate) * 0.05;\n     fragmentColor += texture2D(inputImageTexture, oneStepForwardTextureCoordinate) * 0.15;\n     fragmentColor += texture2D(inputImageTexture, twoStepsForwardTextureCoordinate) *  0.12;\n     fragmentColor += texture2D(inputImageTexture, threeStepsForwardTextureCoordinate) * 0.09;\n     fragmentColor += texture2D(inputImageTexture, fourStepsForwardTextureCoordinate) * 0.05;\n \n     gl_FragColor = fragmentColor;\n }\n "
public let MotionComparisonFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n uniform highp float intensity;\n \n void main()\n {\n     lowp vec3 currentImageColor = texture2D(inputImageTexture, textureCoordinate).rgb;\n     lowp vec3 lowPassImageColor = texture2D(inputImageTexture2, textureCoordinate2).rgb;\n     \n     mediump float colorDistance = distance(currentImageColor, lowPassImageColor); // * 0.57735\n     lowp float movementThreshold = step(0.2, colorDistance);\n     \n     gl_FragColor = movementThreshold * vec4(textureCoordinate2.x, textureCoordinate2.y, 1.0, 1.0);\n }\n "
public let MultiplyBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n     lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);\n          \n     gl_FragColor = overlayer * base + overlayer * (1.0 - base.a) + base * (1.0 - overlayer.a);\n }\n "
public let NearbyTexelSamplingVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n uniform float texelWidth;\n uniform float texelHeight; \n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 widthStep = vec2(texelWidth, 0.0);\n     vec2 heightStep = vec2(0.0, texelHeight);\n     vec2 widthHeightStep = vec2(texelWidth, texelHeight);\n     vec2 widthNegativeHeightStep = vec2(texelWidth, -texelHeight);\n     \n     textureCoordinate = inputTextureCoordinate.xy;\n     leftTextureCoordinate = inputTextureCoordinate.xy - widthStep;\n     rightTextureCoordinate = inputTextureCoordinate.xy + widthStep;\n     \n     topTextureCoordinate = inputTextureCoordinate.xy - heightStep;\n     topLeftTextureCoordinate = inputTextureCoordinate.xy - widthHeightStep;\n     topRightTextureCoordinate = inputTextureCoordinate.xy + widthNegativeHeightStep;\n     \n     bottomTextureCoordinate = inputTextureCoordinate.xy + heightStep;\n     bottomLeftTextureCoordinate = inputTextureCoordinate.xy - widthNegativeHeightStep;\n     bottomRightTextureCoordinate = inputTextureCoordinate.xy + widthHeightStep;\n }\n "
public let NobleCornerDetectorFragmentShader = " varying highp vec2 textureCoordinate;\n  \n  uniform sampler2D inputImageTexture;\n  uniform lowp float sensitivity;\n  \n  void main()\n  {\n      mediump vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;\n      \n      mediump float derivativeSum = derivativeElements.x + derivativeElements.y;\n      \n      // R = (Ix^2 * Iy^2 - Ixy * Ixy) / (Ix^2 + Iy^2)\n      mediump float zElement = (derivativeElements.z * 2.0) - 1.0;\n      //     mediump float harrisIntensity = (derivativeElements.x * derivativeElements.y - (derivativeElements.z * derivativeElements.z)) / (derivativeSum);\n      mediump float cornerness = (derivativeElements.x * derivativeElements.y - (zElement * zElement)) / (derivativeSum);\n      \n      // Original Harris detector\n      // R = Ix^2 * Iy^2 - Ixy * Ixy - k * (Ix^2 + Iy^2)^2\n      //     highp float harrisIntensity = derivativeElements.x * derivativeElements.y - (derivativeElements.z * derivativeElements.z) - harrisConstant * derivativeSum * derivativeSum;\n      \n      //     gl_FragColor = vec4(vec3(harrisIntensity * 7.0), 1.0);\n      gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);\n  }\n "
public let NormalBlendFragmentShader = "/*\n  This equation is a simplification of the general blending equation. It assumes the destination color is opaque, and therefore drops the destination color's alpha term.\n  \n  D = C1 * C1a + C2 * C2a * (1 - C1a)\n  where D is the resultant color, C1 is the color of the first element, C1a is the alpha of the first element, C2 is the second element color, C2a is the alpha of the second element. The destination alpha is calculated with:\n  \n  Da = C1a + C2a * (1 - C1a)\n  The resultant color is premultiplied with the alpha. To restore the color to the unmultiplied values, just divide by Da, the resultant alpha.\n  \n  http://stackoverflow.com/questions/1724946/blend-mode-on-a-transparent-and-semi-transparent-background\n  \n  For some reason Photoshop behaves \n  D = C1 + C2 * C2a * (1 - C1a)\n  */\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n  lowp vec4 c2 = texture2D(inputImageTexture, textureCoordinate);\n  lowp vec4 c1 = texture2D(inputImageTexture2, textureCoordinate2);\n  \n  lowp vec4 outputColor;\n  \n //     outputColor.r = c1.r + c2.r * c2.a * (1.0 - c1.a);\n //     outputColor.g = c1.g + c2.g * c2.a * (1.0 - c1.a);\n //     outputColor.b = c1.b + c2.b * c2.a * (1.0 - c1.a);\n //     outputColor.a = c1.a + c2.a * (1.0 - c1.a);\n  \n  lowp float a = c1.a + c2.a * (1.0 - c1.a);\n  lowp float alphaDivisor = a + step(a, 0.0); // Protect against a divide-by-zero blacking out things in the output\n \n  outputColor.r = (c1.r * c1.a + c2.r * c2.a * (1.0 - c1.a))/alphaDivisor;\n  outputColor.g = (c1.g * c1.a + c2.g * c2.a * (1.0 - c1.a))/alphaDivisor;\n  outputColor.b = (c1.b * c1.a + c2.b * c2.a * (1.0 - c1.a))/alphaDivisor;\n  outputColor.a = a;\n \n  gl_FragColor = outputColor;\n }\n "
public let OneInputVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n varying vec2 textureCoordinate;\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = inputTextureCoordinate.xy;\n }\n "
public let OpacityFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float opacity;\n \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = vec4(textureColor.rgb, textureColor.a * opacity);\n }\n "
public let OverlayBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     mediump float ra;\n     if (2.0 * base.r < base.a) {\n         ra = 2.0 * overlay.r * base.r + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n     } else {\n         ra = overlay.a * base.a - 2.0 * (base.a - base.r) * (overlay.a - overlay.r) + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n     }\n     \n     mediump float ga;\n     if (2.0 * base.g < base.a) {\n         ga = 2.0 * overlay.g * base.g + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n     } else {\n         ga = overlay.a * base.a - 2.0 * (base.a - base.g) * (overlay.a - overlay.g) + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n     }\n     \n     mediump float ba;\n     if (2.0 * base.b < base.a) {\n         ba = 2.0 * overlay.b * base.b + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n     } else {\n         ba = overlay.a * base.a - 2.0 * (base.a - base.b) * (overlay.a - overlay.b) + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n     }\n     \n     gl_FragColor = vec4(ra, ga, ba, 1.0);\n }\n "
public let PassthroughFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     gl_FragColor = texture2D(inputImageTexture, textureCoordinate);\n }\n "
public let PinchDistortionFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float aspectRatio;\n uniform highp vec2 center;\n uniform highp float radius;\n uniform highp float scale;\n \n void main()\n {\n     highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n     highp float dist = distance(center, textureCoordinateToUse);\n     textureCoordinateToUse = textureCoordinate;\n     \n     if (dist < radius)\n     {\n         textureCoordinateToUse -= center;\n         highp float percent = 1.0 + ((0.5 - dist) / 0.5) * scale;\n         textureCoordinateToUse = textureCoordinateToUse * percent;\n         textureCoordinateToUse += center;\n         \n         gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );\n     }\n     else\n     {\n         gl_FragColor = texture2D(inputImageTexture, textureCoordinate );\n     }\n }\n "
public let PixellateFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float fractionalWidthOfPixel;\n uniform highp float aspectRatio;\n \n void main()\n {\n     highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);\n     \n     highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;\n     gl_FragColor = texture2D(inputImageTexture, samplePos );\n }\n "
public let PolarPixellateFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp vec2 center;\n uniform highp vec2 pixelSize;\n \n \n void main()\n {\n     highp vec2 normCoord = 2.0 * textureCoordinate - 1.0;\n     highp vec2 normCenter = 2.0 * center - 1.0;\n     \n     normCoord -= normCenter;\n     \n     highp float r = length(normCoord); // to polar coords \n     highp float phi = atan(normCoord.y, normCoord.x); // to polar coords \n     \n     r = r - mod(r, pixelSize.x) + 0.03;\n     phi = phi - mod(phi, pixelSize.y);\n           \n     normCoord.x = r * cos(phi);\n     normCoord.y = r * sin(phi);\n      \n     normCoord += normCenter;\n     \n     mediump vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;\n     \n     gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );\n     \n }\n "
public let PolkaDotFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float fractionalWidthOfPixel;\n uniform highp float aspectRatio;\n uniform highp float dotScaling;\n \n void main()\n {\n     highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);\n     \n     highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;\n     highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n     highp vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n     highp float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse);\n     lowp float checkForPresenceWithinDot = step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling);\n \n     lowp vec4 inputColor = texture2D(inputImageTexture, samplePos);\n     \n     gl_FragColor = vec4(inputColor.rgb * checkForPresenceWithinDot, inputColor.a);\n }\n "
public let PosterizeFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform highp float colorLevels;\n \n void main()\n {\n     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = floor((textureColor * colorLevels) + vec4(0.5)) / colorLevels;\n }\n "
public let PrewittEdgeDetectionFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform float edgeStrength;\n \n void main()\n {\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float h = -topLeftIntensity - topIntensity - topRightIntensity + bottomLeftIntensity + bottomIntensity + bottomRightIntensity;\n     float v = -bottomLeftIntensity - leftIntensity - topLeftIntensity + bottomRightIntensity + rightIntensity + topRightIntensity;\n     \n     float mag = length(vec2(h, v)) * edgeStrength;\n     \n     gl_FragColor = vec4(vec3(mag), 1.0);\n }\n "
public let RGBAdjustmentFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform highp float redAdjustment;\n uniform highp float greenAdjustment;\n uniform highp float blueAdjustment;\n \n void main()\n {\n     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     gl_FragColor = vec4(textureColor.r * redAdjustment, textureColor.g * greenAdjustment, textureColor.b * blueAdjustment, textureColor.a);\n }\n "
public let SaturationBlendFragmentShader = "// Saturation blend mode based upon pseudo code from the PDF specification.\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n highp float lum(lowp vec3 c) {\n     return dot(c, vec3(0.3, 0.59, 0.11));\n }\n \n lowp vec3 clipcolor(lowp vec3 c) {\n     highp float l = lum(c);\n     lowp float n = min(min(c.r, c.g), c.b);\n     lowp float x = max(max(c.r, c.g), c.b);\n     \n     if (n < 0.0) {\n         c.r = l + ((c.r - l) * l) / (l - n);\n         c.g = l + ((c.g - l) * l) / (l - n);\n         c.b = l + ((c.b - l) * l) / (l - n);\n     }\n     if (x > 1.0) {\n         c.r = l + ((c.r - l) * (1.0 - l)) / (x - l);\n         c.g = l + ((c.g - l) * (1.0 - l)) / (x - l);\n         c.b = l + ((c.b - l) * (1.0 - l)) / (x - l);\n     }\n     \n     return c;\n }\n \n lowp vec3 setlum(lowp vec3 c, highp float l) {\n     highp float d = l - lum(c);\n     c = c + vec3(d);\n     return clipcolor(c);\n }\n \n highp float sat(lowp vec3 c) {\n     lowp float n = min(min(c.r, c.g), c.b);\n     lowp float x = max(max(c.r, c.g), c.b);\n     return x - n;\n }\n \n lowp float mid(lowp float cmin, lowp float cmid, lowp float cmax, highp float s) {\n     return ((cmid - cmin) * s) / (cmax - cmin);\n }\n \n lowp vec3 setsat(lowp vec3 c, highp float s) {\n     if (c.r > c.g) {\n         if (c.r > c.b) {\n             if (c.g > c.b) {\n                 /* g is mid, b is min */\n                 c.g = mid(c.b, c.g, c.r, s);\n                 c.b = 0.0;\n             } else {\n                 /* b is mid, g is min */\n                 c.b = mid(c.g, c.b, c.r, s);\n                 c.g = 0.0;\n             }\n             c.r = s;\n         } else {\n             /* b is max, r is mid, g is min */\n             c.r = mid(c.g, c.r, c.b, s);\n             c.b = s;\n             c.r = 0.0;\n         }\n     } else if (c.r > c.b) {\n         /* g is max, r is mid, b is min */\n         c.r = mid(c.b, c.r, c.g, s);\n         c.g = s;\n         c.b = 0.0;\n     } else if (c.g > c.b) {\n         /* g is max, b is mid, r is min */\n         c.b = mid(c.r, c.b, c.g, s);\n         c.g = s;\n         c.r = 0.0;\n     } else if (c.b > c.g) {\n         /* b is max, g is mid, r is min */\n         c.g = mid(c.r, c.g, c.b, s);\n         c.b = s;\n         c.r = 0.0;\n     } else {\n         c = vec3(0.0);\n     }\n     return c;\n }\n \n void main()\n {\n  highp vec4 baseColor = texture2D(inputImageTexture, textureCoordinate);\n  highp vec4 overlayColor = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     gl_FragColor = vec4(baseColor.rgb * (1.0 - overlayColor.a) + setlum(setsat(baseColor.rgb, sat(overlayColor.rgb)), lum(baseColor.rgb)) * overlayColor.a, baseColor.a);\n }\n "
public let SaturationFragmentShader = "varying highp vec2 textureCoordinate;\n  \n uniform sampler2D inputImageTexture;\n uniform lowp float saturation;\n \n // Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n  \n void main()\n {\n     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float luminance = dot(textureColor.rgb, luminanceWeighting);\n     lowp vec3 greyScaleColor = vec3(luminance);\n     gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);\n }\n "
public let ScreenBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n     mediump vec4 whiteColor = vec4(1.0);\n     gl_FragColor = whiteColor - ((whiteColor - textureColor2) * (whiteColor - textureColor));\n }\n "
public let SharpenVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n uniform float texelWidth; \n uniform float texelHeight; \n uniform float sharpness;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate; \n varying vec2 topTextureCoordinate;\n varying vec2 bottomTextureCoordinate;\n \n varying float centerMultiplier;\n varying float edgeMultiplier;\n \n void main()\n {\n     gl_Position = position;\n     \n     vec2 widthStep = vec2(texelWidth, 0.0);\n     vec2 heightStep = vec2(0.0, texelHeight);\n     \n     textureCoordinate = inputTextureCoordinate.xy;\n     leftTextureCoordinate = inputTextureCoordinate.xy - widthStep;\n     rightTextureCoordinate = inputTextureCoordinate.xy + widthStep;\n     topTextureCoordinate = inputTextureCoordinate.xy + heightStep;     \n     bottomTextureCoordinate = inputTextureCoordinate.xy - heightStep;\n     \n     centerMultiplier = 1.0 + 4.0 * sharpness;\n     edgeMultiplier = sharpness;\n }\n "
public let SharpenFragmentShader = "precision highp float;\n \n varying highp vec2 textureCoordinate;\n varying highp vec2 leftTextureCoordinate;\n varying highp vec2 rightTextureCoordinate; \n varying highp vec2 topTextureCoordinate;\n varying highp vec2 bottomTextureCoordinate;\n \n varying highp float centerMultiplier;\n varying highp float edgeMultiplier;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     mediump vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb;\n     mediump vec3 leftTextureColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;\n     mediump vec3 rightTextureColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;\n     mediump vec3 topTextureColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;\n     mediump vec3 bottomTextureColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;\n \n     gl_FragColor = vec4((textureColor * centerMultiplier - (leftTextureColor * edgeMultiplier + rightTextureColor * edgeMultiplier + topTextureColor * edgeMultiplier + bottomTextureColor * edgeMultiplier)), texture2D(inputImageTexture, bottomTextureCoordinate).w);\n }\n "
public let ShiTomasiFeatureDetectorFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float sensitivity;\n \n void main()\n {\n     mediump vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;\n     \n     mediump float derivativeDifference = derivativeElements.x - derivativeElements.y;\n     mediump float zElement = (derivativeElements.z * 2.0) - 1.0;\n     \n     // R = Ix^2 + Iy^2 - sqrt( (Ix^2 - Iy^2)^2 + 4 * Ixy * Ixy)\n     mediump float cornerness = derivativeElements.x + derivativeElements.y - sqrt(derivativeDifference * derivativeDifference + 4.0 * zElement * zElement);\n \n     gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);\n }\n "
public let SketchFragmentShader = "precision mediump float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform float edgeStrength;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float h = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;\n     float v = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;\n     \n     float mag = 1.0 - (length(vec2(h, v)) * edgeStrength);\n     \n     gl_FragColor = vec4(vec3(mag), 1.0);\n }\n "
public let SobelEdgeDetectionFragmentShader = "//   Code from \"Graphics Shaders: Theory and Practice\" by M. Bailey and S. Cunningham \n \n precision mediump float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform float edgeStrength;\n \n void main()\n {\n    float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n    float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n    float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n    float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n    float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n    float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n    float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n    float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n    float h = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;\n    float v = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;\n    \n    float mag = length(vec2(h, v)) * edgeStrength;\n    \n    gl_FragColor = vec4(vec3(mag), 1.0);\n }\n "
public let SoftLightBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n     mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);\n     mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     lowp float alphaDivisor = base.a + step(base.a, 0.0); // Protect against a divide-by-zero blacking out things in the output\n     gl_FragColor = base * (overlay.a * (base / alphaDivisor) + (2.0 * overlay * (1.0 - (base / alphaDivisor)))) + overlay * (1.0 - base.a) + base * (1.0 - overlay.a);\n }\n "
public let SolarizeFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform highp float threshold;\n \n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     highp float luminance = dot(textureColor.rgb, W);\n     highp float thresholdResult = step(luminance, threshold);\n     highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n     \n     gl_FragColor = vec4(finalColor, textureColor.w);\n }\n "
public let SourceOverBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n   lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n   lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate);\n   \n   gl_FragColor = mix(textureColor, textureColor2, textureColor2.a);\n }\n "
public let SphereRefractionFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp vec2 center;\n uniform highp float radius;\n uniform highp float aspectRatio;\n uniform highp float refractiveIndex;\n \n void main()\n {\n     highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));\n     highp float distanceFromCenter = distance(center, textureCoordinateToUse);\n     lowp float checkForPresenceWithinSphere = step(distanceFromCenter, radius);\n     \n     distanceFromCenter = distanceFromCenter / radius;\n     \n     highp float normalizedDepth = radius * sqrt(1.0 - distanceFromCenter * distanceFromCenter);\n     highp vec3 sphereNormal = normalize(vec3(textureCoordinateToUse - center, normalizedDepth));\n     \n     highp vec3 refractedVector = refract(vec3(0.0, 0.0, -1.0), sphereNormal, refractiveIndex);\n     \n     gl_FragColor = texture2D(inputImageTexture, (refractedVector.xy + 1.0) * 0.5) * checkForPresenceWithinSphere;     \n }\n "
public let StretchDistortionFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp vec2 center;\n \n void main()\n {\n     highp vec2 normCoord = 2.0 * textureCoordinate - 1.0;\n     highp vec2 normCenter = 2.0 * center - 1.0;\n     \n     normCoord -= normCenter;\n     mediump vec2 s = sign(normCoord);\n     normCoord = abs(normCoord);\n     normCoord = 0.5 * normCoord + 0.5 * smoothstep(0.25, 0.5, normCoord) * normCoord;\n     normCoord = s * normCoord;\n     \n     normCoord += normCenter;\n        \n     mediump vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;\n     \n     \n     gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );\n     \n }\n "
public let SubtractBlendFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n void main()\n {\n  lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n  lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n  \n  gl_FragColor = vec4(textureColor.rgb - textureColor2.rgb, textureColor.a);\n }\n "
public let SwirlFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp vec2 center;\n uniform highp float radius;\n uniform highp float angle;\n \n void main()\n {\n     highp vec2 textureCoordinateToUse = textureCoordinate;\n     highp float dist = distance(center, textureCoordinate);\n     if (dist < radius)\n     {\n         textureCoordinateToUse -= center;\n         highp float percent = (radius - dist) / radius;\n         highp float theta = percent * percent * angle * 8.0;\n         highp float s = sin(theta);\n         highp float c = cos(theta);\n         textureCoordinateToUse = vec2(dot(textureCoordinateToUse, vec2(c, -s)), dot(textureCoordinateToUse, vec2(s, c)));\n         textureCoordinateToUse += center;\n     }\n    \n     gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );\n     \n }\n "
public let ThreeInputVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n attribute vec4 inputTextureCoordinate2;\n attribute vec4 inputTextureCoordinate3;\n \n varying vec2 textureCoordinate;\n varying vec2 textureCoordinate2;\n varying vec2 textureCoordinate3;\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = inputTextureCoordinate.xy;\n     textureCoordinate2 = inputTextureCoordinate2.xy;\n     textureCoordinate3 = inputTextureCoordinate3.xy;\n }\n "
public let ThresholdEdgeDetectionFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform float threshold;\n \n uniform float edgeStrength;\n \n void main()\n {\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float h = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;\n     h = max(0.0, h);\n     float v = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;\n     v = max(0.0, v);\n     \n     float mag = length(vec2(h, v)) * edgeStrength;\n     mag = step(threshold, mag);\n     \n     gl_FragColor = vec4(vec3(mag), 1.0);\n }\n "
public let ThresholdSketchFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform float threshold;\n \n uniform float edgeStrength;\n \n void main()\n {\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float h = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;\n     float v = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;\n     \n     float mag = length(vec2(h, v)) * edgeStrength;\n     mag = 1.0 - step(threshold, mag);\n     \n     gl_FragColor = vec4(vec3(mag), 1.0);\n }\n "
public let ThresholdedNonMaximumSuppressionFragmentShader = " uniform sampler2D inputImageTexture;\n  \n  varying highp vec2 textureCoordinate;\n  varying highp vec2 leftTextureCoordinate;\n  varying highp vec2 rightTextureCoordinate;\n  \n  varying highp vec2 topTextureCoordinate;\n  varying highp vec2 topLeftTextureCoordinate;\n  varying highp vec2 topRightTextureCoordinate;\n  \n  varying highp vec2 bottomTextureCoordinate;\n  varying highp vec2 bottomLeftTextureCoordinate;\n  varying highp vec2 bottomRightTextureCoordinate;\n  \n  uniform lowp float threshold;\n  \n  void main()\n  {\n      lowp float bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n      lowp float bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n      lowp float bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n      lowp vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);\n      lowp float leftColor = texture2D(inputImageTexture, leftTextureCoordinate).r;\n      lowp float rightColor = texture2D(inputImageTexture, rightTextureCoordinate).r;\n      lowp float topColor = texture2D(inputImageTexture, topTextureCoordinate).r;\n      lowp float topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n      lowp float topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n      \n      // Use a tiebreaker for pixels to the left and immediately above this one\n      lowp float multiplier = 1.0 - step(centerColor.r, topColor);\n      multiplier = multiplier * (1.0 - step(centerColor.r, topLeftColor));\n      multiplier = multiplier * (1.0 - step(centerColor.r, leftColor));\n      multiplier = multiplier * (1.0 - step(centerColor.r, bottomLeftColor));\n      \n      lowp float maxValue = max(centerColor.r, bottomColor);\n      maxValue = max(maxValue, bottomRightColor);\n      maxValue = max(maxValue, rightColor);\n      maxValue = max(maxValue, topRightColor);\n      \n      lowp float finalValue = centerColor.r * step(maxValue, centerColor.r) * multiplier;\n      finalValue = step(threshold, finalValue);\n      \n      gl_FragColor = vec4(finalValue, finalValue, finalValue, 1.0);\n //\n //     gl_FragColor = vec4((centerColor.rgb * step(maxValue, step(threshold, centerColor.r)) * multiplier), 1.0);\n  }\n "
public let TiltShiftFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2; \n \n uniform highp float topFocusLevel;\n uniform highp float bottomFocusLevel;\n uniform highp float focusFallOffRate;\n \n void main()\n {\n     lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp vec4 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2);\n     \n     lowp float blurIntensity = 1.0 - smoothstep(topFocusLevel - focusFallOffRate, topFocusLevel, textureCoordinate2.y);\n     blurIntensity += smoothstep(bottomFocusLevel, bottomFocusLevel + focusFallOffRate, textureCoordinate2.y);\n     \n     gl_FragColor = mix(sharpImageColor, blurredImageColor, blurIntensity);\n }\n "
public let ToonFragmentShader = "precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp float intensity;\n uniform highp float threshold;\n uniform highp float quantizationLevels;\n \n const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n void main()\n {\n     vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n     \n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float h = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;\n     float v = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;\n     \n     float mag = length(vec2(h, v));\n \n     vec3 posterizedImageColor = floor((textureColor.rgb * quantizationLevels) + 0.5) / quantizationLevels;\n     \n     float thresholdTest = 1.0 - step(threshold, mag);\n     \n     gl_FragColor = vec4(posterizedImageColor * thresholdTest, textureColor.a);\n }\n "
public let TransformVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n \n uniform mat4 transformMatrix;\n uniform mat4 orthographicMatrix;\n \n varying vec2 textureCoordinate;\n \n void main()\n {\n     gl_Position = transformMatrix * vec4(position.xyz, 1.0) * orthographicMatrix;\n     textureCoordinate = inputTextureCoordinate.xy;\n }\n "
public let TwoInputVertexShader = "attribute vec4 position;\n attribute vec4 inputTextureCoordinate;\n attribute vec4 inputTextureCoordinate2;\n \n varying vec2 textureCoordinate;\n varying vec2 textureCoordinate2;\n \n void main()\n {\n     gl_Position = position;\n     textureCoordinate = inputTextureCoordinate.xy;\n     textureCoordinate2 = inputTextureCoordinate2.xy;\n }\n "
public let UnsharpMaskFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2; \n \n uniform highp float intensity;\n \n void main()\n {\n     lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp vec3 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2).rgb;\n     \n     gl_FragColor = vec4(sharpImageColor.rgb * intensity + blurredImageColor * (1.0 - intensity), sharpImageColor.a);\n }\n "
public let VibranceFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n uniform lowp float vibrance;\n \n void main() {\n     lowp vec4 color = texture2D(inputImageTexture, textureCoordinate);\n     lowp float average = (color.r + color.g + color.b) / 3.0;\n     lowp float mx = max(color.r, max(color.g, color.b));\n     lowp float amt = (mx - average) * (-vibrance * 3.0);\n     color.rgb = mix(color.rgb, vec3(mx), amt);\n     gl_FragColor = color;\n }\n "
public let VignetteFragmentShader = "uniform sampler2D inputImageTexture;\n varying highp vec2 textureCoordinate;\n \n uniform lowp vec2 vignetteCenter;\n uniform lowp vec3 vignetteColor;\n uniform highp float vignetteStart;\n uniform highp float vignetteEnd;\n \n void main()\n {\n     lowp vec4 sourceImageColor = texture2D(inputImageTexture, textureCoordinate);\n     lowp float d = distance(textureCoordinate, vec2(vignetteCenter.x, vignetteCenter.y));\n     lowp float percent = smoothstep(vignetteStart, vignetteEnd, d);\n     gl_FragColor = vec4(mix(sourceImageColor.rgb, vignetteColor, percent), sourceImageColor.a);\n }\n "
public let WeakPixelInclusionFragmentShader = "precision lowp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float centerIntensity = texture2D(inputImageTexture, textureCoordinate).r;\n     \n     float pixelIntensitySum = bottomLeftIntensity + topRightIntensity + topLeftIntensity + bottomRightIntensity + leftIntensity + rightIntensity + bottomIntensity + topIntensity + centerIntensity;\n     float sumTest = step(1.5, pixelIntensitySum);\n     float pixelTest = step(0.01, centerIntensity);\n          \n     gl_FragColor = vec4(vec3(sumTest * pixelTest), 1.0);\n }\n "
public let WhiteBalanceFragmentShader = "uniform sampler2D inputImageTexture;\n varying highp vec2 textureCoordinate;\n  \n uniform lowp float temperature;\n uniform lowp float tint;\n \n const lowp vec3 warmFilter = vec3(0.93, 0.54, 0.0);\n \n const mediump mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);\n const mediump mat3 YIQtoRGB = mat3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);\n \n void main()\n {\n     lowp vec4 source = texture2D(inputImageTexture, textureCoordinate);\n \n     mediump vec3 yiq = RGBtoYIQ * source.rgb; //adjusting tint\n     yiq.b = clamp(yiq.b + tint*0.5226*0.1, -0.5226, 0.5226);\n     lowp vec3 rgb = YIQtoRGB * yiq;\n \n     lowp vec3 processed = vec3(\n         (rgb.r < 0.5 ? (2.0 * rgb.r * warmFilter.r) : (1.0 - 2.0 * (1.0 - rgb.r) * (1.0 - warmFilter.r))), //adjusting temperature\n         (rgb.g < 0.5 ? (2.0 * rgb.g * warmFilter.g) : (1.0 - 2.0 * (1.0 - rgb.g) * (1.0 - warmFilter.g))), \n         (rgb.b < 0.5 ? (2.0 * rgb.b * warmFilter.b) : (1.0 - 2.0 * (1.0 - rgb.b) * (1.0 - warmFilter.b))));\n \n     gl_FragColor = vec4(mix(rgb, processed, temperature), source.a);\n }\n "
public let XYDerivativeFragmentShader = "// I'm using the Prewitt operator to obtain the derivative, then squaring the X and Y components and placing the product of the two in Z.\n // In tests, Prewitt seemed to be tied with Sobel for the best, and it's just a little cheaper to compute.\n // This is primarily intended to be used with corner detection filters.\n \n precision highp float;\n \n varying vec2 textureCoordinate;\n varying vec2 leftTextureCoordinate;\n varying vec2 rightTextureCoordinate;\n \n varying vec2 topTextureCoordinate;\n varying vec2 topLeftTextureCoordinate;\n varying vec2 topRightTextureCoordinate;\n \n varying vec2 bottomTextureCoordinate;\n varying vec2 bottomLeftTextureCoordinate;\n varying vec2 bottomRightTextureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n void main()\n {\n     float topIntensity = texture2D(inputImageTexture, topTextureCoordinate).r;\n     float topRightIntensity = texture2D(inputImageTexture, topRightTextureCoordinate).r;\n     float topLeftIntensity = texture2D(inputImageTexture, topLeftTextureCoordinate).r;\n     float bottomIntensity = texture2D(inputImageTexture, bottomTextureCoordinate).r;\n     float bottomLeftIntensity = texture2D(inputImageTexture, bottomLeftTextureCoordinate).r;\n     float bottomRightIntensity = texture2D(inputImageTexture, bottomRightTextureCoordinate).r;\n     float leftIntensity = texture2D(inputImageTexture, leftTextureCoordinate).r;\n     float rightIntensity = texture2D(inputImageTexture, rightTextureCoordinate).r;\n     \n     float verticalDerivative = -topLeftIntensity - topIntensity - topRightIntensity + bottomLeftIntensity + bottomIntensity + bottomRightIntensity;\n     float horizontalDerivative = -bottomLeftIntensity - leftIntensity - topLeftIntensity + bottomRightIntensity + rightIntensity + topRightIntensity;\n     verticalDerivative = verticalDerivative;\n     horizontalDerivative = horizontalDerivative;\n     \n     // Scaling the X * Y operation so that negative numbers are not clipped in the 0..1 range. This will be expanded in the corner detection filter\n     gl_FragColor = vec4(horizontalDerivative * horizontalDerivative, verticalDerivative * verticalDerivative, ((verticalDerivative * horizontalDerivative) + 1.0) / 2.0, 1.0);\n }\n "
public let YUVConversionFullRangeUVPlanarFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n varying highp vec2 textureCoordinate3;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n uniform sampler2D inputImageTexture3;\n \n uniform mediump mat3 colorConversionMatrix;\n \n void main()\n {\n     mediump vec3 yuv;\n     \n     yuv.x = texture2D(inputImageTexture, textureCoordinate).r;\n     yuv.y = texture2D(inputImageTexture2, textureCoordinate).r - 0.5;\n     yuv.z = texture2D(inputImageTexture3, textureCoordinate).r - 0.5;\n     lowp vec3 rgb = colorConversionMatrix * yuv;\n     \n     gl_FragColor = vec4(rgb, 1.0);\n }\n "
public let YUVConversionFullRangeFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n uniform mediump mat3 colorConversionMatrix;\n \n void main()\n {\n     mediump vec3 yuv;\n     \n     yuv.x = texture2D(inputImageTexture, textureCoordinate).r;\n     yuv.yz = texture2D(inputImageTexture2, textureCoordinate).ra - vec2(0.5, 0.5);\n     lowp vec3 rgb = colorConversionMatrix * yuv;\n     \n     gl_FragColor = vec4(rgb, 1.0);\n }\n "
public let YUVConversionVideoRangeFragmentShader = "varying highp vec2 textureCoordinate;\n varying highp vec2 textureCoordinate2;\n \n uniform sampler2D inputImageTexture;\n uniform sampler2D inputImageTexture2;\n \n uniform mediump mat3 colorConversionMatrix;\n \n void main()\n {\n     mediump vec3 yuv;\n     \n     yuv.x = texture2D(inputImageTexture, textureCoordinate).r - (16.0/255.0);\n     yuv.yz = texture2D(inputImageTexture2, textureCoordinate).ra - vec2(0.5, 0.5);\n     lowp vec3 rgb = colorConversionMatrix * yuv;\n     \n     gl_FragColor = vec4(rgb, 1.0);\n }\n "
public let ZoomBlurFragmentShader = "varying highp vec2 textureCoordinate;\n \n uniform sampler2D inputImageTexture;\n \n uniform highp vec2 blurCenter;\n uniform highp float blurSize;\n \n void main()\n {\n     // TODO: Do a more intelligent scaling based on resolution here\n     highp vec2 samplingOffset = 1.0/100.0 * (blurCenter - textureCoordinate) * blurSize;\n     \n     lowp vec4 fragmentColor = texture2D(inputImageTexture, textureCoordinate) * 0.18;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate + samplingOffset) * 0.15;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate + (2.0 * samplingOffset)) *  0.12;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate + (3.0 * samplingOffset)) * 0.09;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate + (4.0 * samplingOffset)) * 0.05;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate - samplingOffset) * 0.15;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate - (2.0 * samplingOffset)) *  0.12;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate - (3.0 * samplingOffset)) * 0.09;\n     fragmentColor += texture2D(inputImageTexture, textureCoordinate - (4.0 * samplingOffset)) * 0.05;\n     \n     gl_FragColor = fragmentColor;\n }\n "
