Skip to content

Commit

Permalink
Fixed vignette filter to take into account alpha in the original imag…
Browse files Browse the repository at this point in the history
…e, improved its performance.
  • Loading branch information
BradLarson committed May 15, 2013
1 parent bdda333 commit b33ff86
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions framework/Source/GPUImageVignetteFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@

void main()
{
/*
lowp vec3 rgb = texture2D(inputImageTexture, textureCoordinate).rgb;
lowp float d = distance(textureCoordinate, vec2(0.5,0.5));
rgb *= (1.0 - smoothstep(vignetteStart, vignetteEnd, d));
gl_FragColor = vec4(vec3(rgb),1.0);
*/

lowp vec3 rgb = texture2D(inputImageTexture, textureCoordinate).rgb;
lowp vec4 sourceImageColor = texture2D(inputImageTexture, textureCoordinate);
lowp float d = distance(textureCoordinate, vec2(vignetteCenter.x, vignetteCenter.y));
lowp float percent = smoothstep(vignetteStart, vignetteEnd, d);
gl_FragColor = vec4(mix(rgb.x, vignetteColor.x, percent), mix(rgb.y, vignetteColor.y, percent), mix(rgb.z, vignetteColor.z, percent), 1.0);
gl_FragColor = vec4(mix(sourceImageColor.rgb, vignetteColor, percent), sourceImageColor.a);
}
);

Expand Down

0 comments on commit b33ff86

Please sign in to comment.