#define PI 3.14159265359 //Anti-aliased coordinate system grid float coordinateGrid(vec2 coords) { vec3 axesColor = vec3(0.0, 0.0, 1.0); float axesThickness = 0.015; vec3 gridColor = vec3(0.5); float gridThickness = 0.008; float retrn = 0.0; // What is this returning? //Draw grid lines const float tickWidth = 0.1; for(float i=-2.0; i<2.0; i+=tickWidth) { // "i" is the line coordinate. retrn += 1.0 - smoothstep(0.0, gridThickness, abs(coords.x - i)); retrn += 1.0 - smoothstep(0.0, gridThickness, abs(coords.y - i)); } //Draw the axes retrn += 1.0 - smoothstep(0.001, 0.015, abs(coords.x)); retrn += 1.0 - smoothstep(0.001, 0.015, abs(coords.y)); return retrn; } //returns 1.0 if inside circle float circle(vec2 coords, vec2 center, float radius) { float antiAliasTolerance = 0.005; return 1.0 - smoothstep(radius - antiAliasTolerance, radius + antiAliasTolerance, length(coords - center)); } //returns 1.0 if inside rectangle float rectangle(vec2 r, vec2 topLeft, vec2 bottomRight) { float ret; float d = 0.005; ret = smoothstep(topLeft.x-d, topLeft.x+d, r.x); ret *= smoothstep(topLeft.y-d, topLeft.y+d, r.y); ret *= 1.0 - smoothstep(bottomRight.y-d, bottomRight.y+d, r.y); ret *= 1.0 - smoothstep(bottomRight.x-d, bottomRight.x+d, r.x); return ret; } void main(){ vec2 p = vec2(gl_FragCoord.xy / resolution.xy); vec2 r = (vec2(gl_FragCoord.xy - 0.5*resolution.xy)*2.0)/resolution.y; float xMax = resolution.x / resolution.y; vec3 bgCol = vec3(1.0); vec3 col1 = vec3(0.216, 0.471, 0.698); //blue vec3 col2 = vec3(1.00, 0.329, 0.298); //yellow vec3 col3 = vec3(0.867, 0.910, 0.247); //red vec3 retrn = bgCol; // -------------------------------- // -------------------------------- // -------------------------------- // -------------------------------- vec3 pixel = retrn; gl_FragColor = vec4(pixel, 1.0); }