Skip to content

Instantly share code, notes, and snippets.

@tomaes
Last active February 11, 2019 10:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaes/3162d565ce655e4f5a4a19d45df83e3e to your computer and use it in GitHub Desktop.
Save tomaes/3162d565ce655e4f5a4a19d45df83e3e to your computer and use it in GitHub Desktop.
shadertoy GLSL oneliners
// fragment shader one-liners
// note: some might break for timing reasons (iDate.a/iDate.w) and some for compatibility reasons ("f+=" on a Mac, f.e.)
//
// void mainImage( out vec4 f, vec2 p )
// and then...
// "flames (red)"
{f=vec4(p.x/p.y*mod(sin(p.x-iDate.a),.001*length(p-.9)),.2,.5,1.0);}
// "rain (small)"
{f=vec4((sin(tan(p.x*.4)*p.y/sin(iDate.a+p.x))),p,1.);}
// "rain (big)"
{f=vec4((cos(tan(99./p.y)*p.y/sin(iDate.a+p.x))),p,1.);}
// "yellow flames"
{f=vec4(p,p/p.y*sin(iDate.a*.3/atan(p)));}
// "zoom"
{f=vec4(p/p.y/cos(iDate.a/atan(p)),p);}
// "fork" (breaks)
{f=vec4(p+p.y/sin(iDate.a*.6/atan(p/.1)),p);}
// "sky"
{f=vec4((tan(acos(.1/p.y)/3./sin(iDate.a+p.x/p.y))),p,1.);}
// "circles (fuzzy)"
{f=vec4(p.x*.01+tan(mod(length(p*.01-.9+sin(iDate.a+p.y*.5)),p.x*p.y)*mod(iDate.a,2.)*2.),.0,99./p.y,1.);}
// "circles (clean)" (130 chars)
{f=vec4(p.x*.01+tan(mod(length(p*.005+atan(1./iDate.a)),p.y)*mod(iDate.a,2.)*4.),.0,99./p.y,1.);}
// "silver sky"
{f+=(sin(acos(.1/p.y)/3./sin(iDate.a+p.x/p.y)));}
// "silver sky (final/compatible)"
{f=(acos(.1/p)/4.+tan(iDate.ww+p/p.y)).xxxx;}
// "min" (74 chars)
{f+=dot(p*=log(p),sin(p+iDate.w*.1));}
// "board" (76 chars)
{f+=dot(p*=log(p),tan(p*.005+iDate.w));}
// "flicker" (81 chars)
{f=vec4(dot(p*=cos(p),p/5.*mod(iDate.w,.002)));}
// "blurred" (102 chars)
{f=vec4(dot(p/=log(p),tan(.01/p+iDate.w))*dot(p*=sin(p),p/iDate.w));}
// "still" (87 chars)
{f=vec4(dot(p/=log(p),sin(p))*dot(p+=sin(p),tan(p)));}
// "changing" (100 chars)
f+=dot(p/=log(p*p),tan(iDate.w+sin(p)))+dot(p+=sin(p),tan(p));
// "changing (zoom)" (122 chars)
{f=vec4(dot(p/=log(p*abs(sin(iDate.w*.1))),tan(iDate.w+sin(p)))+dot(p+=sin(p),tan(p*.1)));}
// "beam" (67 chars)
{f=(sin(9./p)/sin(iDate.w)).xxxx;}
// "still" (53 chars)
{f=(tan(p)*p).yxxx;}
// "squares" (63 chars)
{f=(tan(p*.01+iDate.w)).yyxy;}
// "mondrian zoom" (69 chars)
{f=(cos(atan(p*.01)+iDate.w)).yyxy;}
// "mosaic" (90 chars)
{f=sin(dot(p,tan(p/29.))*(p.x*tan(iDate.w))/iDate.wwww);}
// "minimum (still)" (47 chars)
{f=9./p.xyyy;}
// "silver sky" (64 chars)
{f=vec4( cos(iDate.w+p.x/p.y) );}
// "curtain" (100 chars)
{f=vec4(sin(49./p.y)*fract(sin(iDate.w+tan(p.x*.1)/cos(p.y*.1))));}
// "light" (102 chars)
{f=vec4(sin(p.y/99.)/fract(sin(iDate.w+tan(p.x*.02)/tan(p.y*.02))));}
// "complex" (111+-x chars)
{f=vec4(sin(p.y/99.)+fract(sin(iDate.w+sin(p.x)+tan(p.x*.02)/tan(p.y*.02))));}
{f=vec4(sin(p.y/99.)*fract(tan(iDate.w+sin(p.x)+tan(p.x*.02)/tan(p.y*.02))));}
{f=vec4(sin(p.y/99.)*fract(tan(iDate.w+sin(p.x)+tan(p.x*.01)/tan(p.y*.02))));}
{f=vec4(sin(p.y/99.)*fract(tan(iDate.w+sin(p.x)+cos(p.x*.01)/tan(p.y*.02))));}
{f=vec4(sin(p.y/99.)*fract(tan(iDate.w+sin(p.x)/cos(p.y*.02+p.x*.0005)*tan(p.x*.01))));}
{f=vec4(p.y/99.*fract(tan(iDate.w+sin(p.x)/cos(p.y*.02+p.x*.0005)*tan(p.x*.01))));}
{f=vec4(p.y/99.*fract(tan(iDate.w+sin(p.x)/cos(p.y*.02)*tan(p.x*.01))));}
// "mosaic #2" (108 chars)
{f=tan(dot(p*=fract(p.y/2.+iDate.w),tan(p/25.))/max(p.x,p.y)+iDate.wwww);}
// "canon" (114 chars)
{f=tan(dot(p*=fract(p.x/4.-iDate.w),sin(5999./p/25.))/max(p.x,p.y)+iDate.wwww);}
{f=tan(dot(p*=fract(p.x/4.-iDate.w),sin(5999./p/25.))/min(p.x,p.y)+iDate.wwww);}
{f=tan(dot(p*=fract(p.x/4.-iDate.w),sin(5999./p/25.))/min(p.x,p.y)+iDate.xyww);}
// "metal drill" (102/116 chars)
{f=sin(tan(iDate.wwww-sin(p.x+iDate.w)+tan(p.x*.006)/tan(p.y*.01)));}
{f=sin(tan(iDate.wwww+sin(p.x+iDate.w)+tan((p.x+iDate.w*29.)/259.)/tan(p.y*.01)));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment