Skip to content

Commit 3453c29

Browse files
author
Thayer J Andrews
committed
CCEffectBloom - Fix intensity math
The intensity value needs to multiply all instances of the source term in the screen blending equation. Otherwise, even when intensity is zero, the source term is still contributing to the final result which is not what we want.
1 parent 8e19335 commit 3453c29

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cocos2d/CCEffectBloom.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ -(void)setLuminanceThreshold:(float)luminanceThreshold
105105
-(void)setIntensity:(float)intensity
106106
{
107107
_intensity = clampf(intensity, 0.0f, 1.0f);
108-
_transformedIntensity = 1.0f - _intensity;
108+
_transformedIntensity = _intensity;
109109
}
110110

111111
-(void)setBlurRadius:(NSUInteger)blurRadius
@@ -214,7 +214,7 @@ -(void)buildFragmentFunctions
214214
// Choose one?
215215
// TODO: try using min(src, dst) to create a gloomEffect
216216
// NSString* additiveBlending = @"src + dst";
217-
NSString* screenBlending = @"(src + dst) - ((src * dst) * u_intensity)";
217+
NSString* screenBlending = @"(src * u_intensity + dst) - ((src * dst) * u_intensity)";
218218

219219
[shaderString appendFormat:@"\
220220
return %@;\n", screenBlending];

0 commit comments

Comments
 (0)