Just installed the iOS 9 open beta (version 3) and now I'm having loads of problems with SpriteKit shaders. On iOS 8 the following code worked just fine:
_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];
Edit: the file "TheShader.fsh" looks like this:
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 color = SKDefaultShading(); // the current label color (iOS 9 Compatibility issues here)
color = vec4(gradient + color.r, gradient + color.g, gradient + color.b, color.a);
color.rgb *= color.a; // set background to alpha 0
gl_FragColor = color;
On iOS 9 the console is spewing out a pile of warnings in this format:
2015-07-12 22:43:17.717 ReconInForce[599:110531] Jet: Error Domain=MTLLibraryErrorDomain Code=3 "Compilation failed:
program_source:8:18: error: use of undeclared identifier 'gl_FragCoord'
float yPos = gl_FragCoord.y - labelBase[0];
^
program_source:11:18: error: use of undeclared identifier 'SKDefaultShading'
vec4 color = SKDefaultShading(); // the current label color
^
" UserInfo=0x158c084b0 {NSLocalizedDescription=Compilation failed:
program_source:8:18: error: use of undeclared identifier 'gl_FragCoord'
float yPos = gl_FragCoord.y - labelBase[0];
^
program_source:11:18: error: use of undeclared identifier 'SKDefaultShading'
vec4 color = SKDefaultShading(); // the current label color
^
}
Seems like iOS9 is not supporting SKDefaultShading and gl_FragCoord. How do I find the local pixel dimension without using gl_FragCoord?
The console continues to repeat this forever, slowing down the device. Here's a screenshot:
If I comment out the lines above that say "iOS9 compatibility issues here" then the problem resolves itself, but then I don't have any shaders.
Anyone else having this issue? Much help would be appreciated.