VuoImageBlend implementation.
Definition in file VuoImageBlend.c.
Go to the source code of this file.
Functions | |
VuoImageBlend | VuoImageBlend_make (VuoBlendMode blendMode) |
Creates state data for the image Blendr. More... | |
VuoImage | VuoImageBlend_blend (VuoImageBlend blend, VuoImage background, VuoImage foreground, VuoReal foregroundOpacity, VuoBoolean replaceOpacity) |
Blends multiple images together into a single image. More... | |
#define | FilterSource "\ \n#include \"VuoGlslAlpha.glsl\"\ uniform sampler2D background;\ uniform sampler2D foreground;\ uniform float foregroundOpacity;\ uniform bool replaceOpacity;\ varying vec2 fragmentTextureCoordinate;\ \ float BlendLinearDodgef(float base, float blend) { return min(base + blend, 1.0); }\ float BlendLinearBurnf(float base, float blend) { return max(base + blend - 1.0, 0.0); }\ float BlendDividef(float base, float blend) { return (blend == 0.0) ? blend : base/blend; }\ \ float BlendLightenf(float base, float blend) { return max(blend, base); }\ float BlendDarkenf(float base, float blend) { return min(blend, base); }\ float BlendLinearLightf(float base, float blend) { return (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5)))); }\ \ float BlendScreenf(float base, float blend) { return (1.0 - ((1.0 - base) * (1.0 - blend))); }\ float BlendOverlayf(float base, float blend) { return (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))); }\ float BlendSoftLightf(float base, float blend) { return ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend))); }\ float BlendHardLightf(float base, float blend) { return BlendOverlayf(blend, base); }\ float BlendColorDodgef(float base, float blend) { return ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0)); }\ float BlendColorBurnf(float base, float blend) { return (blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0); }\ \ float BlendVividLightf(float base, float blend) { return ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5)))); }\ float BlendPinLightf(float base, float blend) { return ((blend < 0.5) ? BlendDarkenf(base, (2.0 * blend)) : BlendLightenf(base, (2.0 *(blend - 0.5)))); }\ float BlendHardMixf(float base, float blend) { return ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0); }\ \ \n#include \"VuoGlslHsl.glsl\"\ \ vec3 blendColors(vec4 bg, vec4 fg);\ \ void main() \ { \ vec4 backgroundColor = VuoGlsl_sample(background, fragmentTextureCoordinate); \ backgroundColor.rgb /= backgroundColor.a > 0. ? backgroundColor.a : 1.; \ vec4 foregroundColor = VuoGlsl_sample(foreground, fragmentTextureCoordinate); \ foregroundColor.rgb /= foregroundColor.a > 0. ? foregroundColor.a : 1.; \ foregroundColor.a *= foregroundOpacity; \ \ vec3 blendedColors = clamp(blendColors(backgroundColor, foregroundColor), 0., 1.); \ if (replaceOpacity) \ blendedColors = mix(foregroundColor.rgb, blendedColors, backgroundColor.a); \ \ vec4 mixed = replaceOpacity \ ? vec4(blendedColors*foregroundColor.a + backgroundColor.rgb*backgroundColor.a*(1.-foregroundColor.a), \ foregroundColor.a + backgroundColor.a*(1.-foregroundColor.a)) \ : vec4(blendedColors*foregroundColor.a*backgroundColor.a + backgroundColor.rgb*backgroundColor.a*(1.-foregroundColor.a), \ backgroundColor.a); \ \ gl_FragColor = mixed; \ } \ " |
#define | BLEND_FILTERS(source) "#version 120\n" FilterSource "\n" #source |
static const char * | fragmentShaderSource_blendNormal |
static const char * | fragmentShaderSource_blendMultiply |
static const char * | fragmentShaderSource_blendLinearDodge |
static const char * | fragmentShaderSource_blendDarkerComponent |
static const char * | fragmentShaderSource_blendDarkerColor |
static const char * | fragmentShaderSource_blendLighterComponent |
static const char * | fragmentShaderSource_blendLighterColor |
static const char * | fragmentShaderSource_blendLinearBurn |
static const char * | fragmentShaderSource_blendColorBurn |
static const char * | fragmentShaderSource_blendColorDodge |
static const char * | fragmentShaderSource_blendScreen |
static const char * | fragmentShaderSource_blendOverlay |
static const char * | fragmentShaderSource_blendSoftLight |
static const char * | fragmentShaderSource_blendHardLight |
static const char * | fragmentShaderSource_blendVividLight |
static const char * | fragmentShaderSource_blendLinearLight |
static const char * | fragmentShaderSource_blendPinLight |
static const char * | fragmentShaderSource_blendHardMix |
static const char * | fragmentShaderSource_blendDifference |
static const char * | fragmentShaderSource_blendExclusion |
static const char * | fragmentShaderSource_blendSubtract |
static const char * | fragmentShaderSource_blendDivide |
static const char * | fragmentShaderSource_blendHue |
static const char * | fragmentShaderSource_blendSaturation |
static const char * | fragmentShaderSource_blendColor |
static const char * | fragmentShaderSource_blendLuminosity |
static const char * | fragmentShaderSource_blendPower |
#define BLEND_FILTERS | ( | source | ) | "#version 120\n" FilterSource "\n" #source |
Source code for GLSL blend modes.
Definition at line 81 of file VuoImageBlend.c.
#define FilterSource "\ \n#include \"VuoGlslAlpha.glsl\"\ uniform sampler2D background;\ uniform sampler2D foreground;\ uniform float foregroundOpacity;\ uniform bool replaceOpacity;\ varying vec2 fragmentTextureCoordinate;\ \ float BlendLinearDodgef(float base, float blend) { return min(base + blend, 1.0); }\ float BlendLinearBurnf(float base, float blend) { return max(base + blend - 1.0, 0.0); }\ float BlendDividef(float base, float blend) { return (blend == 0.0) ? blend : base/blend; }\ \ float BlendLightenf(float base, float blend) { return max(blend, base); }\ float BlendDarkenf(float base, float blend) { return min(blend, base); }\ float BlendLinearLightf(float base, float blend) { return (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5)))); }\ \ float BlendScreenf(float base, float blend) { return (1.0 - ((1.0 - base) * (1.0 - blend))); }\ float BlendOverlayf(float base, float blend) { return (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))); }\ float BlendSoftLightf(float base, float blend) { return ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend))); }\ float BlendHardLightf(float base, float blend) { return BlendOverlayf(blend, base); }\ float BlendColorDodgef(float base, float blend) { return ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0)); }\ float BlendColorBurnf(float base, float blend) { return (blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0); }\ \ float BlendVividLightf(float base, float blend) { return ((blend < 0.5) ? BlendColorBurnf(base, (2.0 * blend)) : BlendColorDodgef(base, (2.0 * (blend - 0.5)))); }\ float BlendPinLightf(float base, float blend) { return ((blend < 0.5) ? BlendDarkenf(base, (2.0 * blend)) : BlendLightenf(base, (2.0 *(blend - 0.5)))); }\ float BlendHardMixf(float base, float blend) { return ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0); }\ \ \n#include \"VuoGlslHsl.glsl\"\ \ vec3 blendColors(vec4 bg, vec4 fg);\ \ void main() \ { \ vec4 backgroundColor = VuoGlsl_sample(background, fragmentTextureCoordinate); \ backgroundColor.rgb /= backgroundColor.a > 0. ? backgroundColor.a : 1.; \ vec4 foregroundColor = VuoGlsl_sample(foreground, fragmentTextureCoordinate); \ foregroundColor.rgb /= foregroundColor.a > 0. ? foregroundColor.a : 1.; \ foregroundColor.a *= foregroundOpacity; \ \ vec3 blendedColors = clamp(blendColors(backgroundColor, foregroundColor), 0., 1.); \ if (replaceOpacity) \ blendedColors = mix(foregroundColor.rgb, blendedColors, backgroundColor.a); \ \ vec4 mixed = replaceOpacity \ ? vec4(blendedColors*foregroundColor.a + backgroundColor.rgb*backgroundColor.a*(1.-foregroundColor.a), \ foregroundColor.a + backgroundColor.a*(1.-foregroundColor.a)) \ : vec4(blendedColors*foregroundColor.a*backgroundColor.a + backgroundColor.rgb*backgroundColor.a*(1.-foregroundColor.a), \ backgroundColor.a); \ \ gl_FragColor = mixed; \ } \ " |
Source code for GLSL blend modes.
Definition at line 28 of file VuoImageBlend.c.
VuoImage VuoImageBlend_blend | ( | VuoImageBlend | blend, |
VuoImage | background, | ||
VuoImage | foreground, | ||
VuoReal | foregroundOpacity, | ||
VuoBoolean | replaceOpacity | ||
) |
Blends multiple images together into a single image.
Definition at line 404 of file VuoImageBlend.c.
VuoImageBlend VuoImageBlend_make | ( | VuoBlendMode | blendMode | ) |
Creates state data for the image Blendr.
Definition at line 304 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 277 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 143 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 152 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 111 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 104 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 231 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 252 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 238 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 186 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 222 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 261 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 127 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 120 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 136 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 97 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 204 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 285 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 90 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 83 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 168 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 213 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 293 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 269 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 159 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 177 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 245 of file VuoImageBlend.c.
|
static |
Source code for GLSL blend modes.
Definition at line 195 of file VuoImageBlend.c.