3 Replies
      Latest reply on Jan 5, 2017 10:27 AM by Bobjt
      fishbait75 Level 1 Level 1 (0 points)

        I am creating a game in Swift + SpriteKit that makes heavy use of shaders.


        All the documentation I can find still states that SKShader(fileNamed: "myshader.fsh") requires that the source file be written in the OpenGLES shader language. This used to be the case but on 10.11 and XCode 7 my shaders throw runtime errors because they seem to be being compiled with the metal shader compiler.


        I was under the impression that even though SpriteKit now uses metal under the hood, existing shaders would continue to work. Is that not the case?

        • Re: SKShader on 10.11 (Metal vs OpenGL ES)
          toriol Apple Staff Apple Staff (40 points)

          Most SKShaders shaders are fully supported in both OpenGL & Metal. If you run into cases that are not, please file a bug report with your specific shader source.



          By default, SpriteKit and SceneKit render with Metal in iOS 9 and OS X El Capitan, however, there is a facility to use OpenGL.


          IMPORTANT: For optimal performance, Metal rendering in SpriteKit and SceneKit is enabled by default. Setting PrefersOpenGL rendering key is not recommended unless it is determined necessary for other reasons.


          To do that:

          1. Edit your app's Info.plist
          2. Add the PrefersOpenGL key with a bool value of YES