I have a 64 x 64 pixel white square that I’m trying to clip with a shader so I have a nice smooth edged circle. It’s a sprite.
I can’t however, get the alpha for work on the edges.
This is what I’m trying to make, minus the red. This was done with a shader.
This is the sample code for this test, but not the code I’m working with:
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D texture_sampler;
uniform lowp vec4 tint;
void main()
{
vec4 tex = texture2D(texture_sampler, var_texcoord0);
vec2 p = var_texcoord0 * 2.0 - 1.0;
float d = length(p);
float alpha = 1.0 - smoothstep(0.70, 1.0, d);
vec3 outside_colour = vec3(1.0, 0.0, 0.0); // red
vec3 inside_colour = tex.rgb;
vec3 final_colour = mix(outside_colour, inside_colour, alpha);
gl_FragColor = vec4(final_colour, tint.a);
}
But my issue is when I try to apply it with alpha, it just renders as a solid white square. (I have blend mode Alpha on the sprite). This is the code I’m working with.
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D texture_sampler;
uniform lowp vec4 tint;
void main()
{
vec4 tex = texture2D(texture_sampler, var_texcoord0);
vec2 p = var_texcoord0 * 2.0 - 1.0;
float d = length(p);
float alpha = 1.0 - smoothstep(0.70, 1.0, d);
gl_FragColor = vec4(tex.rgb, alpha);
}
One other thing, when I run an actual build of the game, these both disappear completely anyway. I can only see them in the editor, so that’s another issue I have after I eventually get this alpha thing fixed…
I did also test directly applying alpha, and it worked… so I’m really confused.
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 0.05);
}
My material settings:
My sprite’s atlas settings (its the only image on the atlas and I turned off extrude borders)




