Advertisement
Guest User

Untitled

a guest
Sep 25th, 2019
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float square(float val) {
  2.     return val * val;
  3. }
  4.  
  5. float distanceSquared(vec2 p1, vec2 p2) {
  6.     vec2 vector = p2 - p1;
  7.     return vector.x * vector.x + vector.y * vector.y;
  8. }
  9.  
  10. float calcRoundedCorners() {
  11.     if (radius <= 0.0) {
  12.         return 1.0;
  13.     }
  14.     vec2 pixelPos = pass_textureCoords * vec2(uiWidth, uiHeight);
  15.     vec2 minCorner = vec2(radius, radius);
  16.     vec2 maxCorner = vec2(uiWidth - radius, uiHeight - radius);
  17.  
  18.     vec2 cornerPoint = clamp(pixelPos, minCorner, maxCorner);
  19.     float lowerBound = square(radius - cornerSmooth);
  20.     float upperBound = square(radius + cornerSmooth);
  21.     return smoothstep(upperBound, lowerBound, distanceSquared(pixelPos, cornerPoint));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement