Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. float udRoundBox( vec2 p, vec2 b, float r )
  2. {
  3. return length(max(abs(p)-b+r,0.0))-r;
  4. }
  5.  
  6. void mainImage( out vec4 fragColor, in vec2 fragCoord )
  7. {
  8. // setup
  9. float t = 0.2 + 0.2 * sin(mod(iTime, 2.0 * PI) - 0.5 * PI);
  10. float iRadius = min(iResolution.x, iResolution.y) * (0.05 + t);
  11. vec2 halfRes = 0.5 * iResolution.xy;
  12.  
  13. // compute box
  14. float b = udRoundBox( fragCoord.xy - halfRes, halfRes, iRadius );
  15.  
  16. // colorize (red / black )
  17. vec3 c = mix( vec3(1.0,0.0,0.0), vec3(0.0,0.0,0.0), smoothstep(0.0,1.0,b) );
  18.  
  19. fragColor = vec4( c, 1.0 );
  20. }
  21.  
  22. float udRoundBox( float2 p, float2 b, float r )
  23. {
  24. return length(max(abs(p)-b+r,0.0))-r;
  25. }
  26.  
  27. float4 cornerRadius(sampler_h src) {
  28.  
  29. float2 greenCoord = src.coord(); // this is alreay in relative coords; no need to devide by image size
  30.  
  31. float t = 0.5;
  32. float iRadius = min(greenCoord.x, greenCoord.y) * (t);
  33. float2 halfRes = float2(greenCoord.x * 0.5, greenCoord.y * 0.5);
  34.  
  35. float b = udRoundBox( float2(greenCoord.x - halfRes.x, greenCoord.y - halfRes.y), halfRes, iRadius );
  36.  
  37. float3 c = mix(float3(1.0,0.0,0.0), float3(0.0,0.0,0.0), smoothstep(0.0,1.0,b) );
  38.  
  39. return float4(c, 1.0);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement