Skip to content

Commit

Permalink
Chroma key blend now respects alpha channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradLarson committed Jul 10, 2012
1 parent 3a413c8 commit 7290587
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions framework/Source/GPUImageChromaKeyBlendFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

void main()
{
vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb;
vec3 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2).rgb;
vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);

float maskY = 0.2989 * colorToReplace.r + 0.5866 * colorToReplace.g + 0.1145 * colorToReplace.b;
float maskCr = 0.7132 * (colorToReplace.r - maskY);
Expand All @@ -30,7 +30,7 @@ void main()

// float blendValue = 1.0 - smoothstep(thresholdSensitivity - smoothing, thresholdSensitivity , abs(Cr - maskCr) + abs(Cb - maskCb));
float blendValue = 1.0 - smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb)));
gl_FragColor = vec4(mix(textureColor, textureColor2, blendValue), 1.0);
gl_FragColor = mix(textureColor, textureColor2, blendValue);
}
);

Expand Down
2 changes: 1 addition & 1 deletion framework/Source/GPUImageSphereRefractionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@interface GPUImageSphereRefractionFilter : GPUImageFilter
{
GLint radiusUniform, centerUniform, scaleUniform, aspectRatioUniform, refractiveIndexUniform;
GLint radiusUniform, centerUniform, aspectRatioUniform, refractiveIndexUniform;
}

/// The center about which to apply the distortion, with a default of (0.5, 0.5)
Expand Down
2 changes: 0 additions & 2 deletions framework/Source/GPUImageSphereRefractionFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

uniform highp vec2 center;
uniform highp float radius;
uniform highp float scale;
uniform highp float aspectRatio;
uniform highp float refractiveIndex;

Expand Down Expand Up @@ -54,7 +53,6 @@ - (id)init;
}

radiusUniform = [filterProgram uniformIndex:@"radius"];
scaleUniform = [filterProgram uniformIndex:@"scale"];
aspectRatioUniform = [filterProgram uniformIndex:@"aspectRatio"];
centerUniform = [filterProgram uniformIndex:@"center"];
refractiveIndexUniform = [filterProgram uniformIndex:@"refractiveIndex"];
Expand Down

0 comments on commit 7290587

Please sign in to comment.