Shaders
Shaders in Sprite Kit facilitate SKScenenode
to appear with a special, customized, drawing behavior. This can be achieved by creating the SKShader
objects and assigning a custom OpenGL ES fragment shader.
If a custom shader (the SKShader
object) needs to provide a uniform shader, then you need to create one or more SKUniform
objects and associate them with your shader objects. Shader programs are primarily divided into:
Vertex shaders
Fragment shaders
Let's discuss about both of these in detail:
Vertex shaders: These shaders work on each vertex and most of the calculation is done on the vertex part. They are set by Sprite Kit automatically. As the computation of these shaders are mostly done on the vertex part, not much of the CPU's resources are consumed in the formation.
Fragment shaders: These shaders are written in OpenGL Shading Language. As the name suggests, they work on each pixel. They use very heavy computation and hence are avoided when too many shaders are required.