blob: 93a6c7c071b330542f066c7c6c1a7de64411301a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#version 110
uniform float radius;
uniform vec2 halfSize;
uniform vec2 centerPos;
uniform float smoothness;
float roundedBoxSDF(vec2 CenterPosition, vec2 Size, float Radius) {
return length(max(abs(CenterPosition)-Size+Radius,0.0))-Radius;
}
void main() {
float distance = roundedBoxSDF(gl_FragCoord.xy - centerPos, halfSize, radius);
float smoothedAlpha = smoothstep(-smoothness,0.0, -distance);
gl_FragColor = gl_Color * vec4(1.0, 1.0, 1.0, smoothedAlpha);
}
|