1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
uniform sampler2D texture;
uniform vec2 resolution;
vec4 circle(vec2 uv, vec2 pos, float rad, vec4 color) {
float d = smoothstep(0.0, 2.0, length(pos - uv) - rad);
float t = clamp(d, 0.0, 1.0);
return vec4(color.rgb, color.a * (1.0 - t));
}
void main() {
vec2 uv = gl_TexCoord[0].xy * resolution;
vec2 center = resolution * 0.5;
float radius = 0.49 * resolution.y;
vec4 texture_color = texture2D(texture, gl_TexCoord[0].xy);
vec4 layer1 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 layer2 = circle(uv, center, radius, texture_color);
gl_FragColor = mix(layer1, layer2, layer2.a);
}
|