Skip to content

Instantly share code, notes, and snippets.

@P-Seebauer
Forked from glslioadmin/TEMPLATE.glsl
Created May 21, 2014 12:23
Show Gist options
  • Select an option

  • Save P-Seebauer/99e7c4413a88d2a70bec to your computer and use it in GitHub Desktop.

Select an option

Save P-Seebauer/99e7c4413a88d2a70bec to your computer and use it in GitHub Desktop.

Revisions

  1. P-Seebauer revised this gist May 22, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,8 @@ bool isBlack(float progress, vec2 p){
    }else{

    float nProg = (progress-.25)*2.;

    return (p.x < r.x || p.x > 1.-r.x)
    ;
    ;
    }
    return false;
  2. P-Seebauer revised this gist May 21, 2014. 1 changed file with 2 additions and 11 deletions.
    13 changes: 2 additions & 11 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -24,18 +24,9 @@ bool isBlack(float progress, vec2 p){
    ;

    }else{

    float nProg = (progress-.25)*2.;
    vec3 pr = vec3( r.x, r.y-nProg,r.z);
    vec3 revPr = vec3(1.-r.x,1.- r.y-nProg,1.-r.z);
    //vec3 revPr = 1.-pr;
    return p.x < pr.x || p.x > revPr.x // left/right
    || pr.y < 0. && p.y > fract(pr.y)
    //|| p.y < fract(pr.y) || p.y > fract(revPr.y) // top/bottom
    /*||(p.x < pr.x + pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(pr.x,fract(pr.y))+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(revPr.x-pr.z,fract(pr.y)+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y > fract(revPr.y) - pr.z && distance(vec2(pr.x+pr.z,fract(revPr.y)-pr.z),p) > pr.z) // top left corner
    ||(p.x > revPr.x - pr.z && p.y > fract(revPr.y) - pr.z && distance(vec2(revPr.x,fract(revPr.y))-pr.z,p) > pr.z) // top right corner
    */

    ;
    }
    return false;
  3. P-Seebauer revised this gist May 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ bool isBlack(float progress, vec2 p){
    vec3 revPr = vec3(1.-r.x,1.- r.y-nProg,1.-r.z);
    //vec3 revPr = 1.-pr;
    return p.x < pr.x || p.x > revPr.x // left/right
    || pr.y < 0. && p.y > pr.y
    || pr.y < 0. && p.y > fract(pr.y)
    //|| p.y < fract(pr.y) || p.y > fract(revPr.y) // top/bottom
    /*||(p.x < pr.x + pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(pr.x,fract(pr.y))+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(revPr.x-pr.z,fract(pr.y)+pr.z),p) > pr.z) // bottom right corner
  4. P-Seebauer revised this gist May 21, 2014. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -25,22 +25,26 @@ bool isBlack(float progress, vec2 p){

    }else{
    float nProg = (progress-.25)*2.;
    vec3 pr = vec3( r.x, r.y+nProg,r.z);
    //vec3 revPr = vec3(1.-r.x,1.-r.y+nProg,1.-r.z);
    vec3 revPr = 1.-pr;
    vec3 pr = vec3( r.x, r.y-nProg,r.z);
    vec3 revPr = vec3(1.-r.x,1.- r.y-nProg,1.-r.z);
    //vec3 revPr = 1.-pr;
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < fract(pr.y) || p.y > fract(revPr.y) // top/bottom
    ||(p.x < pr.x + pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(pr.x,fract(pr.y))+pr.z,p) > pr.z) // bottom left corner
    || pr.y < 0. && p.y > pr.y
    //|| p.y < fract(pr.y) || p.y > fract(revPr.y) // top/bottom
    /*||(p.x < pr.x + pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(pr.x,fract(pr.y))+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(revPr.x-pr.z,fract(pr.y)+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y > fract(revPr.y) - pr.z && distance(vec2(pr.x+pr.z,fract(revPr.y)-pr.z),p) > pr.z) // top left corner
    ||(p.x > revPr.x - pr.z && p.y > fract(revPr.y) - pr.z && distance(vec2(revPr.x,fract(revPr.y))-pr.z,p) > pr.z) // top right corner

    */
    ;

    }
    return false;
    }

    bool between (float low, float value, float high){
    return low < value && value < high;
    }

    void main() {
    vec2 p = gl_FragCoord.xy / resolution.xy;
    if(isBlack(progress,p))// distance(p,vec2(.9,.9)) < .1 || p.x < .9 || p.y < .9 )
  5. P-Seebauer revised this gist May 21, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,8 @@ bool isBlack(float progress, vec2 p){

    }else{
    float nProg = (progress-.25)*2.;
    vec3 pr = vec3(r.x, r.y+nProg,r.z);
    vec3 pr = vec3( r.x, r.y+nProg,r.z);
    //vec3 revPr = vec3(1.-r.x,1.-r.y+nProg,1.-r.z);
    vec3 revPr = 1.-pr;
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < fract(pr.y) || p.y > fract(revPr.y) // top/bottom
  6. P-Seebauer revised this gist May 21, 2014. 1 changed file with 17 additions and 13 deletions.
    30 changes: 17 additions & 13 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -8,30 +8,34 @@ uniform vec2 resolution;
    uniform vec3 r; // ( left/right,top/bottom, radius)

    bool isBlack(float progress, vec2 p){
    float nProg = 1.;
    vec3 pr = r * nProg;
    vec3 revPr = 1.-pr;

    if(progress < 0.25|| progress > 0.75){
    // "zoom"
    nProg = progress * 4.;
    if (progress > 0.5) nProg = (-progress+1.)*4. ;
    float nProg = (progress < .5) ? progress * 4. : (-progress+1.)*4.;
    // if (progress > 0.5) nProg = (-progress+1.)*4. ;
    vec3 pr = r * nProg;
    vec3 revPr = 1.-pr;
    // somehow the bvec functions aren't working for me…
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < pr.y || p.y > revPr.y // top/bottom
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < pr.y || p.y > revPr.y // top/bottom
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < pr.y + pr.z && distance(vec2(revPr.x-pr.z,pr.y+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y > revPr.y - pr.z && distance(vec2(pr.x+pr.z,revPr.y-pr.z),p) > pr.z) // top left corner
    ||(p.x > revPr.x - pr.z && p.y > revPr.y - pr.z && distance(vec2(revPr.x,revPr.y)-pr.z,p) > pr.z) // top right corner

    ;
    ;

    }else{
    //transition
    return p.x < pr.x || p.y < pr.y
    || p.x > revPr.x || p.y > revPr.y;
    float nProg = (progress-.25)*2.;
    vec3 pr = vec3(r.x, r.y+nProg,r.z);
    vec3 revPr = 1.-pr;
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < fract(pr.y) || p.y > fract(revPr.y) // top/bottom
    ||(p.x < pr.x + pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(pr.x,fract(pr.y))+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < fract(pr.y) + pr.z && distance(vec2(revPr.x-pr.z,fract(pr.y)+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y > fract(revPr.y) - pr.z && distance(vec2(pr.x+pr.z,fract(revPr.y)-pr.z),p) > pr.z) // top left corner
    ||(p.x > revPr.x - pr.z && p.y > fract(revPr.y) - pr.z && distance(vec2(revPr.x,fract(revPr.y))-pr.z,p) > pr.z) // top right corner

    ;

    }
    return false;
    }
  7. P-Seebauer revised this gist May 21, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -21,11 +21,11 @@ bool isBlack(float progress, vec2 p){
    // somehow the bvec functions aren't working for me…
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < pr.y || p.y > revPr.y // top/bottom
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < pr.y + pr.z && distance(vec2(revPr.x-pr.z,pr.y+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner

    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < pr.y + pr.z && distance(vec2(revPr.x-pr.z,pr.y+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y > revPr.y - pr.z && distance(vec2(pr.x+pr.z,revPr.y-pr.z),p) > pr.z) // top left corner
    ||(p.x > revPr.x - pr.z && p.y > revPr.y - pr.z && distance(vec2(revPr.x,revPr.y)-pr.z,p) > pr.z) // top right corner
    ;

    }else{
  8. P-Seebauer revised this gist May 21, 2014. 1 changed file with 8 additions and 4 deletions.
    12 changes: 8 additions & 4 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,14 @@ bool isBlack(float progress, vec2 p){
    if (progress > 0.5) nProg = (-progress+1.)*4. ;
    vec3 pr = r * nProg;
    vec3 revPr = 1.-pr;

    return p.x < pr.x || p.y < pr.y
    || p.x > revPr.x || p.y > revPr.y
    || (distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z && pr.x + pr.z > p.x && pr.y + pr.z > p.y) // bottom left corner
    // somehow the bvec functions aren't working for me…
    return p.x < pr.x || p.x > revPr.x // left/right
    || p.y < pr.y || p.y > revPr.y // top/bottom
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner
    ||(p.x > revPr.x - pr.z && p.y < pr.y + pr.z && distance(vec2(revPr.x-pr.z,pr.y+pr.z),p) > pr.z) // bottom right corner
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner
    ||(p.x < pr.x + pr.z && p.y < pr.y + pr.z && distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z) // bottom left corner

    ;

    }else{
  9. P-Seebauer revised this gist May 21, 2014. 2 changed files with 34 additions and 3 deletions.
    35 changes: 33 additions & 2 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,38 @@ uniform sampler2D from, to;
    uniform float progress;
    uniform vec2 resolution;

    uniform vec3 r; // ( left/right,top/bottom, radius)

    bool isBlack(float progress, vec2 p){
    float nProg = 1.;
    vec3 pr = r * nProg;
    vec3 revPr = 1.-pr;

    if(progress < 0.25|| progress > 0.75){
    // "zoom"
    nProg = progress * 4.;
    if (progress > 0.5) nProg = (-progress+1.)*4. ;
    vec3 pr = r * nProg;
    vec3 revPr = 1.-pr;

    return p.x < pr.x || p.y < pr.y
    || p.x > revPr.x || p.y > revPr.y
    || (distance(vec2(pr.x,pr.y)+pr.z,p) > pr.z && pr.x + pr.z > p.x && pr.y + pr.z > p.y) // bottom left corner
    ;

    }else{
    //transition
    return p.x < pr.x || p.y < pr.y
    || p.x > revPr.x || p.y > revPr.y;
    }
    return false;
    }

    void main() {
    vec2 p = gl_FragCoord.xy / resolution.xy;
    gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);
    }
    if(isBlack(progress,p))// distance(p,vec2(.9,.9)) < .1 || p.x < .9 || p.y < .9 )
    gl_FragColor = vec4(0,0,0,0);
    else
    gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);

    }
    2 changes: 1 addition & 1 deletion uniforms.default.json
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    {}
    {"r":[0.1,0.05,0.05]}
  10. @glslioadmin glslioadmin revised this gist May 16, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ precision highp float;
    uniform sampler2D from, to;
    uniform float progress;
    uniform vec2 resolution;

    void main() {
    vec2 p = gl_FragCoord.xy / resolution.xy;
    gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);
  11. @glslioadmin glslioadmin revised this gist May 16, 2014. 1 changed file with 18 additions and 4 deletions.
    22 changes: 18 additions & 4 deletions ~LICENSE
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,22 @@
    GLSL.io Transition License (v1) under MIT
    GLSL.io Transition License (v1):
    The MIT License (MIT)

    Copyright (C) 2014 [email protected]

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
  12. @glslioadmin glslioadmin created this gist May 16, 2014.
    11 changes: 11 additions & 0 deletions TEMPLATE.glsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #ifdef GL_ES
    precision highp float;
    #endif
    uniform sampler2D from, to;
    uniform float progress;
    uniform vec2 resolution;

    void main() {
    vec2 p = gl_FragCoord.xy / resolution.xy;
    gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);
    }
    1 change: 1 addition & 0 deletions uniforms.default.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    {}
    8 changes: 8 additions & 0 deletions ~LICENSE
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    GLSL.io Transition License (v1) under MIT
    Copyright (C) 2014 [email protected]

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.