Skip to content

Commit

Permalink
Fixed a precision issue and some divide-by-zero problems with the col…
Browse files Browse the repository at this point in the history
…or dodge blend.
  • Loading branch information
BradLarson committed May 25, 2012
1 parent 837b942 commit 6361d93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions framework/Source/GPUImageColorDodgeBlendFilter.m
Expand Up @@ -3,7 +3,7 @@
NSString *const kGPUImageColorDodgeBlendFragmentShaderString = SHADER_STRING
(

precision lowp float;
precision mediump float;

varying highp vec2 textureCoordinate;
varying highp vec2 textureCoordinate2;
Expand All @@ -20,7 +20,7 @@ void main()
vec3 rightHandProduct = overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a);

vec3 firstBlendColor = baseOverlayAlphaProduct + rightHandProduct;
vec3 overlayRGB = (overlay.rgb / overlay.a) * step(0.0, overlay.a);
vec3 overlayRGB = clamp((overlay.rgb / clamp(overlay.a, 0.01, 1.0)) * step(0.0, overlay.a), 0.0, 0.99);

vec3 secondBlendColor = (base.rgb * overlay.a) / (1.0 - overlayRGB) + rightHandProduct;

Expand Down

0 comments on commit 6361d93

Please sign in to comment.