Skip to content

Instantly share code, notes, and snippets.

@JBlackCat
Last active March 29, 2017 00:37
Show Gist options
  • Save JBlackCat/7d297fd58254dcfdd471dd6687674ab9 to your computer and use it in GitHub Desktop.
Save JBlackCat/7d297fd58254dcfdd471dd6687674ab9 to your computer and use it in GitHub Desktop.

Revisions

  1. JBlackCat revised this gist Mar 29, 2017. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,14 @@ void main() {
    const float tickLineThickness = 0.002;
    vec3 gridColor = vec3(0.5);

    // --------------------------------------
    // --------------------------------------
    // -------- Start Fancy Code ------------
    // -------- "Code Here" -------------
    // -------- End Fancy Code---------------
    // --------------------------------------
    // --------------------------------------

    //Draw r grid lines
    for(float i = -1.0; i < 1.0; i +=tickWidth) {
    //i is the line coordinate;
    @@ -34,14 +42,6 @@ void main() {
    if(abs(p.y - i)< tickLineThickness) pixel = gridColor;
    }

    // --------------------------------------
    // --------------------------------------
    // -------- Start Fancy Code ------------
    // -------- "Code Here" -------------
    // -------- End Fancy Code---------------
    // --------------------------------------
    // --------------------------------------

    //[0,1] coordinat system axes
    if(abs(p.x) < pAxesThickness) pixel = pAxesColor;
    if(abs(p.y) < pAxesThickness) pixel = pAxesColor;
  2. JBlackCat revised this gist Mar 28, 2017. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,6 @@ void main() {
    vec2 r = vec2((gl_FragCoord.xy - 0.5*resolution.xy)/resolution.y) * 2.0; // Is [-1, 1] coordinate system
    vec2 p = vec2(gl_FragCoord.xy/resolution.xy); //[0,1] coordinate system

    // //Maximum x value to maintain aspect ratio?
    //float xMax = iResolution.x/iResolution.y;

    //Set background color
    vec3 bgCol = vec3(0.0); // black
    vec3 pixel = bgCol;
  3. JBlackCat revised this gist Mar 28, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@ void main() {
    vec2 r = vec2((gl_FragCoord.xy - 0.5*resolution.xy)/resolution.y) * 2.0; // Is [-1, 1] coordinate system
    vec2 p = vec2(gl_FragCoord.xy/resolution.xy); //[0,1] coordinate system

    //Maximum x value to maintain aspect ratio?
    float xMax = iResolution.x/iResolution.y;
    // //Maximum x value to maintain aspect ratio?
    //float xMax = iResolution.x/iResolution.y;

    //Set background color
    vec3 bgCol = vec3(0.0); // black
  4. JBlackCat revised this gist Mar 28, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,9 @@ void main() {
    vec2 r = vec2((gl_FragCoord.xy - 0.5*resolution.xy)/resolution.y) * 2.0; // Is [-1, 1] coordinate system
    vec2 p = vec2(gl_FragCoord.xy/resolution.xy); //[0,1] coordinate system

    //Maximum x value to maintain aspect ratio?
    float xMax = iResolution.x/iResolution.y;

    //Set background color
    vec3 bgCol = vec3(0.0); // black
    vec3 pixel = bgCol;
  5. JBlackCat revised this gist Mar 28, 2017. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,25 @@ void main() {
    vec3 pAxesColor = vec3(1.0, 0.412, 0.635);
    float pAxesThickness = 0.008;

    //Grid tick size
    const float tickWidth = 0.1;
    const float tickLineThickness = 0.002;
    vec3 gridColor = vec3(0.5);

    //Draw r grid lines
    for(float i = -1.0; i < 1.0; i +=tickWidth) {
    //i is the line coordinate;
    if(abs(r.x - i)< tickLineThickness) pixel = gridColor;
    if(abs(r.y - i)< tickLineThickness) pixel = gridColor;
    }

    //Draw p grid lines
    for(float i = -1.0; i < 1.0; i +=tickWidth) {
    //i is the line coordinate;
    if(abs(p.x - i)< tickLineThickness) pixel = gridColor;
    if(abs(p.y - i)< tickLineThickness) pixel = gridColor;
    }

    // --------------------------------------
    // --------------------------------------
    // -------- Start Fancy Code ------------
  6. JBlackCat revised this gist Mar 28, 2017. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    //uniform vec2 resolution

    void main() {
    //coordinate systems
    vec2 r = vec2((gl_FragCoord.xy - 0.5*resolution.xy)/resolution.y) * 2.0; // Is [-1, 1] coordinate system
    @@ -13,11 +15,13 @@ void main() {
    vec3 pAxesColor = vec3(1.0, 0.412, 0.635);
    float pAxesThickness = 0.008;

    // -----------------------------------
    // -----------------------------------
    // --------Fancy Code Here------------
    // -----------------------------------
    // -----------------------------------
    // --------------------------------------
    // --------------------------------------
    // -------- Start Fancy Code ------------
    // -------- "Code Here" -------------
    // -------- End Fancy Code---------------
    // --------------------------------------
    // --------------------------------------

    //[0,1] coordinat system axes
    if(abs(p.x) < pAxesThickness) pixel = pAxesColor;
  7. JBlackCat revised this gist Mar 28, 2017. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,13 @@ void main() {

    vec3 pAxesColor = vec3(1.0, 0.412, 0.635);
    float pAxesThickness = 0.008;


    // -----------------------------------
    // -----------------------------------
    // --------Fancy Code Here------------
    // -----------------------------------
    // -----------------------------------

    //[0,1] coordinat system axes
    if(abs(p.x) < pAxesThickness) pixel = pAxesColor;
    if(abs(p.y) < pAxesThickness) pixel = pAxesColor;
  8. JBlackCat created this gist Mar 28, 2017.
    26 changes: 26 additions & 0 deletions coordinate-system-axes.glsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    void main() {
    //coordinate systems
    vec2 r = vec2((gl_FragCoord.xy - 0.5*resolution.xy)/resolution.y) * 2.0; // Is [-1, 1] coordinate system
    vec2 p = vec2(gl_FragCoord.xy/resolution.xy); //[0,1] coordinate system

    //Set background color
    vec3 bgCol = vec3(0.0); // black
    vec3 pixel = bgCol;

    vec3 rAxesColor = vec3(0.537, 1.0, 0.364);
    float rAxesThickness = 0.006;

    vec3 pAxesColor = vec3(1.0, 0.412, 0.635);
    float pAxesThickness = 0.008;

    //[0,1] coordinat system axes
    if(abs(p.x) < pAxesThickness) pixel = pAxesColor;
    if(abs(p.y) < pAxesThickness) pixel = pAxesColor;

    //[-1,1] coordinat system axes
    if(abs(r.x) < rAxesThickness) pixel = rAxesColor;
    if(abs(r.y) < rAxesThickness) pixel = rAxesColor;

    //Final output
    gl_FragColor = vec4(pixel, 1.0);
    }