I want to fill a SKShapeNode with a linear gradient. Being a programming perfectionist I want the solution to be as customizable as possible. So I decided to use a fillShader. Here's the shader:
let shader = SKShader(
source: "void main() {" +
"vec4 c1 = vec4(1, 1, 1, 0.25);" +
"vec4 c2 = vec4(0, 0, 0, 0);" +
"vec2 p1 = vec2(0, 0);" +
"vec2 p2 = vec2(1, 1);" +
"vec2 v0 = p2 - p1;" +
"vec2 v = v_tex_coord - p1;" +
"float t = dot(v, v0) / (length(v0) * length(v0));" +
"t = clamp(t, 0.0, 1.0);" +
"gl_FragColor = mix(c1, c2, t);" +
"}")
(c1, c2, p1, p2 should be attributes but here they are constant to isolate the bug)
So the problem is the shader ignores alpha, and instead of transparent color white I see solid white in the corner:
If you change c1 and c2 to other colors, the bug will stay there.
