diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-22 03:35:27 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-22 03:35:27 +0200 |
commit | faa74e2c942102a9b1aa215a913fddf422714d7e (patch) | |
tree | ea037970d5fec74586f1a8a637d84f696b3c48be /tests/circle_mask.glsl | |
parent | f02a283c06c51cb29f79e89754b31ffd6952d2e6 (diff) |
Add shader
Diffstat (limited to 'tests/circle_mask.glsl')
-rw-r--r-- | tests/circle_mask.glsl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/circle_mask.glsl b/tests/circle_mask.glsl new file mode 100644 index 0000000..0564cf3 --- /dev/null +++ b/tests/circle_mask.glsl @@ -0,0 +1,17 @@ +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.5 * resolution.y - 1.0; + + vec4 texture_color = texture2D(texture, gl_TexCoord[0].xy); + gl_FragColor = circle(uv, center, radius, texture_color); +}
\ No newline at end of file |