Skip to content

Commit 6fdfe54

Browse files
committed
Merge pull request #897 from thayerandrews/develop
Refraction, reflection, and glass
2 parents 7b1311e + 7fc4ffd commit 6fdfe54

25 files changed

+716
-58
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The file MountainPanorama.jpg is a derivative of Helvellyn_Striding_Edge_360_Panorama,_Lake_District_-_June_09.jpg by DAVID ILIFF, used under CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/deed.en). MountainPanorama.jpg is a crop of the original image.
2+
3+
The original image was downloaded from http://en.wikipedia.org/wiki/File:Helvellyn_Striding_Edge_360_Panorama,_Lake_District_-_June_09.jpg
4+
5+
MountainPanorama.jpg is licensed under CC-BY-SA 3.0.
6+

Resources/Images/MountainPanorama.jpg

195 KB
Loading
-16.9 KB
Loading

Resources/Images/StoneWall.jpg

294 KB
Loading

cocos2d-ios.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,18 @@
108108
926B97F71938606D00E345FB /* CCAnimationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 926B97F21938606D00E345FB /* CCAnimationManager.h */; };
109109
9D1C03B81954F636007B6735 /* CCEffectRefraction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D1C03B61954F636007B6735 /* CCEffectRefraction.h */; };
110110
9D1C03B91954F636007B6735 /* CCEffectRefraction.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D1C03B71954F636007B6735 /* CCEffectRefraction.m */; };
111+
9D473920197841A500314F7D /* CCEffectUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D47391E197841A500314F7D /* CCEffectUtils.h */; };
112+
9D473921197841A500314F7D /* CCEffectUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D47391F197841A500314F7D /* CCEffectUtils.m */; };
113+
9D6BE2FE1975E18B0082A327 /* CCEffectGlass.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D6BE2FC1975E18B0082A327 /* CCEffectGlass.h */; };
114+
9D6BE2FF1975E18B0082A327 /* CCEffectGlass.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D6BE2FD1975E18B0082A327 /* CCEffectGlass.m */; };
111115
9D85671D191B018200573093 /* CCEffectBrightness.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85671B191B018200573093 /* CCEffectBrightness.h */; };
112116
9D85671E191B018200573093 /* CCEffectBrightness.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D85671C191B018200573093 /* CCEffectBrightness.m */; };
113117
9D856721191B019900573093 /* CCEffectContrast.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85671F191B019900573093 /* CCEffectContrast.h */; };
114118
9D856722191B019900573093 /* CCEffectContrast.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D856720191B019900573093 /* CCEffectContrast.m */; };
115119
9DB7599A196E09FF00AF3E4A /* CCEffectHue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DB75998196E09FF00AF3E4A /* CCEffectHue.h */; };
116120
9DB7599B196E09FF00AF3E4A /* CCEffectHue.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DB75999196E09FF00AF3E4A /* CCEffectHue.m */; };
121+
9DE8190D1974733200B1D8C3 /* CCEffectReflection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DE8190B1974733200B1D8C3 /* CCEffectReflection.h */; };
122+
9DE8190E1974733200B1D8C3 /* CCEffectReflection.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DE8190C1974733200B1D8C3 /* CCEffectReflection.m */; };
117123
9DE90429192D630000AEB37A /* CCEffectRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DE90427192D630000AEB37A /* CCEffectRenderer.h */; };
118124
9DE9042A192D630000AEB37A /* CCEffectRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DE90428192D630000AEB37A /* CCEffectRenderer.m */; };
119125
9DF37621191C594A00C6D27A /* CCEffectPixellate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DF3761F191C594A00C6D27A /* CCEffectPixellate.h */; };
@@ -434,6 +440,10 @@
434440
92FF6C7318F33A2A005B7139 /* CCActionManager_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCActionManager_Private.h; sourceTree = "<group>"; };
435441
9D1C03B61954F636007B6735 /* CCEffectRefraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectRefraction.h; sourceTree = "<group>"; };
436442
9D1C03B71954F636007B6735 /* CCEffectRefraction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectRefraction.m; sourceTree = "<group>"; };
443+
9D47391E197841A500314F7D /* CCEffectUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectUtils.h; sourceTree = "<group>"; };
444+
9D47391F197841A500314F7D /* CCEffectUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectUtils.m; sourceTree = "<group>"; };
445+
9D6BE2FC1975E18B0082A327 /* CCEffectGlass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectGlass.h; sourceTree = "<group>"; };
446+
9D6BE2FD1975E18B0082A327 /* CCEffectGlass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectGlass.m; sourceTree = "<group>"; };
437447
9D85671A191AE2CC00573093 /* CCEffectStack_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEffectStack_Private.h; sourceTree = "<group>"; };
438448
9D85671B191B018200573093 /* CCEffectBrightness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectBrightness.h; sourceTree = "<group>"; };
439449
9D85671C191B018200573093 /* CCEffectBrightness.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectBrightness.m; sourceTree = "<group>"; };
@@ -442,6 +452,8 @@
442452
9D85B7DC195396E90039A9DB /* CCEffectStackProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEffectStackProtocol.h; sourceTree = "<group>"; };
443453
9DB75998196E09FF00AF3E4A /* CCEffectHue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectHue.h; sourceTree = "<group>"; };
444454
9DB75999196E09FF00AF3E4A /* CCEffectHue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectHue.m; sourceTree = "<group>"; };
455+
9DE8190B1974733200B1D8C3 /* CCEffectReflection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectReflection.h; sourceTree = "<group>"; };
456+
9DE8190C1974733200B1D8C3 /* CCEffectReflection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectReflection.m; sourceTree = "<group>"; };
445457
9DE90427192D630000AEB37A /* CCEffectRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectRenderer.h; sourceTree = "<group>"; };
446458
9DE90428192D630000AEB37A /* CCEffectRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffectRenderer.m; sourceTree = "<group>"; };
447459
9DF3761F191C594A00C6D27A /* CCEffectPixellate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectPixellate.h; sourceTree = "<group>"; };
@@ -1212,6 +1224,8 @@
12121224
D272031718FC89A000B100FF /* CCEffect_Private.h */,
12131225
D272031818FC89A000B100FF /* CCEffect.h */,
12141226
D272031918FC89A000B100FF /* CCEffect.m */,
1227+
9D47391E197841A500314F7D /* CCEffectUtils.h */,
1228+
9D47391F197841A500314F7D /* CCEffectUtils.m */,
12151229
D272032018FC89A000B100FF /* CCEffectStack.h */,
12161230
9D85671A191AE2CC00573093 /* CCEffectStack_Private.h */,
12171231
D272032118FC89A000B100FF /* CCEffectStack.m */,
@@ -1222,6 +1236,8 @@
12221236
9D85671C191B018200573093 /* CCEffectBrightness.m */,
12231237
9D85671F191B019900573093 /* CCEffectContrast.h */,
12241238
9D856720191B019900573093 /* CCEffectContrast.m */,
1239+
9D6BE2FC1975E18B0082A327 /* CCEffectGlass.h */,
1240+
9D6BE2FD1975E18B0082A327 /* CCEffectGlass.m */,
12251241
9DB75998196E09FF00AF3E4A /* CCEffectHue.h */,
12261242
9DB75999196E09FF00AF3E4A /* CCEffectHue.m */,
12271243
9DF3761F191C594A00C6D27A /* CCEffectPixellate.h */,
@@ -1232,6 +1248,8 @@
12321248
9DFB1E4F19241AEF008371EF /* CCEffectSaturation.m */,
12331249
9D1C03B61954F636007B6735 /* CCEffectRefraction.h */,
12341250
9D1C03B71954F636007B6735 /* CCEffectRefraction.m */,
1251+
9DE8190B1974733200B1D8C3 /* CCEffectReflection.h */,
1252+
9DE8190C1974733200B1D8C3 /* CCEffectReflection.m */,
12351253
9DE90427192D630000AEB37A /* CCEffectRenderer.h */,
12361254
9DE90428192D630000AEB37A /* CCEffectRenderer.m */,
12371255
);
@@ -1317,6 +1335,7 @@
13171335
5018F2730DFDEAFF00C013A5 /* CCLabelTTF.h in Headers */,
13181336
5018F2750DFDEAFF00C013A5 /* CCNodeColor.h in Headers */,
13191337
5018F2770DFDEAFF00C013A5 /* CCScene.h in Headers */,
1338+
9D473920197841A500314F7D /* CCEffectUtils.h in Headers */,
13201339
5018F27D0DFDEAFF00C013A5 /* CCTextureCache.h in Headers */,
13211340
B77060051831A07B0043CC67 /* OALNotifications.h in Headers */,
13221341
D380581A1889AD6000822437 /* CCRenderer.h in Headers */,
@@ -1446,11 +1465,13 @@
14461465
A0DA0BC315BCDCA200E80A92 /* CCDrawNode.h in Headers */,
14471466
2B192835163361B10049A044 /* CCClippingNode.h in Headers */,
14481467
B7EE6A1E181AE34600B983FE /* CCSlider.h in Headers */,
1468+
9DE8190D1974733200B1D8C3 /* CCEffectReflection.h in Headers */,
14491469
A003AC8C1657071100C7B792 /* ccFPSImages.h in Headers */,
14501470
B74C2B9B17BDA63A00A829C0 /* CCSprite9Slice.h in Headers */,
14511471
B77060CF18341AD50043CC67 /* CCBReader_Private.h in Headers */,
14521472
B75C2E7C17C5908B002B0E0D /* NSAttributedString+CCAdditions.h in Headers */,
14531473
A6A0734517C788EB004343C8 /* CCResponderManager.h in Headers */,
1474+
9D6BE2FE1975E18B0082A327 /* CCEffectGlass.h in Headers */,
14541475
A6A0734A17C78EF3004343C8 /* CCResponder.h in Headers */,
14551476
B78AE46217E7AF1C0028BE0B /* CCButton.h in Headers */,
14561477
9DE90429192D630000AEB37A /* CCEffectRenderer.h in Headers */,
@@ -1654,11 +1675,13 @@
16541675
B7705FDB1831A07B0043CC67 /* OALAudioTracks.m in Sources */,
16551676
B7705FEE1831A07B0043CC67 /* ALSoundSourcePool.m in Sources */,
16561677
B7EE69E11819E75700B983FE /* CCLayout.m in Sources */,
1678+
9DE8190E1974733200B1D8C3 /* CCEffectReflection.m in Sources */,
16571679
B7705FD51831A07B0043CC67 /* OALUtilityActions.m in Sources */,
16581680
2B192836163361B10049A044 /* CCClippingNode.m in Sources */,
16591681
A003AC8F16572D6000C7B792 /* ccFPSImages.m in Sources */,
16601682
B79F905B17FE2A2E00908504 /* CCTableView.m in Sources */,
16611683
B74C2B9C17BDA63A00A829C0 /* CCSprite9Slice.m in Sources */,
1684+
9D473921197841A500314F7D /* CCEffectUtils.m in Sources */,
16621685
B75C2E7D17C5908B002B0E0D /* NSAttributedString+CCAdditions.m in Sources */,
16631686
B7EE69E31819E75700B983FE /* CCLayoutBox.m in Sources */,
16641687
B7705FF71831A07B0043CC67 /* OALAudioSession.m in Sources */,
@@ -1669,6 +1692,7 @@
16691692
A6A0734617C788EB004343C8 /* CCResponderManager.m in Sources */,
16701693
A6A0734B17C78EF3004343C8 /* CCResponder.m in Sources */,
16711694
B78AE46317E7AF1C0028BE0B /* CCButton.m in Sources */,
1695+
9D6BE2FF1975E18B0082A327 /* CCEffectGlass.m in Sources */,
16721696
B78AE46517E7AF1C0028BE0B /* CCControl.m in Sources */,
16731697
B78AE46717E7AF1C0028BE0B /* CCControlTextureFactory.m in Sources */,
16741698
D38058211889CE7700822437 /* CCCache.m in Sources */,

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,95 @@ -(id)init
1919
return self;
2020
}
2121

