Last active
March 30, 2017 18:07
-
-
Save JBlackCat/2f9e4604e9ccd9ee7853ef91fda19c30 to your computer and use it in GitHub Desktop.
Revisions
-
JBlackCat revised this gist
Mar 30, 2017 . 1 changed file with 40 additions and 49 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,66 +1,57 @@ //uniform vec2 resolution; #define PI 3.14159265359 //Anti-aliased coordinate system grid float coordinateGrid(vec2 coords) { //These colors are unused and irrelevant in current implementation. 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; // //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, axesThickness, abs(coords.x)); retrn += 1.0 - smoothstep(0.001, axesThickness, 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)); } void main() { vec2 defaultCoords = vec2(gl_FragCoord.xy/resolution.xy); vec2 viewportCenterCoords = 2.0 * vec2(gl_FragCoord.xy - resolution.xy/2.0) / resolution.y; vec3 colorOut; // -------------------------------------- // ------------- Start ------------------ // Fancy Code Here // ------------- End ------------------ // -------------------------------------- vec3 gridColor = vec3(0.0, 0.634, 0.876); colorOut = mix(colorOut, gridColor, coordinateGrid(viewportCenterCoords)); vec3 pixel = colorOut; gl_FragColor = vec4(pixel, 1.0); } -
JBlackCat revised this gist
Mar 30, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ vec3 gridColor = vec3(0.5); float gridThickness = 0.008; float retrn = 0.0; // //Draw grid lines const float tickWidth = 0.1; @@ -19,8 +19,8 @@ } //Draw the axes retrn += 1.0 - smoothstep(0.001, axesThickness, abs(coords.x)); retrn += 1.0 - smoothstep(0.001, axesThickness, abs(coords.y)); return retrn; } -
JBlackCat created this gist
Mar 29, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ #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); }