From 2227e40af76aa10d87bbcce0f7df73d98407881b Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 6 Dec 2020 19:13:20 -0500 Subject: finish platform shader & ball shader --- assets/ball_f.glsl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 assets/ball_f.glsl (limited to 'assets/ball_f.glsl') diff --git a/assets/ball_f.glsl b/assets/ball_f.glsl new file mode 100644 index 0000000..e3dfdb3 --- /dev/null +++ b/assets/ball_f.glsl @@ -0,0 +1,19 @@ +varying vec4 color; +varying vec2 pos; +uniform vec2 center; +uniform float radius; + +void main() { + float dist_squared = dot(pos - center, pos - center); + float threshold = 0.9 * radius; // radius border starts at + float thickness = radius - threshold; + + if (dist_squared > threshold * threshold && dist_squared < radius * radius) { + float dist = sqrt(dist_squared); + float v = (dist - threshold) / thickness; + v = 2.0 * v - 1.0; + gl_FragColor = color * (1.0 - v * v); + } else { + discard; + } +} -- cgit v1.2.3