22+
-(void)setupGlassEffectTest
23+
{
24+
self.subTitle = @"Glass Effect Test";
25+
26+
CGPoint p1, p2;
27+
28+
CCSprite *reflectEnvironment = [CCSprite spriteWithImageNamed:@"Images/MountainPanorama.jpg"];
29+
reflectEnvironment.positionType = CCPositionTypeNormalized;
30+
reflectEnvironment.position = ccp(0.5f, 0.5f);
31+
reflectEnvironment.visible = NO;
32+
33+
[self.contentNode addChild:reflectEnvironment];
34+
35+
36+
CCSprite *refractEnvironment = [CCSprite spriteWithImageNamed:@"Images/StoneWall.jpg"];
37+
refractEnvironment.positionType = CCPositionTypeNormalized;
38+
refractEnvironment.position = ccp(0.5f, 0.5f);
39+
refractEnvironment.scale = 0.5;
40+
41+
[self.contentNode addChild:refractEnvironment];
42+
43+
44+
CCSpriteFrame *normalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
45+
CCEffectGlass *glass = [[CCEffectGlass alloc] initWithRefraction:1.0f refractionEnvironment:refractEnvironment reflectionEnvironment:reflectEnvironment normalMap:nil];
46+
glass.fresnelBias = 0.1f;
47+
glass.fresnelPower = 2.0f;
48+
glass.refraction = 0.75f;
49+
50+
p1 = CGPointMake(0.1f, 0.1f);
51+
p2 = CGPointMake(0.9f, 0.9f);
52+
53+
CCSprite *sprite1 = [[CCSprite alloc] init];
54+
sprite1.positionType = CCPositionTypeNormalized;
55+
sprite1.position = ccp(0.5f, 0.5f);
56+
sprite1.normalMapSpriteFrame = normalMap;
57+
sprite1.effect = glass;
58+
sprite1.scale = 0.5f;
59+
sprite1.colorRGBA = [CCColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.0f];
60+
61+
[sprite1 runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
62+
[CCActionMoveTo actionWithDuration:2.0 position:ccp(p1.x, p2.y)],
63+
[CCActionMoveTo actionWithDuration:4.0 position:ccp(p2.x, p2.y)],
64+
[CCActionMoveTo actionWithDuration:2.0 position:ccp(p2.x, p1.y)],
65+
[CCActionMoveTo actionWithDuration:4.0 position:ccp(p1.x, p1.y)],
66+
nil
67+
]]];
68+
[self.contentNode addChild:sprite1];
69+
}
70+
71+
-(void)setupReflectEffectTest
72+
{
73+
self.subTitle = @"Reflection Effect Test";
74+
75+
CGPoint p1, p2;
76+
77+
CCSprite *environment = [CCSprite spriteWithImageNamed:@"Images/MountainPanorama.jpg"];
78+
environment.positionType = CCPositionTypeNormalized;
79+
environment.position = ccp(0.5f, 0.5f);
80+
environment.visible = NO;
81+
82+
[self.contentNode addChild:environment];
83+
84+
CCSpriteFrame *normalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
85+
CCEffectReflection *reflection = [[CCEffectReflection alloc] initWithEnvironment:environment normalMap:nil];
86+
reflection.fresnelBias = 0.0f;
87+
reflection.fresnelPower = 0.0f;
88+
89+
p1 = CGPointMake(0.1f, 0.1f);
90+
p2 = CGPointMake(0.9f, 0.9f);
91+
92+
CCSprite *sprite1 = [[CCSprite alloc] init];
93+
sprite1.positionType = CCPositionTypeNormalized;
94+
sprite1.position = ccp(0.5f, 0.5f);
95+
sprite1.normalMapSpriteFrame = normalMap;
96+
sprite1.effect = reflection;
97+
sprite1.scale = 0.5f;
98+
sprite1.colorRGBA = [CCColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.0f];
99+
100+
[sprite1 runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
101+
[CCActionMoveTo actionWithDuration:2.0 position:ccp(p1.x, p2.y)],
102+
[CCActionMoveTo actionWithDuration:4.0 position:ccp(p2.x, p2.y)],
103+
[CCActionMoveTo actionWithDuration:2.0 position:ccp(p2.x, p1.y)],
104+
[CCActionMoveTo actionWithDuration:4.0 position:ccp(p1.x, p1.y)],
105+
nil
106+
]]];
107+
[self.contentNode addChild:sprite1];
108+
}
109+
110+
22111
-(void)setupRefractionEffectTest
23112
{
24113
self.subTitle = @"Refraction Effect Test";
@@ -61,6 +150,7 @@ -(void)setupRefractionEffectTest
61150
CCTexture *sphereTexture = [CCTexture textureWithFile:sphereTextureFile];
62151
CCSpriteFrame *sphereNormalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
63152
CCEffectRefraction *sphereRefraction = [[CCEffectRefraction alloc] initWithRefraction:0.1f environment:renderTexture.sprite normalMap:nil];
153+
sphereRefraction.refraction = 0.75f;
64154

65155
p1 = CGPointMake(0.1f, 0.8f);
66156
p2 = CGPointMake(0.35f, 0.2f);
@@ -80,6 +170,7 @@ -(void)setupRefractionEffectTest
80170
CCTexture *torusTexture = [CCTexture textureWithFile:torusTextureFile];
81171
CCSpriteFrame *torusNormalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyTorusNormals.png"];
82172
CCEffectRefraction *torusRefraction = [[CCEffectRefraction alloc] initWithRefraction:0.1f environment:renderTexture.sprite normalMap:torusNormalMap];
173+
torusRefraction.refraction = 0.75f;
83174

84175
p1 = CGPointMake(0.65f, 0.2f);
85176
p2 = CGPointMake(0.9f, 0.8f);

cocos2d/CCEffect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typedef void (^CCEffectRenderPassEndBlock)(CCEffectRenderPass *pass);
102102
@property (nonatomic,copy) NSArray* beginBlocks;
103103
@property (nonatomic,copy) NSArray* updateBlocks;
104104
@property (nonatomic,copy) NSArray* endBlocks;
105+
@property (nonatomic,copy) NSString *debugLabel;
105106

106107
-(void)begin:(CCTexture *)previousPassTexture;
107108
-(void)update;

cocos2d/CCEffect.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ -(void)end
257257

258258
-(void)enqueueTriangles
259259
{
260-
CCRenderState *renderState = [[CCRenderState alloc] initWithBlendMode:_blendMode shader:_shader shaderUniforms:_shaderUniforms copyUniforms:NO];
260+
CCRenderState *renderState = [[CCRenderState alloc] initWithBlendMode:_blendMode shader:_shader shaderUniforms:_shaderUniforms copyUniforms:YES];
261261

262262
CCRenderBuffer buffer = [_renderer enqueueTriangles:2 andVertexes:4 withState:renderState globalSortOrder:0];
263263
CCRenderBufferSetVertex(buffer, 0, CCVertexApplyTransform(_verts.bl, &_transform));

cocos2d/CCEffectBloom.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ -(void)buildRenderPasses
306306
__weak CCEffectBloom *weakSelf = self;
307307

308308
CCEffectRenderPass *pass0 = [[CCEffectRenderPass alloc] init];
309+
pass0.debugLabel = @"CCEffectBloom pass 0";
309310
pass0.shader = self.shader;
310311
pass0.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
311312

@@ -322,9 +323,10 @@ -(void)buildRenderPasses
322323

323324

324325
CCEffectRenderPass *pass1 = [[CCEffectRenderPass alloc] init];
326+
pass1.debugLabel = @"CCEffectBloom pass 1";
325327
pass1.shader = self.shader;
326328
pass1.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
327-
329+
328330
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
329331
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:0.0f];
330332
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
@@ -337,8 +339,10 @@ -(void)buildRenderPasses
337339

338340

339341
CCEffectRenderPass *pass2 = [[CCEffectRenderPass alloc] init];
342+
pass2.debugLabel = @"CCEffectBloom pass 2";
340343
pass2.shader = self.shader;
341344
pass2.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
345+
342346
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
343347
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:1.0f];
344348
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];

