Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float square(float val) {
- return val * val;
- }
- float distanceSquared(vec2 p1, vec2 p2) {
- vec2 vector = p2 - p1;
- return vector.x * vector.x + vector.y * vector.y;
- }
- float calcRoundedCorners() {
- if (radius <= 0.0) {
- return 1.0;
- }
- vec2 pixelPos = pass_textureCoords * vec2(uiWidth, uiHeight);
- vec2 minCorner = vec2(radius, radius);
- vec2 maxCorner = vec2(uiWidth - radius, uiHeight - radius);
- vec2 cornerPoint = clamp(pixelPos, minCorner, maxCorner);
- float lowerBound = square(radius - cornerSmooth);
- float upperBound = square(radius + cornerSmooth);
- return smoothstep(upperBound, lowerBound, distanceSquared(pixelPos, cornerPoint));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement