shadertoy
vec3 Rect(vec2 st, float left, float bottom, float right, float top, float blur ){ vec3 col = vec3(0.); float l = smoothstep(left,left+blur,st.x); float b = smoothstep(bottom,bottom+blur,st.y); float t = smoothstep(top,top+blur,1.-st.y); float r = smoothstep(right,right+blur,1.-st.x); col = vec3(t*b*l*r); return col; } vec3 Rect2(vec2 st, float left, float bottom, float right, float top, float blur ){ vec3 col = vec3(0.); // left-bottom vec2 lb = step(vec2(left,bottom), 1.-st); float pct = lb.x * lb.y; // top-right vec2 tr = step(vec2(right, top),st); pct *= tr.x * tr.y; col = vec3(pct); return col; } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Normalized pixel coordinates (from 0 to 1) vec2 st = fragCoord.xy/iResolution.xy; //st.x *= iResolution.x/iResolution.y; vec3 col = vec3(1.); col = Rect2(st, .1,.1,.1,.1,.01); // Output to screen fragColor = vec4(col,1.0); }