cocos2d/CCEffectBrightness.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
@interface CCEffectBrightness ()
1818

19-
@property (nonatomic) float conditionedBrightness;
19+
@property (nonatomic) NSNumber *conditionedBrightness;
2020

2121
@end
2222

@@ -35,7 +35,7 @@ -(id)initWithBrightness:(float)brightness
3535
if((self = [super initWithFragmentUniforms:@[uniformBrightness] vertexUniforms:nil varying:nil]))
3636
{
3737
_brightness = brightness;
38-
_conditionedBrightness = conditionBrightness(brightness);
38+
_conditionedBrightness = [NSNumber numberWithFloat:conditionBrightness(brightness)];
3939

4040
self.debugName = @"CCEffectBrightness";
4141
}
@@ -66,11 +66,13 @@ -(void)buildRenderPasses
6666
__weak CCEffectBrightness *weakSelf = self;
6767

6868
CCEffectRenderPass *pass0 = [[CCEffectRenderPass alloc] init];
69+
pass0.debugLabel = @"CCEffectBrightness pass 0";
6970
pass0.shader = self.shader;
7071
pass0.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
72+
7173
pass.shaderUniforms[CCShaderUniformMainTexture] = previousPassTexture;
7274
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
73-
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_brightness"]] = [NSNumber numberWithFloat:weakSelf.conditionedBrightness];
75+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_brightness"]] = weakSelf.conditionedBrightness;
7476
} copy]];
7577

7678
self.renderPasses = @[pass0];
@@ -79,7 +81,7 @@ -(void)buildRenderPasses
7981
-(void)setBrightness:(float)brightness
8082
{
8183
_brightness = brightness;
82-
_conditionedBrightness = conditionBrightness(brightness);
84+
_conditionedBrightness = [NSNumber numberWithFloat:conditionBrightness(brightness)];
8385
}
8486

8587
@end

0 commit comments

Comments
 (0)