Advertisement
ThinMatrix

Untitled

Apr 27th, 2020
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. float calcRoundedCorners() {
  2.     if (radius <= 0.0) {
  3.         return 1.0;
  4.     }
  5.     vec2 pixelPos = pass_textureCoords * vec2(uiWidth, uiHeight);
  6.     vec2 minCorner = vec2(radius, radius);
  7.     vec2 maxCorner = vec2(uiWidth - radius, uiHeight - radius);
  8.  
  9.     vec2 cornerPoint = clamp(pixelPos, minCorner, maxCorner);
  10.     float lowerBound = square(radius - cornerSmoothFactor);
  11.     float upperBound = square(radius + cornerSmoothFactor);
  12.     return smoothstep(upperBound, lowerBound, distanceSquared(pixelPos, cornerPoint));
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement