Skip to content

Commit 7b1311e

Browse files
committed
Merge branch 'develop' of github.com:cocos2d/cocos2d-iphone into develop
Conflicts: cocos2d/CCDirector.m
2 parents 4dacabf + 3e3765f commit 7b1311e

17 files changed

+120
-43
lines changed

Resources/Images/ShinyBallColor.png

54.9 KB
Loading

Resources/Images/ShinyBallNormals.png

42.3 KB
Loading

Resources/Images/ShinyTorusColor.png

65.3 KB
Loading
83.9 KB
Loading

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ -(void)setupRefractionEffectTest
5757

5858
[self.contentNode addChild:renderTexture];
5959

60-
NSString *sphereTextureFile = @"Images/sphere-256.png";
60+
NSString *sphereTextureFile = @"Images/ShinyBallColor.png";
6161
CCTexture *sphereTexture = [CCTexture textureWithFile:sphereTextureFile];
62-
CCSpriteFrame *sphereNormalMap = [CCSpriteFrame frameWithImageNamed:@"Images/sphere-normal-256.png"];
62+
CCSpriteFrame *sphereNormalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
6363
CCEffectRefraction *sphereRefraction = [[CCEffectRefraction alloc] initWithRefraction:0.1f environment:renderTexture.sprite normalMap:nil];
6464

6565
p1 = CGPointMake(0.1f, 0.8f);
@@ -76,9 +76,9 @@ -(void)setupRefractionEffectTest
7676
]]];
7777
[self.contentNode addChild:sprite1];
7878

79-
NSString *torusTextureFile = @"Images/torus-256.png";
79+
NSString *torusTextureFile = @"Images/ShinyTorusColor.png";
8080
CCTexture *torusTexture = [CCTexture textureWithFile:torusTextureFile];
81-
CCSpriteFrame *torusNormalMap = [CCSpriteFrame frameWithImageNamed:@"Images/torus-normal-256.png"];
81+
CCSpriteFrame *torusNormalMap = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyTorusNormals.png"];
8282
CCEffectRefraction *torusRefraction = [[CCEffectRefraction alloc] initWithRefraction:0.1f environment:renderTexture.sprite normalMap:torusNormalMap];
8383

8484
p1 = CGPointMake(0.65f, 0.2f);

cocos2d-ui/CCButton.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ - (void) stateChanged
321321
}
322322

323323
[_label stopAllActions];
324+
[_background stopAllActions];
325+
324326
if (_zoomWhenHighlighted)
325327
{
326328
_label.scaleX = _originalScaleX;

cocos2d/CCEffect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#import "ccTypes.h"
1414

1515
#if CC_ENABLE_EXPERIMENTAL_EFFECTS
16-
extern const NSString *CCShaderUniformPreviousPassTexture;
16+
extern NSString * const CCShaderUniformPreviousPassTexture;
1717

1818
typedef NS_ENUM(NSUInteger, CCEffectFunctionStitchFlags)
1919
{

cocos2d/CCEffect.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import "CCtexture.h"
1212

1313
#if CC_ENABLE_EXPERIMENTAL_EFFECTS
14-
const NSString *CCShaderUniformPreviousPassTexture = @"cc_PreviousPassTexture";
14+
NSString * const CCShaderUniformPreviousPassTexture = @"cc_PreviousPassTexture";
1515

1616
static NSString* fragBase =
1717
@"%@\n\n" // uniforms
@@ -40,6 +40,8 @@ -(id)initWithName:(NSString *)name body:(NSString*)body inputs:(NSArray*)inputs
4040
{
4141
if((self = [super init]))
4242
{
43+
NSAssert(inputs.count <= 1, @"Effect functions currently only support 0 or 1 inputs.");
44+
4345
_body = [body copy];
4446
_name = [name copy];
4547
_inputs = [inputs copy];
@@ -255,7 +257,7 @@ -(void)end
255257

256258
-(void)enqueueTriangles
257259
{
258-
CCRenderState *renderState = [[CCRenderState alloc] initWithBlendMode:_blendMode shader:_shader shaderUniforms:_shaderUniforms];
260+
CCRenderState *renderState = [[CCRenderState alloc] initWithBlendMode:_blendMode shader:_shader shaderUniforms:_shaderUniforms copyUniforms:NO];
259261

260262
CCRenderBuffer buffer = [_renderer enqueueTriangles:2 andVertexes:4 withState:renderState globalSortOrder:0];
261263
CCRenderBufferSetVertex(buffer, 0, CCVertexApplyTransform(_verts.bl, &_transform));
@@ -445,7 +447,7 @@ -(void)buildEffectShader
445447
}
446448

447449
NSMutableArray *inputs = [[NSMutableArray alloc] init];
448-
for (CCEffectFunctionInput *input in curFunction.inputs)
450+
if (curFunction.inputs.count)
449451
{
450452
[inputs addObject:@"tmp"];
451453
}

cocos2d/CCEffectBloom.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ -(void)buildFragmentFunctions
214214

215215
// Choose one?
216216
// TODO: try using min(src, dst) to create a gloomEffect
217-
NSString* addativeBlending = @"src + dst";
217+
// NSString* additiveBlending = @"src + dst";
218218
NSString* screenBlending = @"(src + dst) - ((src * dst) * u_intensity)";
219219

220220
[shaderString appendFormat:@"\
@@ -311,12 +311,12 @@ -(void)buildRenderPasses
311311

312312
pass.shaderUniforms[CCShaderUniformMainTexture] = previousPassTexture;
313313
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
314-
pass.shaderUniforms[self.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:0.0f];
315-
pass.shaderUniforms[self.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
316-
pass.shaderUniforms[self.uniformTranslationTable[@"u_intensity"]] = [NSNumber numberWithFloat:_transformedIntensity];
314+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:0.0f];
315+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
316+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_intensity"]] = [NSNumber numberWithFloat:_transformedIntensity];
317317

318318
GLKVector2 dur = GLKVector2Make(1.0 / (previousPassTexture.pixelWidth / previousPassTexture.contentScale), 0.0);
319-
pass.shaderUniforms[self.uniformTranslationTable[@"u_blurDirection"]] = [NSValue valueWithGLKVector2:dur];
319+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_blurDirection"]] = [NSValue valueWithGLKVector2:dur];
320320

321321
} copy]];
322322

@@ -326,12 +326,12 @@ -(void)buildRenderPasses
326326
pass1.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
327327

328328
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
329-
pass.shaderUniforms[self.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:0.0f];
330-
pass.shaderUniforms[self.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
331-
pass.shaderUniforms[self.uniformTranslationTable[@"u_intensity"]] = [NSNumber numberWithFloat:_transformedIntensity];
329+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:0.0f];
330+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
331+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_intensity"]] = [NSNumber numberWithFloat:_transformedIntensity];
332332

333333
GLKVector2 dur = GLKVector2Make(0.0, 1.0 / (previousPassTexture.pixelHeight / previousPassTexture.contentScale));
334-
pass.shaderUniforms[self.uniformTranslationTable[@"u_blurDirection"]] = [NSValue valueWithGLKVector2:dur];
334+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_blurDirection"]] = [NSValue valueWithGLKVector2:dur];
335335

336336
} copy]];
337337

@@ -340,9 +340,9 @@ -(void)buildRenderPasses
340340
pass2.shader = self.shader;
341341
pass2.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
342342
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
343-
pass.shaderUniforms[self.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:1.0f];
344-
pass.shaderUniforms[self.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
345-
pass.shaderUniforms[self.uniformTranslationTable[@"u_intensity"]] = [NSNumber numberWithFloat:_transformedIntensity];
343+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_enableGlowMap"]] = [NSNumber numberWithFloat:1.0f];
344+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_luminanceThreshold"]] = [NSNumber numberWithFloat:_luminanceThreshold];
345+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_intensity"]] = [NSNumber numberWithFloat:_transformedIntensity];
346346

347347
} copy]];
348348

cocos2d/CCEffectBrightness.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ -(void)buildRenderPasses
7070
pass0.beginBlocks = @[[^(CCEffectRenderPass *pass, CCTexture *previousPassTexture){
7171
pass.shaderUniforms[CCShaderUniformMainTexture] = previousPassTexture;
7272
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
73-
pass.shaderUniforms[self.uniformTranslationTable[@"u_brightness"]] = [NSNumber numberWithFloat:weakSelf.conditionedBrightness];
73+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_brightness"]] = [NSNumber numberWithFloat:weakSelf.conditionedBrightness];
7474
} copy]];
7575

7676
self.renderPasses = @[pass0];

0 commit comments

Comments
 (0)