rounded_rectangle_no_shadow.glsl 542 B

1234567891011121314151617
  1. uniform float radius;
  2. uniform vec2 resolution;
  3. float rounded_rect(vec2 coord, vec2 size, float r) {
  4. return length(max(abs(coord) - size+r, 0.0)) - r;
  5. }
  6. void main() {
  7. vec2 shadow_offset = vec2(20.0, 20.0);
  8. vec2 uv = gl_TexCoord[0].xy * resolution;
  9. vec2 center = resolution * 0.5;
  10. vec2 size = (resolution - shadow_offset * 2.0) * 0.5;
  11. float rect_dist = rounded_rect(uv - center, size, radius);
  12. float a = clamp(1.0 - smoothstep(0.0, 1.0, rect_dist), 0.0, 1.0);
  13. gl_FragColor = vec4(gl_Color.rgb, gl_Color.a * a);
  14. }