I'm trying to understand how to apply shaders in SpriteKit, so I made the following shader that comes from a guide with some adaptations (http://battleofbrothers.com/sirryan/understanding-shaders-in-spritekit):
void main() {
vec4 val = texture2D(u_texture, v_tex_coord);
if (val.a == 1.0) {
gl_FragColor = vec4(1.0,1.0,1.0,1.0);
} else {
gl_FragColor = val;
}
}
The idea of this simple shader is to translate to white every non-transparent pixel of the sprite node.
The shader works with my sprite nodes that have a single texture as their image.
The issue that I'm having is that the shader seems to be ignored when I apply it to a sprite node which comes from a multi-layered SKScene. I've tried to set the shader to every children node of the scene, but it still doesn't appear.
Any suggestions?