刚刚安装了iOS 9开放式测试版(版本3),现在我遇到了SpriteKit着色器的大量问题.在iOS 8上,以下代码工作正常:
_fontShader = [SKShader shaderWithFileNamed:@"TheShader"]; // TODO: iOS9 compatibility issues here
_fontUniform = [SKUniform uniformWithName:@"labelBase" float:0];
[self.fontShader addUniform:self.fontUniform]; // TODO: iOS9 compatibility issues here
_fontEffects = [SKEffectNode node];
self.fontEffects.shader = self.fontShader; // TODO: iOS9 compatibility issues here
self.fontEffects.shouldEnableEffects = YES;
self.fontEffects.shouldCenterFilter = NO;
self.fontEffects.shouldRasterize = YES;
[self addChild:self.fontEffects];
Run Code Online (Sandbox Code Playgroud)
编辑:文件"TheShader.fsh"如下所示:
float yPos = gl_FragCoord.y - labelBase; // iOS 9 Compatibility issues here
float gradient = 0.35*(yPos / u_sprite_size.y); // ranges from 0 at base to 0.35 at top
vec4 …Run Code Online (Sandbox Code Playgroud)