FREE: Read a new Swift article every day – click here! >>

ShaderKit adds special effects to SpriteKit in seconds

Paul Hudson       @twostraws

I just released a new open-source project called ShaderKit, which delivers 20 different fragment shader effects for use in SpriteKit games.

Fragment shaders are commonly used to provide effects such as water ripples, spinning black holes, flashing lights, embossing, noise, gradients, and more. They run directly on the GPU, which makes them a blazingly fast way to add special effects to games.

The problem is, most SpriteKit developers don’t use them – partly because writing shaders is a unique skill in its own right, but partly also because shaders are written in GLSL rather than Swift.

I built ShaderKit to solve that problem: it’s an open-source library of fragment shaders for SpriteKit that you can drop in to any game. All shaders come with example code so you can see how to use them, plus sandbox apps for both iOS and macOS so you can see how they look.

Here’s a brief video to whet your appetite:

Even better, each of the shaders is comprehensively documented: you get an explanation of how the algorithm works, plus line-by-line comments explaining what each line means in English. All being well this should mean even relative beginners can dive in and try shaders for themselves.

The great thing about shaders is that you can add them to any game without changing your logic – you just drop the shader code into your program and attach it to whatever node you want. So, the next time you want a water effect over your background, a black hole sucking players to their doom, or an infrared view to simulate being the Predator, give ShaderKit a try.

Link: ShaderKit.


Buy Testing Swift Buy Practical iOS 12 Buy Pro Swift Buy Swift Design Patterns Buy Swift Coding Challenges Buy Server-Side Swift (Vapor Edition) Buy Server-Side Swift (Kitura Edition) Buy Hacking with macOS Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with Swift Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

About the author

Paul Hudson is the creator of Hacking with Swift, the most comprehensive series of Swift books in the world. He's also the editor of Swift Developer News, the maintainer of the Swift Knowledge Base, and Mario Kart world champion. OK, so that last part isn't true. If you're curious you can learn more here.

Was this page useful? Let me know!

Click here to visit the Hacking with Swift store >>