Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
ae07b0daf8 |
31 changed files with 3221 additions and 215 deletions
|
@ -1,62 +0,0 @@
|
||||||
#pragma map font=image:./res/ascii.png
|
|
||||||
|
|
||||||
vec4 ascii(vec2 uv, int char) {
|
|
||||||
vec2 charPos = vec2(char % 16, 15 - char / 16) / 16;
|
|
||||||
return texture2D(font, (charPos + clamp(uv*.5+.5, 0, 1) / 16) * vec2(1, -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 text(vec2 uv, float time) {
|
|
||||||
int text[19]; // REFRESHING MEMORIES
|
|
||||||
text[0] = 0x52; // R
|
|
||||||
text[1] = 0x45; // E
|
|
||||||
text[2] = 0x46; // F
|
|
||||||
text[3] = 0x52; // R
|
|
||||||
text[4] = 0x45; // E
|
|
||||||
text[5] = 0x53; // S
|
|
||||||
text[6] = 0x48; // H
|
|
||||||
text[7] = 0x49; // I
|
|
||||||
text[8] = 0x4E; // N
|
|
||||||
text[9] = 0x47; // G
|
|
||||||
text[10] = 0x20;
|
|
||||||
text[11] = 0x4D; // M
|
|
||||||
text[12] = 0x45; // E
|
|
||||||
text[13] = 0x4D; // M
|
|
||||||
text[14] = 0x4F; // O
|
|
||||||
text[15] = 0x52; // R
|
|
||||||
text[16] = 0x49; // I
|
|
||||||
text[17] = 0x45; // E
|
|
||||||
text[18] = 0x53; // S
|
|
||||||
|
|
||||||
float numShown = 10;
|
|
||||||
|
|
||||||
int edge = int(step(1, mod(time, 2)));
|
|
||||||
int strStart = 11 * edge;
|
|
||||||
int xoffset = 1 * edge;
|
|
||||||
|
|
||||||
vec4 face = vec4(0);
|
|
||||||
|
|
||||||
int strPos = int(floor((uv.x) * numShown - xoffset)) + strStart;
|
|
||||||
if (uv.x > (xoffset / numShown) && strPos < text.length()) {
|
|
||||||
int char = text[strPos];
|
|
||||||
vec2 charUV = vec2(mod(uv.x * numShown, 1), uv.y) * 2 - 1;
|
|
||||||
face = ascii(charUV * 0.8, char);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vec4(0, 0, 0, face.r * 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 wave(vec2 uv, float time) {
|
|
||||||
vec3 a = vec3(0, 132, 176) / 255;
|
|
||||||
vec3 b = vec3(0, 163, 86) / 255;
|
|
||||||
return mix(a, b, sin(uv.x * 2 + time*4)*.5+.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
||||||
vec2 uv = fragCoord / iResolution.xy;
|
|
||||||
|
|
||||||
fragColor.a = 1;
|
|
||||||
fragColor.rgb = wave(uv, iTime * .5);
|
|
||||||
|
|
||||||
vec4 textColor = text(uv, iTime * .5);
|
|
||||||
fragColor.rgb = mix(fragColor.rgb, textColor.rgb, textColor.a);
|
|
||||||
}
|
|
65
analythical-motionblur-2d.glsl
Normal file
65
analythical-motionblur-2d.glsl
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// The MIT License
|
||||||
|
// Copyright © 2014 Inigo Quilez
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
// Analytic motion blur, for 2D spheres (disks).
|
||||||
|
//
|
||||||
|
// (Linearly) Moving Disk - pixel/ray overlap test. The resulting equation is a quadratic
|
||||||
|
// that can be solved to compute time coverage of the swept disk behind the pixel over the
|
||||||
|
// aperture of the camera (a full frame at 24 hz in this test).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// draw a disk with motion blur
|
||||||
|
vec3 diskWithMotionBlur( vec3 col, in vec2 uv, in vec3 sph, in vec2 cd, in vec3 sphcol )
|
||||||
|
{
|
||||||
|
vec2 xc = uv - sph.xy;
|
||||||
|
float a = dot(cd,cd);
|
||||||
|
float b = dot(cd,xc);
|
||||||
|
float c = dot(xc,xc) - sph.z*sph.z;
|
||||||
|
float h = b*b - a*c;
|
||||||
|
if( h>0.0 )
|
||||||
|
{
|
||||||
|
h = sqrt( h );
|
||||||
|
|
||||||
|
float ta = max( 0.0, (-b - h)/a );
|
||||||
|
float tb = min( 1.0, (-b + h)/a );
|
||||||
|
|
||||||
|
if( ta < tb ) // we can comment this conditional, in fact
|
||||||
|
col = mix( col, sphcol, clamp(2.0*(tb-ta),0.0,1.0) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 hash3( float n ) { return fract(sin(vec3(n,n+1.0,n+2.0))*43758.5453123); }
|
||||||
|
vec4 hash4( float n ) { return fract(sin(vec4(n,n+1.0,n+2.0,n+3.0))*43758.5453123); }
|
||||||
|
|
||||||
|
const float speed = 8.0;
|
||||||
|
vec2 getPosition( float time, vec4 id ) { return vec2( 0.9*sin((speed*(0.75+0.5*id.z))*time+20.0*id.x), 0.75*cos(speed*(0.75+0.5*id.w)*time+20.0*id.y) ); }
|
||||||
|
vec2 getVelocity( float time, vec4 id ) { return vec2( speed*0.9*cos((speed*(0.75+0.5*id.z))*time+20.0*id.x), -speed*0.75*sin(speed*(0.75+0.5*id.w)*time+20.0*id.y) ); }
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = (2.0*fragCoord.xy-iResolution.xy) / iResolution.y;
|
||||||
|
|
||||||
|
vec3 col = vec3(0.2) + 0.05*p.y;
|
||||||
|
|
||||||
|
for( int i=0; i<16; i++ )
|
||||||
|
{
|
||||||
|
vec4 off = hash4( float(i)*13.13 );
|
||||||
|
vec3 sph = vec3( getPosition( iTime, off ), 0.02+0.1*off.x );
|
||||||
|
vec2 cd = getVelocity( iTime, off ) /24.0 ;
|
||||||
|
vec3 sphcol = 0.7 + 0.3*sin( 3.0*off.z + vec3(4.0,0.0,2.0) );
|
||||||
|
|
||||||
|
col = diskWithMotionBlur( col, p, sph, cd, sphcol );
|
||||||
|
}
|
||||||
|
|
||||||
|
col += (1.0/255.0)*hash3(p.x+13.0*p.y);
|
||||||
|
|
||||||
|
fragColor = vec4(col,1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/MdSGDm
|
64
blobs.glsl
Normal file
64
blobs.glsl
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
// By @paulofalcao
|
||||||
|
//
|
||||||
|
// Blobs
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
|
||||||
|
float makePoint(float x,float y,float fx,float fy,float sx,float sy,float t){
|
||||||
|
float xx=x+tan(t*fx)*sx;
|
||||||
|
float yy=y+sin(t*fy)*sy;
|
||||||
|
return 1.0/sqrt(xx*xx+yy*yy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
|
||||||
|
vec2 p=(gl_FragCoord.xy/resolution.x)*2.0-vec2(1.0,resolution.y/resolution.x);
|
||||||
|
|
||||||
|
p=p*2.0;
|
||||||
|
|
||||||
|
float x=p.x;
|
||||||
|
float y=p.y;
|
||||||
|
|
||||||
|
float a=
|
||||||
|
makePoint(x,y,3.3,2.9,0.3,0.3,time);
|
||||||
|
a=a+makePoint(x,y,1.9,2.0,0.4,0.4,time);
|
||||||
|
a=a+makePoint(x,y,0.8,0.7,0.4,0.5,time);
|
||||||
|
a=a+makePoint(x,y,2.3,0.1,0.6,0.3,time);
|
||||||
|
a=a+makePoint(x,y,0.8,1.7,0.5,0.4,time);
|
||||||
|
a=a+makePoint(x,y,0.3,1.0,0.4,0.4,time);
|
||||||
|
a=a+makePoint(x,y,1.4,1.7,0.4,0.5,time);
|
||||||
|
a=a+makePoint(x,y,1.3,2.1,0.6,0.3,time);
|
||||||
|
a=a+makePoint(x,y,1.8,1.7,0.5,0.4,time);
|
||||||
|
|
||||||
|
float b=
|
||||||
|
makePoint(x,y,1.2,1.9,0.3,0.3,time);
|
||||||
|
b=b+makePoint(x,y,0.7,2.7,0.4,0.4,time);
|
||||||
|
b=b+makePoint(x,y,1.4,0.6,0.4,0.5,time);
|
||||||
|
b=b+makePoint(x,y,2.6,0.9,0.6,0.3,time);
|
||||||
|
b=b+makePoint(x,y,0.7,1.4,0.5,0.4,time);
|
||||||
|
b=b+makePoint(x,y,0.7,1.7,0.4,0.4,time);
|
||||||
|
b=b+makePoint(x,y,0.8,0.5,0.4,0.5,time);
|
||||||
|
b=b+makePoint(x,y,1.4,0.7,0.6,0.3,time);
|
||||||
|
b=b+makePoint(x,y,0.7,1.3,0.5,0.4,time);
|
||||||
|
|
||||||
|
float c=
|
||||||
|
makePoint(x,y,3.7,0.3,0.3,0.3,time);
|
||||||
|
c=c+makePoint(x,y,1.9,1.3,0.4,0.4,time);
|
||||||
|
c=c+makePoint(x,y,0.8,0.9,0.4,0.5,time);
|
||||||
|
c=c+makePoint(x,y,1.2,1.7,0.6,0.3,time);
|
||||||
|
c=c+makePoint(x,y,0.3,0.6,0.5,0.4,time);
|
||||||
|
c=c+makePoint(x,y,0.3,0.3,0.4,0.4,time);
|
||||||
|
c=c+makePoint(x,y,1.4,0.8,0.4,0.5,time);
|
||||||
|
c=c+makePoint(x,y,0.2,0.6,0.6,0.3,time);
|
||||||
|
c=c+makePoint(x,y,1.3,0.5,0.5,0.4,time);
|
||||||
|
|
||||||
|
vec3 d=vec3(a,b,c)/32.0;
|
||||||
|
|
||||||
|
gl_FragColor = vec4(d.x,d.y,d.z,1.0);
|
||||||
|
}
|
36
bubbles.glsl
Normal file
36
bubbles.glsl
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Created by inigo quilez - iq/2013
|
||||||
|
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = (fragCoord - iResolution.xy * 0.5) / min(iResolution.x, iResolution.y);
|
||||||
|
|
||||||
|
// background
|
||||||
|
vec3 color = vec3(0.8 + 0.2*uv.y);
|
||||||
|
|
||||||
|
// bubbles
|
||||||
|
for( int i=0; i<40; i++ )
|
||||||
|
{
|
||||||
|
// bubble seeds
|
||||||
|
float pha = sin(float(i)*546.13+1.0)*0.5 + 0.5;
|
||||||
|
float siz = pow( sin(float(i)*651.74+5.0)*0.5 + 0.5, 4.0 );
|
||||||
|
float pox = sin(float(i)*321.55+4.1) * iResolution.x / iResolution.y;
|
||||||
|
|
||||||
|
// buble size, position and color
|
||||||
|
float rad = 0.1 + 0.5*siz;
|
||||||
|
vec2 pos = vec2( pox, -1.0-rad + (2.0+2.0*rad)*mod(pha+0.1*iTime*(0.2+0.8*siz),1.0));
|
||||||
|
float dis = length( uv - pos );
|
||||||
|
vec3 col = mix( vec3(0.94,0.3,0.0), vec3(0.1,0.4,0.8), 0.5+0.5*sin(float(i)*1.2+1.9));
|
||||||
|
// col+= 8.0*smoothstep( rad*0.95, rad, dis );
|
||||||
|
|
||||||
|
// render
|
||||||
|
float f = length(uv-pos)/rad;
|
||||||
|
f = sqrt(clamp(1.0-f*f,0.0,1.0));
|
||||||
|
color -= col.zyx *(1.0-smoothstep( rad*0.95, rad, dis )) * f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// vigneting
|
||||||
|
// color *= sqrt(1.5-0.5*length(uv));
|
||||||
|
|
||||||
|
fragColor = vec4(color,1.0);
|
||||||
|
}
|
24
cities-are-old-forests.glsl
Normal file
24
cities-are-old-forests.glsl
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma map iChannel0=video:/home/polyfloyd/Documents/Projects/Text Smilies/Lenny Face Challenge/LENNY FACE TAG Shubble lO82ggwCnAQ.webm
|
||||||
|
|
||||||
|
float zigzag(float n) {
|
||||||
|
// 1.33 should be 1.0 for real zigzag
|
||||||
|
return abs(mod(n,2.0)-1.33);
|
||||||
|
}
|
||||||
|
void mainImage( out vec4 O, in vec2 uv ) {
|
||||||
|
uv /= iResolution.y;
|
||||||
|
uv.x -= .5*iResolution.x/iResolution.y;
|
||||||
|
uv.y -= .5;
|
||||||
|
float l = length(uv) + .2 * sin(iTime * .21);
|
||||||
|
float a = atan(uv.y, uv.x)/3.14159 + sin(l + iTime * .1);
|
||||||
|
uv.x = zigzag(a * 3.);
|
||||||
|
uv.y = zigzag(l * 5.);
|
||||||
|
|
||||||
|
// darkening radial waves
|
||||||
|
float bri = (1. + .5 * sin(l * 5. - iTime));
|
||||||
|
vec4 c = texture(iChannel0, uv) * bri;
|
||||||
|
|
||||||
|
// colorize
|
||||||
|
c *= vec4(10., 17., 1.8, 1.);
|
||||||
|
c = .5+.5*sin(c);
|
||||||
|
O = c;
|
||||||
|
}
|
|
@ -1,153 +0,0 @@
|
||||||
// "Fireworks" by Martijn Steinrucken aka BigWings - 2015
|
|
||||||
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
|
|
||||||
// License.
|
|
||||||
// Email:countfrolic@gmail.com Twitter:@The_ArtOfCode
|
|
||||||
|
|
||||||
// Adaptation for Bitlair's LED-Banner by polyfloyd
|
|
||||||
|
|
||||||
#pragma map font=image:./res/ascii.png
|
|
||||||
|
|
||||||
#define PI 3.141592653589793238
|
|
||||||
|
|
||||||
#define B(x,y,z,w) (smoothstep(x-z, x+z, w)*smoothstep(y+z, y-z, w))
|
|
||||||
|
|
||||||
#define NUM_EXPLOSIONS 32.
|
|
||||||
#define NUM_PARTICLES 70.
|
|
||||||
|
|
||||||
// <Fireworks>
|
|
||||||
#define MOD3 vec3(.1031,.11369,.13787)
|
|
||||||
|
|
||||||
vec3 hash31(float p) {
|
|
||||||
vec3 p3 = fract(vec3(p) * MOD3);
|
|
||||||
p3 += dot(p3, p3.yzx + 19.19);
|
|
||||||
return fract(vec3((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y, (p3.y+p3.z)*p3.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
float hash12(vec2 p){
|
|
||||||
vec3 p3 = fract(vec3(p.xyx) * MOD3);
|
|
||||||
p3 += dot(p3, p3.yzx + 19.19);
|
|
||||||
return fract((p3.x + p3.y) * p3.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
float circ(vec2 uv, vec2 pos, float size) {
|
|
||||||
uv -= pos;
|
|
||||||
|
|
||||||
size *= size;
|
|
||||||
return smoothstep(size*1.1, size, dot(uv, uv));
|
|
||||||
}
|
|
||||||
|
|
||||||
float light(vec2 uv, vec2 pos, float size) {
|
|
||||||
uv -= pos;
|
|
||||||
size *= size;
|
|
||||||
return size/dot(uv, uv);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 explosion(vec2 uv, vec2 p, float seed, float t) {
|
|
||||||
vec3 col = vec3(0.);
|
|
||||||
|
|
||||||
vec3 en = hash31(seed);
|
|
||||||
vec3 baseCol = en;
|
|
||||||
for(float i=0.; i<NUM_PARTICLES; i++) {
|
|
||||||
vec3 n = hash31(i)-.5;
|
|
||||||
|
|
||||||
vec2 startP = p-vec2(0., t*t*.1);
|
|
||||||
vec2 endP = startP+normalize(n.xy)*n.z;
|
|
||||||
|
|
||||||
|
|
||||||
float pt = 1.-pow(t-1., 2.);
|
|
||||||
vec2 pos = mix(p, endP, pt);
|
|
||||||
float size = mix(.01, .005, smoothstep(0., .1, pt));
|
|
||||||
size *= smoothstep(1., .1, pt);
|
|
||||||
|
|
||||||
float sparkle = (sin((pt+n.z)*100.)*.5+.5);
|
|
||||||
sparkle = pow(sparkle, pow(en.x, 3.)*50.)*mix(0.01, .01, en.y*n.y);
|
|
||||||
|
|
||||||
// size += sparkle*B(.6, 1., .1, t);
|
|
||||||
size += sparkle*B(en.x, en.y, en.z, t);
|
|
||||||
|
|
||||||
col += baseCol*light(uv, pos, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
return col;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 rainbow(vec3 c, float t) {
|
|
||||||
float avg = (c.r+c.g+c.b)/3.;
|
|
||||||
c = avg + (c-avg)*sin(vec3(0., .333, .666)+t);
|
|
||||||
c += sin(vec3(.4, .3, .3)*t + vec3(1.1244,3.43215,6.435))*vec3(.4, .1, .5);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 fireworks(vec2 fragCoord, float t) {
|
|
||||||
vec2 uv = fragCoord.xy / iResolution.xy;
|
|
||||||
uv.x -= .5;
|
|
||||||
uv.y /= iResolution.x/iResolution.y;
|
|
||||||
|
|
||||||
float n = hash12(uv+10.);
|
|
||||||
|
|
||||||
vec3 c = vec3(0.);
|
|
||||||
|
|
||||||
for (float i=0.; i<NUM_EXPLOSIONS; i++) {
|
|
||||||
float et = t+i*1234.45235;
|
|
||||||
float id = floor(et);
|
|
||||||
et -= id;
|
|
||||||
|
|
||||||
vec2 p = hash31(id).xy;
|
|
||||||
p.x -= .5;
|
|
||||||
p.x *= 1.6;
|
|
||||||
c += explosion(uv, p, id, et);
|
|
||||||
}
|
|
||||||
c = rainbow(c, t*2);
|
|
||||||
|
|
||||||
return vec4(c, 1);
|
|
||||||
}
|
|
||||||
// </fireworks>
|
|
||||||
|
|
||||||
vec4 ascii(vec2 uv, int char) {
|
|
||||||
vec2 charPos = vec2(char % 16, 15 - char / 16) / 16;
|
|
||||||
return texture2D(font, (charPos + clamp(uv*.5+.5, 0, 1) / 16) * vec2(1, -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
int imod(int n, int d) {
|
|
||||||
return int(mod(n, d));
|
|
||||||
}
|
|
||||||
|
|
||||||
float text(vec2 uv, float time) {
|
|
||||||
int s = int(iDate.w) + 1;
|
|
||||||
int seconds = imod(s, 60);
|
|
||||||
int minutes = imod(s / 60, 60);
|
|
||||||
int hours = imod(s / (60*60) + 1, 24);
|
|
||||||
int text[8]; // HH:MM:SS
|
|
||||||
text[0] = 0x30 + imod(hours/10, 10); // H
|
|
||||||
text[1] = 0x30 + imod(hours, 10); // H
|
|
||||||
text[2] = 0x3a; // :
|
|
||||||
text[3] = 0x30 + imod(minutes/10, 10); // M
|
|
||||||
text[4] = 0x30 + imod(minutes, 10); // M
|
|
||||||
text[5] = 0x3a; // :
|
|
||||||
text[6] = 0x30 + imod(seconds/10, 10); // S
|
|
||||||
text[7] = 0x30 + imod(seconds, 10); // S
|
|
||||||
|
|
||||||
const float numShown = 10;
|
|
||||||
const int xoffset = 1;
|
|
||||||
|
|
||||||
vec4 face = vec4(0);
|
|
||||||
int charPos = int(floor((uv.x) * numShown - xoffset));
|
|
||||||
if (uv.x > (xoffset / numShown) && charPos < text.length()) {
|
|
||||||
int char = text[charPos];
|
|
||||||
vec2 charUV = vec2(mod(uv.x * numShown, 1), uv.y) * 2 - 1;
|
|
||||||
face = ascii(charUV * 0.8, char);
|
|
||||||
}
|
|
||||||
return clamp(face.r * 16, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
|
||||||
vec2 uv = fragCoord / iResolution.xy;
|
|
||||||
|
|
||||||
vec4 fw = fireworks(fragCoord, iTime+60);
|
|
||||||
float tx = text(uv, iTime);
|
|
||||||
|
|
||||||
vec4 color = vec4(0, 0, 0, 1);
|
|
||||||
color.rgb = mix(color.rgb, fw.rgb, fw.a);
|
|
||||||
color.rgb = mix(color.rgb, 1-fw.rgb, tx);
|
|
||||||
fragColor = color;
|
|
||||||
}
|
|
60
cyan-bubbles.glsl
Normal file
60
cyan-bubbles.glsl
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#define ROWS 9
|
||||||
|
#define COLS 12.
|
||||||
|
#define PI 3.14159265359
|
||||||
|
#define TAU 6.28318530718
|
||||||
|
#define es (4./iResolution.y)
|
||||||
|
#define initialRad .175
|
||||||
|
#define waveCenter .4325
|
||||||
|
#define waveWidth .205
|
||||||
|
#define colDelta PI/COLS
|
||||||
|
#define rMat(x) mat2(cos(x), -sin(x), sin(x), cos(x))
|
||||||
|
#define dotRad(x) TAU*x/float(COLS)*.25
|
||||||
|
#define CLR vec3(.388, .843, .976)
|
||||||
|
|
||||||
|
float rm(float value, float min, float max) {
|
||||||
|
return clamp((value - min) / (max - min), 0., 1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
float calcRowRad(int rowNum){
|
||||||
|
float rad = initialRad;
|
||||||
|
//FIXME codeblock below could be replaced with non conditional expression,
|
||||||
|
// but in some reason it don't work. Any ideas?
|
||||||
|
//rad += step(0., sin(iTime)) * step(0., cos(iTime)) * .066;
|
||||||
|
{
|
||||||
|
float s = sin(iTime * 4.);
|
||||||
|
float c = cos(iTime * 4.);
|
||||||
|
if(s > 0. && c > 0.)
|
||||||
|
rad += s * .066;
|
||||||
|
}
|
||||||
|
for(int i=0; i<rowNum; i++)
|
||||||
|
rad += dotRad(rad) * 1.33;
|
||||||
|
return rad;
|
||||||
|
}
|
||||||
|
|
||||||
|
float clr(float r, float a){
|
||||||
|
vec2 st = vec2(r * cos(a), r * sin(a));
|
||||||
|
float clr = 0.;
|
||||||
|
for(int j = 0; j < ROWS; j++){
|
||||||
|
float rowRad = calcRowRad(j);
|
||||||
|
vec2 dotCenter = vec2(rowRad, 0.) * rMat(colDelta * mod(float(j), 2.));
|
||||||
|
float dotRad = dotRad(rowRad);
|
||||||
|
float dotClr = smoothstep(dotRad, dotRad - es, length(st - dotCenter));
|
||||||
|
float thickness = pow(rm(abs(length(dotCenter) - waveCenter), 0., waveWidth), 1.25);
|
||||||
|
dotClr *= smoothstep(dotRad * thickness - es, dotRad * thickness, length(st - dotCenter));
|
||||||
|
dotClr *= step(es, 1. - thickness);
|
||||||
|
clr += dotClr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return clr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 st = (fragCoord.xy * 2. - iResolution.xy)/iResolution.y;
|
||||||
|
float delta = PI/COLS*2.;
|
||||||
|
float l = length(st);
|
||||||
|
float a = mod(atan(st.y, st.x), delta) - delta/4.;
|
||||||
|
fragColor = vec4(clr(l, a) * CLR, 1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/Xl2Bz3
|
114
disk.glsl
Normal file
114
disk.glsl
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
// The MIT License
|
||||||
|
// Copyright © 2013 Inigo Quilez
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SC 3.0
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
//
|
||||||
|
// Elegant way to intersect a planar coordinate system (3x3 linear system)
|
||||||
|
//
|
||||||
|
vec3 intersectCoordSys( in vec3 o, in vec3 d, vec3 c, vec3 u, vec3 v )
|
||||||
|
{
|
||||||
|
vec3 q = o - c;
|
||||||
|
return vec3(
|
||||||
|
dot( cross(u,v), q ),
|
||||||
|
dot( cross(q,u), d ),
|
||||||
|
dot( cross(v,q), d ) ) /
|
||||||
|
dot( cross(v,u), d );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
//
|
||||||
|
// Ugly (but faster) way to intersect a planar coordinate system: plane + projection
|
||||||
|
//
|
||||||
|
vec3 intersectCoordSys( in vec3 o, in vec3 d, vec3 c, vec3 u, vec3 v )
|
||||||
|
{
|
||||||
|
vec3 q = o - c;
|
||||||
|
vec3 n = cross(u,v);
|
||||||
|
float t = -dot(n,q)/dot(d,n);
|
||||||
|
float r = dot(u,q + d*t);
|
||||||
|
float s = dot(v,q + d*t);
|
||||||
|
return vec3(t,s,r);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec3 hash3( float n )
|
||||||
|
{
|
||||||
|
return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,12578.1459123,19642.3490423));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 shade( in vec4 res )
|
||||||
|
{
|
||||||
|
float ra = length(res.yz);
|
||||||
|
float an = atan(res.y,res.z) + 8.0*iTime;
|
||||||
|
float pa = sin(3.0*an);
|
||||||
|
|
||||||
|
vec3 cola = 0.5 + 0.5*sin( (res.w/64.0)*3.5 + vec3(0.0,1.0,2.0) );
|
||||||
|
|
||||||
|
vec3 col = vec3(0.0);
|
||||||
|
col += cola*0.4*(1.0-smoothstep( 0.90, 1.00, ra) );
|
||||||
|
col += cola*1.0*(1.0-smoothstep( 0.00, 0.03, abs(ra-0.8)))*(0.5+0.5*pa);
|
||||||
|
col += cola*1.0*(1.0-smoothstep( 0.00, 0.20, abs(ra-0.8)))*(0.5+0.5*pa);
|
||||||
|
col += cola*0.5*(1.0-smoothstep( 0.05, 0.10, abs(ra-0.5)))*(0.5+0.5*pa);
|
||||||
|
col += cola*0.7*(1.0-smoothstep( 0.00, 0.30, abs(ra-0.5)))*(0.5+0.5*pa);
|
||||||
|
|
||||||
|
return col*0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 render( in vec3 ro, in vec3 rd )
|
||||||
|
{
|
||||||
|
// raytrace
|
||||||
|
vec3 col = vec3( 0.0 );
|
||||||
|
for( int i=0; i<64; i++ )
|
||||||
|
{
|
||||||
|
// position disk
|
||||||
|
vec3 r = 2.5*(-1.0 + 2.0*hash3( float(i) ));
|
||||||
|
r *= SC;
|
||||||
|
// orientate disk
|
||||||
|
vec3 u = normalize( r.zxy );
|
||||||
|
vec3 v = normalize( cross( u, vec3(0.0,1.0,0.0 ) ) );
|
||||||
|
|
||||||
|
// intersect coord sys
|
||||||
|
vec3 tmp = intersectCoordSys( ro, rd, r, u, v );
|
||||||
|
tmp /= SC;
|
||||||
|
if( dot(tmp.yz,tmp.yz)<1.0 && tmp.x>0.0 )
|
||||||
|
{
|
||||||
|
// shade
|
||||||
|
col += shade( vec4(tmp,float(i)) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 q = fragCoord.xy / iResolution.xy;
|
||||||
|
vec2 p = -1.0 + 2.0 * q;
|
||||||
|
p.x *= iResolution.x/iResolution.y;
|
||||||
|
|
||||||
|
// camera
|
||||||
|
vec3 ro = 2.0*vec3(cos(0.5*iTime*1.1),0.0,sin(0.5*iTime*1.1));
|
||||||
|
vec3 ta = vec3(0.0,0.0,0.0);
|
||||||
|
// camera matrix
|
||||||
|
vec3 ww = normalize( ta - ro );
|
||||||
|
vec3 uu = normalize( cross(ww,vec3(0.0,1.0,0.0) ) );
|
||||||
|
vec3 vv = normalize( cross(uu,ww));
|
||||||
|
// create view ray
|
||||||
|
vec3 rd = normalize( p.x*uu + p.y*vv + 1.0*ww );
|
||||||
|
|
||||||
|
vec3 col = render( ro*SC, rd );
|
||||||
|
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainVR( out vec4 fragColor, in vec2 fragCoord, in vec3 fragRayOri, in vec3 fragRayDir )
|
||||||
|
{
|
||||||
|
vec3 col = render( fragRayOri + vec3(0.0,0.0,0.0), fragRayDir );
|
||||||
|
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
}
|
44
example.glsl
Normal file
44
example.glsl
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011 Mr.doob
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#extension GL_OES_standard_derivatives : enable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
vec2 position = ( gl_FragCoord.xy / resolution.xy ) + mouse / 4.0;
|
||||||
|
|
||||||
|
float color = 0.0;
|
||||||
|
color += sin( position.x * cos( time / 15.0 ) * 80.0 ) + cos( position.y * cos( time / 15.0 ) * 10.0 );
|
||||||
|
color += sin( position.y * sin( time / 10.0 ) * 40.0 ) + cos( position.x * sin( time / 25.0 ) * 40.0 );
|
||||||
|
color += sin( position.x * sin( time / 5.0 ) * 10.0 ) + sin( position.y * sin( time / 35.0 ) * 80.0 );
|
||||||
|
color *= sin( time / 10.0 ) * 0.5;
|
||||||
|
|
||||||
|
gl_FragColor = vec4( vec3( color, color * 0.5, sin( color + time / 3.0 ) * 0.75 ), 1.0 );
|
||||||
|
}
|
275
eye-of-sauron.glsl
Normal file
275
eye-of-sauron.glsl
Normal file
|
@ -0,0 +1,275 @@
|
||||||
|
// Eye of Sauron. By Dave Hoskins. Dec. 2013
|
||||||
|
// Video: http://youtu.be/DCQrDLbhiuQ
|
||||||
|
|
||||||
|
#pragma map iChannel0=builtin:RGBA Noise Medium
|
||||||
|
|
||||||
|
#define TAU 6.28318530718
|
||||||
|
#define MOD2 vec2(.16632,.17369)
|
||||||
|
#define MOD3 vec3(.16532,.17369,.15787)
|
||||||
|
float gTime = 0;
|
||||||
|
float flareUp = 0;
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
vec2 Rotate2axis(vec2 p, float a)
|
||||||
|
{
|
||||||
|
float si = sin(a);
|
||||||
|
float co = cos(a);
|
||||||
|
return mat2(si, co, -co, si) * p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
// Linear step, faster than smoothstep...
|
||||||
|
float LinearStep(float a, float b, float x)
|
||||||
|
{
|
||||||
|
return clamp((x-a)/(b-a), 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
|
||||||
|
float Hash(float p)
|
||||||
|
{
|
||||||
|
vec2 p2 = fract(vec2(p) * MOD2);
|
||||||
|
p2 += dot(p2.yx, p2.xy+19.19);
|
||||||
|
return fract(p2.x * p2.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float EyeNoise( in float x )
|
||||||
|
{
|
||||||
|
float p = floor(x);
|
||||||
|
float f = fract(x);
|
||||||
|
f = clamp(pow(f, 7.0), 0.0,1.0);
|
||||||
|
//f = f*f*(3.0-2.0*f);
|
||||||
|
return mix(Hash(p), Hash(p+1.0), f);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float Bump( in vec3 x )
|
||||||
|
{
|
||||||
|
vec3 p = floor(x);
|
||||||
|
vec3 f = fract(x);
|
||||||
|
//f = f*f*(3.0-2.0*f);
|
||||||
|
|
||||||
|
vec2 uv = (p.xy + vec2(37.0, 17.0) * p.z) + f.xy;
|
||||||
|
vec2 rg = textureLod( iChannel0, (uv+.5)/256., 0.).yx;
|
||||||
|
return mix(rg.x, rg.y, f.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float Noise( in vec3 x )
|
||||||
|
{
|
||||||
|
vec3 p = floor(x);
|
||||||
|
vec3 f = fract(x);
|
||||||
|
f = f*f*(3.0-2.0*f);
|
||||||
|
vec2 uv = (p.xy + vec2(37.0, 17.0) * p.z) + f.xy;
|
||||||
|
vec2 rg = textureLod( iChannel0, (uv+.5)/256., 0.).yx;
|
||||||
|
return mix(rg.x, rg.y, f.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float Pupil(vec3 p, float r)
|
||||||
|
{
|
||||||
|
// It's just a stretched sphere but the mirrored
|
||||||
|
// halves are push together to make a sharper top and bottom.
|
||||||
|
p.xz = abs(p.xz)+.25;
|
||||||
|
return length(p) - r;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float DE_Fire(vec3 p)
|
||||||
|
{
|
||||||
|
p *= vec3(1.0, 1.0, 1.5);
|
||||||
|
float len = length(p);
|
||||||
|
float ax = atan(p.y, p.x)*10.0;
|
||||||
|
float ay = atan(p.y, p.z)*10.0;
|
||||||
|
vec3 shape = vec3(len*.5-gTime*1.2, ax, ay) * 2.0;
|
||||||
|
|
||||||
|
shape += 2.5 * (Noise(p * .25) -
|
||||||
|
Noise(p * 0.5) * .5 +
|
||||||
|
Noise(p * 2.0) * .25);
|
||||||
|
float f = Noise(shape)*6.0;
|
||||||
|
f += (LinearStep(7.30, 8.3+flareUp, len)*LinearStep(12.0+flareUp*2.0, 8.0, len)) * 3.0;
|
||||||
|
p *= vec3(.75, 1.2, 1.0);
|
||||||
|
len = length(p);
|
||||||
|
f = mix(f, 0.0, LinearStep(12.5+flareUp, 16.5+flareUp, len));
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float Sphere(vec3 p, float r)
|
||||||
|
{
|
||||||
|
return length(p) - r;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float DE_Pillars(vec3 p)
|
||||||
|
{
|
||||||
|
// It's just two spheres with added bumpy noise.
|
||||||
|
// Simple, but it'll do fine. :)
|
||||||
|
float d = Sphere((p+vec3(0.0, 1.0, 0.0))*vec3(1.0, 1.0, 18.0), 20.0);
|
||||||
|
d = max(-Sphere((p + vec3(0.0, -3.0, 38.0))* vec3(1.5, 1.1, .95), 44.0), d);
|
||||||
|
d += Noise(p*2.0)*.15 + Noise(p*8.0)*.04;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float DE_Pupil(vec3 p)
|
||||||
|
{
|
||||||
|
float time = gTime * .5+sin(gTime*.3)*.5;
|
||||||
|
float t = EyeNoise(time) * .125 +.125;
|
||||||
|
p.yz = Rotate2axis(p.yz, t * TAU);
|
||||||
|
p *= vec3(1.2-EyeNoise(time+32.5)*.5, .155, 1.0);
|
||||||
|
t = EyeNoise(time-31.0) * .125 +.1875;
|
||||||
|
p.xz = Rotate2axis(p.xz, t*TAU);
|
||||||
|
p += vec3(.0, 0.0, 4.);
|
||||||
|
|
||||||
|
float d = Pupil(p, .78);
|
||||||
|
return d * max(1.0, abs(p.y*2.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
vec3 Normal( in vec3 pos )
|
||||||
|
{
|
||||||
|
vec2 eps = vec2( 0.1, 0.0);
|
||||||
|
vec3 nor = vec3(
|
||||||
|
DE_Pillars(pos+eps.xyy) - DE_Pillars(pos-eps.xyy),
|
||||||
|
DE_Pillars(pos+eps.yxy) - DE_Pillars(pos-eps.yxy),
|
||||||
|
DE_Pillars(pos+eps.yyx) - DE_Pillars(pos-eps.yyx) );
|
||||||
|
return normalize(nor);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
vec4 Raymarch( in vec3 ro, in vec3 rd, in vec2 fragCoord, inout bool hit, out float pupil)
|
||||||
|
{
|
||||||
|
float sum = 0.0;
|
||||||
|
// Starting point plus dither to prevent edge banding...
|
||||||
|
float t = 14.0 + .1 * texture(iChannel0, fragCoord.xy / iChannelResolution[0].xy).y;
|
||||||
|
vec3 pos = vec3(0.0, 0.0, 0.0);
|
||||||
|
float d = 100.0;
|
||||||
|
pupil = 0.0;
|
||||||
|
for(int i=0; i < 197; i++)
|
||||||
|
{
|
||||||
|
if (t > 37.0) break;
|
||||||
|
pos = ro + t*rd;
|
||||||
|
vec3 shape = pos * vec3(1.5, .4, 1.5);
|
||||||
|
|
||||||
|
// Accumulate pixel denisity depending on the distance to the pupil
|
||||||
|
d = DE_Pupil(pos);
|
||||||
|
pupil += LinearStep(0.02 +Noise(pos*4.0+gTime)*.3, 0.0, d) * .17;
|
||||||
|
|
||||||
|
// Add fire around pupil...
|
||||||
|
sum += LinearStep(1.3, 0.0, d) * .014;
|
||||||
|
|
||||||
|
// Search for pillars...
|
||||||
|
d = DE_Pillars(pos);
|
||||||
|
if (d < 0.01)
|
||||||
|
{
|
||||||
|
pos = ro + (t + d) * rd;
|
||||||
|
hit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sum += max(DE_Fire(pos), 0.0) * .00162;
|
||||||
|
t += max(.1, t*.0057);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec4(pos, clamp(sum*sum*sum, 0.0, 1.0 ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
vec3 FlameColour(float f)
|
||||||
|
{
|
||||||
|
f = f*f*(3.0-2.0*f);
|
||||||
|
return min(vec3(f+.8, f*f*1.4+.05, f*f*f*.6) * f, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
float Sky(vec2 p)
|
||||||
|
{
|
||||||
|
float z = gTime*.5 + 47.5;
|
||||||
|
p *= .0025;
|
||||||
|
float dist = length(p) * .7;
|
||||||
|
|
||||||
|
float f = 0.0;
|
||||||
|
float w = .27;
|
||||||
|
for (int i=0; i < 7; i++)
|
||||||
|
{
|
||||||
|
f += Noise(vec3(p, z)) * w;
|
||||||
|
w *= .55;
|
||||||
|
p *= 2.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = smoothstep(.17, 1.0, f)*.55;
|
||||||
|
f = f / dist;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
gTime = iTime + 44.29;
|
||||||
|
flareUp = max(sin(gTime*.75+3.5), 0.0);
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
vec2 p = -1.0 + 2.0 * uv;
|
||||||
|
p.x *= iResolution.x/iResolution.y;
|
||||||
|
|
||||||
|
vec3 origin = vec3(sin(gTime*.34)*5.0, -10.0 - sin(gTime*.415) * 6.0, -20.0+sin(gTime*.15) * 2.0);
|
||||||
|
vec3 target = vec3( 0.0, 0.0, 0.0 );
|
||||||
|
|
||||||
|
// Make camera ray using origin and target positions...
|
||||||
|
vec3 cw = normalize( target-origin);
|
||||||
|
vec3 cp = vec3(0.0, 1.0, 0.0);
|
||||||
|
vec3 cu = normalize( cross(cw, cp) );
|
||||||
|
vec3 cv = ( cross(cu,cw) );
|
||||||
|
vec3 ray = normalize(p.x*cu + p.y*cv + 1.5 * cw );
|
||||||
|
|
||||||
|
bool hit = false;
|
||||||
|
float pupil = 0.0;
|
||||||
|
vec4 ret = Raymarch(origin, ray, fragCoord, hit, pupil);
|
||||||
|
vec3 col = vec3(0.0);
|
||||||
|
|
||||||
|
vec3 light = vec3(0.0, 4.0, -4.0);
|
||||||
|
// Do the lightning flash effect...
|
||||||
|
float t = mod(gTime+3.0, 13.0);
|
||||||
|
float flash = smoothstep(0.4, .0, t);
|
||||||
|
flash += smoothstep(0.2, .0, abs(t-.6)) * 1.5;
|
||||||
|
flash += smoothstep(0.7, .8, t) * smoothstep(1.3, .8, t);
|
||||||
|
flash *= 2.2;
|
||||||
|
|
||||||
|
if (hit)
|
||||||
|
{
|
||||||
|
// Pillars...
|
||||||
|
vec3 nor = Normal(ret.xyz);
|
||||||
|
vec3 ldir = normalize(light - ret.xyz);
|
||||||
|
vec3 ref = reflect(ray, nor);
|
||||||
|
float bri = max(dot(ldir, nor), 0.0) * (1.0+flareUp*2.0) + flash * max(nor.y * 2.0 - nor.z*.5, 0.0);
|
||||||
|
float spe = max(dot(ldir, ref), 0.0);
|
||||||
|
spe = pow(abs(spe), 40.0) * .15;
|
||||||
|
vec3 mat = vec3(.6, .4, .35) * .15;
|
||||||
|
col = mat * bri + spe * vec3(.4, .2, .0);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
// Background...
|
||||||
|
if (ray.y > 0.0)
|
||||||
|
{
|
||||||
|
float d = (250.0 - origin.y) / ray.y;
|
||||||
|
vec2 cloud = vec2((ray * d).xz);
|
||||||
|
float k = Sky(cloud);
|
||||||
|
col = vec3(.7, .7, 1.0) * k;
|
||||||
|
col += (smoothstep(0.045, 0.19, k)) * flash * vec3(.58, .53, .6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
col += FlameColour(ret.w);
|
||||||
|
col = mix (col, vec3(0.0), min(pupil, 1.0));
|
||||||
|
|
||||||
|
// Contrasts...
|
||||||
|
col = sqrt(col);
|
||||||
|
col = min(mix(vec3(length(col)),col, 1.22), 1.0);
|
||||||
|
col += col * .3;
|
||||||
|
|
||||||
|
fragColor = vec4(min(col, 1.0),1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/ldBGWW
|
30
feather-field.glsl
Normal file
30
feather-field.glsl
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
//#define col(i) vec4( vec3(C[i]), 1 )
|
||||||
|
//#define col(i) vec4( .6 + .6 * cos(l-iTime+float(i) +vec3(0,23,21) ), 1 ) // colored
|
||||||
|
#define col(i) vec4( ( .6 + .6 * cos(l-iTime+float(i) +vec3(0,23,21) ) )*C[i], 1 ) // + border
|
||||||
|
|
||||||
|
#define blend(i) O += (1.-O.a) * col(i) * C[i]
|
||||||
|
|
||||||
|
void mainImage( out vec4 O, vec2 U )
|
||||||
|
{
|
||||||
|
vec2 R = iResolution.xy;
|
||||||
|
U = (U+U-R)/R.y;
|
||||||
|
O -= O;
|
||||||
|
|
||||||
|
float a = atan(U.y,U.x), l = length(U);
|
||||||
|
l = 2.*l; a = 30.*a/6.28;
|
||||||
|
|
||||||
|
vec4 s = l-vec4(0,0,.5,.5),
|
||||||
|
A = fract( a-vec4(.25,.75,0,.5) )-.5, L = fract(s-iTime) - .5, // 4 overlapping polar tilings
|
||||||
|
r = sqrt(A*A*abs(s) + L*L), // ellipse (s*s would be const width)
|
||||||
|
C = smoothstep(.1,0., r-.3); // 4 feathers mask
|
||||||
|
|
||||||
|
int c = 2* int( L.z > L.x ); // sort ranks
|
||||||
|
ivec2 T = ivec2( A[1+c] > A[0+c], A[1+2-c] > A[0+2-c] ); // sort rows
|
||||||
|
|
||||||
|
blend( T.x + c ); // blend by sorted order
|
||||||
|
blend( 1-T.x + c );
|
||||||
|
blend( T.y + 2-c );
|
||||||
|
blend( 1-T.y + 2-c );
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/XljBRh
|
33
fluid.glsl
Normal file
33
fluid.glsl
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
|
||||||
|
#define MAX_ITER 3
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec2 v_texCoord = gl_FragCoord.xy / min(resolution.x, resolution.y) / 2.0;
|
||||||
|
|
||||||
|
vec2 p = v_texCoord * 8.0 - vec2(20.0);
|
||||||
|
vec2 i = p;
|
||||||
|
float c = 1.0;
|
||||||
|
float inten = .05;
|
||||||
|
|
||||||
|
for (int n = 0; n < MAX_ITER; n++) {
|
||||||
|
float t = time * (1.0 - (3.0 / float(n+1)));
|
||||||
|
|
||||||
|
i = p + vec2(cos(t - i.x) + sin(t + i.y),
|
||||||
|
sin(t - i.y) + cos(t + i.x));
|
||||||
|
|
||||||
|
c += 1.0/length(vec2(p.x / (sin(i.x+t)/inten),
|
||||||
|
p.y / (cos(i.y+t)/inten)));
|
||||||
|
}
|
||||||
|
|
||||||
|
c /= float(MAX_ITER);
|
||||||
|
c = 1.5 - sqrt(c);
|
||||||
|
|
||||||
|
vec4 texColor = vec4(0.001, 0.1, 0.1, 1.);
|
||||||
|
|
||||||
|
texColor.rgb *= (1.0 / (1.0 - (c + 0.05)));
|
||||||
|
|
||||||
|
gl_FragColor = texColor;
|
||||||
|
}
|
42
galaxy-of-universes.glsl
Normal file
42
galaxy-of-universes.glsl
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// https://www.shadertoy.com/view/MdXSzS
|
||||||
|
// The Big Bang - just a small explosion somewhere in a massive Galaxy of Universes.
|
||||||
|
// Outside of this there's a massive galaxy of 'Galaxy of Universes'... etc etc. :D
|
||||||
|
|
||||||
|
// To fake a perspective it takes advantage of the screen being wider than it is tall.
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = (fragCoord.xy / iResolution.xy) - .5;
|
||||||
|
// uv *= iResolution.xy;
|
||||||
|
float t = iTime * .1 + ((.25 + .05 * sin(iTime * .1))/(length(uv.xy) + .07)) * 2.2;
|
||||||
|
float si = sin(t);
|
||||||
|
float co = cos(t);
|
||||||
|
mat2 ma = mat2(co, si, -si, co);
|
||||||
|
|
||||||
|
float v1, v2, v3;
|
||||||
|
v1 = v2 = v3 = 0.0;
|
||||||
|
|
||||||
|
float s = 0.0;
|
||||||
|
for (int i = 0; i < 90; i++)
|
||||||
|
{
|
||||||
|
vec3 p = s * vec3(uv, 0.0);
|
||||||
|
p.xy *= ma;
|
||||||
|
p += vec3(.22, .3, s - 1.5 - sin(iTime * .13) * .1);
|
||||||
|
for (int i = 0; i < 8; i++) p = abs(p) / dot(p,p) - 0.659;
|
||||||
|
v1 += dot(p,p) * .0015 * (1.8 + sin(length(uv.xy * 13.0) + .5 - iTime * .2));
|
||||||
|
v2 += dot(p,p) * .0013 * (1.5 + sin(length(uv.xy * 14.5) + 1.2 - iTime * .3));
|
||||||
|
v3 += length(p.xy*10.) * .0003;
|
||||||
|
s += .035;
|
||||||
|
}
|
||||||
|
|
||||||
|
float len = length(uv);
|
||||||
|
v1 *= smoothstep(.7, .0, len);
|
||||||
|
v2 *= smoothstep(.5, .0, len);
|
||||||
|
v3 *= smoothstep(.9, .0, len);
|
||||||
|
|
||||||
|
vec3 col = vec3( v3 * (1.5 + sin(iTime * .2) * .4),
|
||||||
|
(v1 + v3) * .3,
|
||||||
|
v2) + smoothstep(0.2, .0, len) * .85 + smoothstep(.0, .6, v3) * .3;
|
||||||
|
|
||||||
|
fragColor=vec4(min(pow(abs(col), vec3(1.2)), 1.0), 1.0);
|
||||||
|
}
|
55
game-of-life.glsl
Normal file
55
game-of-life.glsl
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
// Conway's game of life
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
uniform sampler2D backbuffer;
|
||||||
|
|
||||||
|
vec4 live = vec4(0.5,1.0,0.7,1.);
|
||||||
|
vec4 dead = vec4(0.,0.,0.,1.);
|
||||||
|
vec4 blue = vec4(0.,0.,1.,1.);
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
vec2 position = ( gl_FragCoord.xy / resolution.xy );
|
||||||
|
vec2 pixel = 1./resolution;
|
||||||
|
|
||||||
|
if (length(position-mouse) < 0.01) {
|
||||||
|
float rnd1 = mod(fract(sin(dot(position + time * 0.001, vec2(14.9898,78.233))) * 43758.5453), 1.0);
|
||||||
|
if (rnd1 > 0.5) {
|
||||||
|
gl_FragColor = live;
|
||||||
|
} else {
|
||||||
|
gl_FragColor = blue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
float sum = 0.;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(-1., -1.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(-1., 0.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(-1., 1.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(1., -1.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(1., 0.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(1., 1.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(0., -1.)).g;
|
||||||
|
sum += texture2D(backbuffer, position + pixel * vec2(0., 1.)).g;
|
||||||
|
vec4 me = texture2D(backbuffer, position);
|
||||||
|
|
||||||
|
if (me.g <= 0.1) {
|
||||||
|
if ((sum >= 2.9) && (sum <= 3.1)) {
|
||||||
|
gl_FragColor = live;
|
||||||
|
} else if (me.b > 0.004) {
|
||||||
|
gl_FragColor = vec4(0., 0., max(me.b - 0.004, 0.25), 0.);
|
||||||
|
} else {
|
||||||
|
gl_FragColor = dead;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((sum >= 1.9) && (sum <= 3.1)) {
|
||||||
|
gl_FragColor = live;
|
||||||
|
} else {
|
||||||
|
gl_FragColor = blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
70
going-through-lsd.glsl
Normal file
70
going-through-lsd.glsl
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
// Code by Flopine
|
||||||
|
// Thanks to wsmind and Leon for teaching me :)
|
||||||
|
|
||||||
|
|
||||||
|
#define PI 3.14
|
||||||
|
|
||||||
|
mat2 rot (float angle)
|
||||||
|
{
|
||||||
|
float c = cos(angle);
|
||||||
|
float s = sin(angle);
|
||||||
|
return mat2 (c,-s,s,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 moda (vec2 p, float per)
|
||||||
|
{
|
||||||
|
float angle = atan(p.y,p.x);
|
||||||
|
float l = length(p);
|
||||||
|
angle = mod(angle-per/2., per)-per/2.;
|
||||||
|
return vec2(cos(angle),sin(angle))*l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float cylY (vec3 p, float r)
|
||||||
|
{
|
||||||
|
return length(p.xy)-r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF (vec3 p)
|
||||||
|
{
|
||||||
|
float per = 0.7;
|
||||||
|
|
||||||
|
p.x = abs(p.x);
|
||||||
|
p.xy *= rot(p.z+iTime);
|
||||||
|
p.xy = moda(p.xy, (sin(iTime)+2.)*PI/4.);
|
||||||
|
|
||||||
|
p.yz = mod(p.yz-per/2.,per)-per/2.;
|
||||||
|
p.yz *= rot(p.x+iTime);
|
||||||
|
|
||||||
|
p.x -= .7;
|
||||||
|
|
||||||
|
return cylY(p,0.2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = 2.*(fragCoord.xy / iResolution.xy)-1.;
|
||||||
|
uv.x *= iResolution.x/iResolution.y;
|
||||||
|
|
||||||
|
vec3 pos = vec3(0.001,0.001,iTime*0.8);
|
||||||
|
vec3 dir = normalize(vec3(uv, 1.));
|
||||||
|
|
||||||
|
float shad = 0.;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i=0; i<100; i++)
|
||||||
|
{
|
||||||
|
float d = SDF(pos);
|
||||||
|
if (d<0.01)
|
||||||
|
{
|
||||||
|
shad = float(i)/60.;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else shad = 0.8;
|
||||||
|
pos += d*0.2*dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 hue = vec3(abs(pos.y)*3.,1.,.5);
|
||||||
|
fragColor = vec4(vec3(shad)/hue,1.0);
|
||||||
|
}
|
228
greek-patterns.glsl
Normal file
228
greek-patterns.glsl
Normal file
|
@ -0,0 +1,228 @@
|
||||||
|
#define TWO_PI 6.28318530718
|
||||||
|
#define e 2.71828
|
||||||
|
|
||||||
|
|
||||||
|
float DrawRectangle(in vec2 pos, in vec2 dimensions , in vec2 coord){
|
||||||
|
vec2 d = abs(coord - pos) - dimensions;
|
||||||
|
return float(max(d.x,d.y)<0.);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 PalletToRGB(vec3 col01, vec3 col02, vec3 col03, vec3 col04, vec3 colorToConvert){
|
||||||
|
vec3 toReturn = col04;
|
||||||
|
toReturn = mix(toReturn, col01, colorToConvert.x);
|
||||||
|
toReturn = mix(toReturn, col02, colorToConvert.y);
|
||||||
|
toReturn = mix(toReturn, col03, colorToConvert.z);
|
||||||
|
|
||||||
|
return vec4(toReturn, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PATTERNS FUNCTIONS
|
||||||
|
|
||||||
|
void Patter01(inout vec3 color, in vec3 PatternColor01, in vec3 PatternColor02, in float yPos, in vec2 coord, in float size){
|
||||||
|
|
||||||
|
float lineWidthUnit = size/ (7.0);
|
||||||
|
vec3 colorToAdd = PatternColor01;
|
||||||
|
float lineWidthUnitXStretched = lineWidthUnit / (lineWidthUnit *12.0);
|
||||||
|
|
||||||
|
float distanceToCenter= abs( coord.y - yPos) / (size/2.0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float repeatingXCoordinat01 = fract(coord.x / (lineWidthUnit *6.0) );
|
||||||
|
|
||||||
|
float facingUp = DrawRectangle( vec2(0.25, yPos - lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched, lineWidthUnit*2.5), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(0.25, yPos + lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*3.5, lineWidthUnit*0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
float facingDowm = DrawRectangle( vec2(0.75, yPos + lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched, lineWidthUnit*2.5), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(0.75, yPos - lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*3.5, lineWidthUnit*0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
float borders = DrawRectangle( vec2(0.5, yPos - 3.0 * lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*8.0, lineWidthUnit * 0.5), vec2(repeatingXCoordinat01, coord.y))
|
||||||
|
+ DrawRectangle( vec2(0.5, yPos + 3.0 * lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*8.0, lineWidthUnit * 0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
|
||||||
|
float repeatingPattern = facingUp + facingDowm + borders;
|
||||||
|
repeatingPattern = clamp(repeatingPattern, 0.0, 1.0);
|
||||||
|
|
||||||
|
colorToAdd = mix(PatternColor02, colorToAdd, 1.0 - repeatingPattern);
|
||||||
|
|
||||||
|
|
||||||
|
float upDownEdges = (1.0 - step( lineWidthUnit * 3.5 + yPos, coord.y) )*
|
||||||
|
(step( -lineWidthUnit * 3.5 + yPos, coord.y));
|
||||||
|
|
||||||
|
|
||||||
|
colorToAdd = mix(colorToAdd, colorToAdd * 0.6, pow( distanceToCenter, 1.4) /1.0);
|
||||||
|
|
||||||
|
color = mix(colorToAdd, color, 1.0 - upDownEdges);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Patter02(inout vec3 color, in vec3 PatternColor01, in vec3 PatternColor02, in float yPos, in vec2 coord, in float size){
|
||||||
|
|
||||||
|
float lineWidthUnit = size/ (7.0);
|
||||||
|
vec3 colorToAdd = PatternColor01;
|
||||||
|
float lineWidthUnitXStretched = lineWidthUnit / (lineWidthUnit *12.0);
|
||||||
|
float distanceToCenter= abs( coord.y - yPos) / (size/2.0);
|
||||||
|
|
||||||
|
|
||||||
|
float repeatingXCoordinat01 = fract(coord.x / (lineWidthUnit *6.0) );
|
||||||
|
|
||||||
|
float facingUp = DrawRectangle( vec2(0.25, yPos - lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched, lineWidthUnit*2.5), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(0.4167, yPos + lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*3.0, lineWidthUnit*0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
float facingDowm = DrawRectangle( vec2(0.9167, yPos + lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched, lineWidthUnit*2.5), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(0.75, yPos - lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*3.5, lineWidthUnit*0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
float borders = DrawRectangle( vec2(0.5, yPos - 3.0 * lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*8.0, lineWidthUnit * 0.5), vec2(repeatingXCoordinat01, coord.y))
|
||||||
|
+ DrawRectangle( vec2(0.5, yPos + 3.0 * lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*8.0, lineWidthUnit * 0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
|
||||||
|
float repeatingPattern = facingUp + facingDowm + borders;
|
||||||
|
repeatingPattern = clamp(repeatingPattern, 0.0, 1.0);
|
||||||
|
|
||||||
|
colorToAdd = mix(PatternColor02, colorToAdd, 1.0 - repeatingPattern);
|
||||||
|
|
||||||
|
|
||||||
|
float upDownEdges = (1.0 - step( lineWidthUnit * 3.5 + yPos, coord.y) )*
|
||||||
|
(step( -lineWidthUnit * 3.5 + yPos, coord.y));
|
||||||
|
colorToAdd = mix(colorToAdd, colorToAdd * 0.7, pow( distanceToCenter, 1.4) /1.0);
|
||||||
|
|
||||||
|
color = mix(colorToAdd, color, 1.0 - upDownEdges);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Patter03(inout vec3 color, in vec3 PatternColor01, in vec3 PatternColor02, in float yPos, in vec2 coord, in float size){
|
||||||
|
float lineWidthUnit = size/ (9.0);
|
||||||
|
vec3 colorToAdd = PatternColor01;
|
||||||
|
float lineWidthUnitXStretched = lineWidthUnit / (lineWidthUnit *8.0);
|
||||||
|
float xUnit = 1.0/8.0;
|
||||||
|
float distanceToCenter= abs( coord.y - yPos) / (size/2.0);
|
||||||
|
|
||||||
|
|
||||||
|
float repeatingXCoordinat01 = fract(coord.x / (lineWidthUnit *8.0) );
|
||||||
|
|
||||||
|
float facingUp = DrawRectangle( vec2(xUnit * 1.5, yPos - lineWidthUnit * 0.5),
|
||||||
|
vec2(lineWidthUnitXStretched *0.5, lineWidthUnit*3.0), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(3.5*xUnit, yPos + lineWidthUnit * 2.0),
|
||||||
|
vec2(lineWidthUnitXStretched*2.5, lineWidthUnit*0.5), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(3.5*xUnit, yPos - lineWidthUnit ),
|
||||||
|
vec2(lineWidthUnitXStretched*0.5, lineWidthUnit*1.5), vec2(repeatingXCoordinat01, coord.y)) ;
|
||||||
|
|
||||||
|
float facingDowm = DrawRectangle( vec2(1.0 - xUnit*0.5, yPos + lineWidthUnit * 0.5),
|
||||||
|
vec2(lineWidthUnitXStretched * 0.5, lineWidthUnit * 3.0), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(5.5 * xUnit, yPos - lineWidthUnit * 2.0),
|
||||||
|
vec2(lineWidthUnitXStretched*2.5, lineWidthUnit*0.5), vec2(repeatingXCoordinat01, coord.y)) +
|
||||||
|
DrawRectangle( vec2(5.5*xUnit, yPos + lineWidthUnit ),
|
||||||
|
vec2(lineWidthUnitXStretched*0.5, lineWidthUnit*1.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
float borders = DrawRectangle( vec2(0.5, yPos - 4.0 * lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*8.0, lineWidthUnit * 0.5), vec2(repeatingXCoordinat01, coord.y))
|
||||||
|
+ DrawRectangle( vec2(0.5, yPos + 4.0 * lineWidthUnit),
|
||||||
|
vec2(lineWidthUnitXStretched*8.0, lineWidthUnit * 0.5), vec2(repeatingXCoordinat01, coord.y));
|
||||||
|
|
||||||
|
|
||||||
|
float repeatingPattern = facingUp + facingDowm + borders;
|
||||||
|
repeatingPattern = clamp(repeatingPattern, 0.0, 1.0);
|
||||||
|
|
||||||
|
colorToAdd = mix(PatternColor02, colorToAdd, 1.0 - repeatingPattern);
|
||||||
|
|
||||||
|
|
||||||
|
float upDownEdges = (1.0 - step( lineWidthUnit * 4.5 + yPos, coord.y) )*
|
||||||
|
(step( -lineWidthUnit * 4.5 + yPos, coord.y));
|
||||||
|
colorToAdd = mix(colorToAdd, colorToAdd * 0.7, pow( distanceToCenter, 1.4) /1.0);
|
||||||
|
color = mix(colorToAdd, color, 1.0 - upDownEdges);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Patter04(inout vec3 color, in vec3 PatternColor01, in vec3 PatternColor02, in float yPos, in vec2 coord, in float size){
|
||||||
|
float lineWidthUnit = size/ (8.0);
|
||||||
|
vec3 colorToAdd = PatternColor01;
|
||||||
|
float lineWidthUnitXStretched = lineWidthUnit / (lineWidthUnit *8.0);
|
||||||
|
float xUnit = 1.0/8.0;
|
||||||
|
float distanceToCenter= abs( coord.y - yPos) / (size/2.0);
|
||||||
|
vec2 spiralCenter = vec2( 0.66, yPos - lineWidthUnit * 0.5 );
|
||||||
|
|
||||||
|
vec2 spiralCenterPrevieus = vec2( -0.44, yPos - lineWidthUnit * 0.5 );
|
||||||
|
float repeatingXCoordinat01 = fract(coord.x / (lineWidthUnit *8.0) );
|
||||||
|
|
||||||
|
// Map to 0 to 1
|
||||||
|
|
||||||
|
vec2 pixelToCenter = vec2(repeatingXCoordinat01, coord.y) - spiralCenter;
|
||||||
|
vec2 pixelToCenterTwo = vec2(repeatingXCoordinat01, coord.y) - spiralCenterPrevieus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float angle = atan(pixelToCenter.y , (pixelToCenter.x/8.0)) ;
|
||||||
|
float angle2 = atan(- pixelToCenter.y , -(pixelToCenter.x/ 8.0)) ;
|
||||||
|
float angle3 = atan(- pixelToCenterTwo.y , -(pixelToCenterTwo.x/ 8.0)) ;
|
||||||
|
|
||||||
|
float firstSpiralAlpha = (((angle ) /TWO_PI)+0.5);
|
||||||
|
float secondSpiralAlpha = (((-angle ) /TWO_PI)+0.5);
|
||||||
|
float thirdSpiralAngel = (((angle2 ) /TWO_PI)+0.5);
|
||||||
|
float forthSpiralAngel = (((-angle3 ) /TWO_PI)+0.5);
|
||||||
|
|
||||||
|
float distanceToThePixelFromCenterSpiral01 = length(vec2(pixelToCenter.x*0.6, pixelToCenter.y * 4.0));
|
||||||
|
|
||||||
|
float a = 0.28 * size;
|
||||||
|
float b = 38.2 * size;
|
||||||
|
|
||||||
|
float spiralOne= (step( (a * 1.5 * pow(e, firstSpiralAlpha* atan(b ) )) , (distanceToThePixelFromCenterSpiral01)) );
|
||||||
|
float spiralTwo = step( (a *1.0* pow(e, secondSpiralAlpha* atan(b /1.0) )) , (distanceToThePixelFromCenterSpiral01));
|
||||||
|
float spiralThree = step( (a *0.135* pow(e, thirdSpiralAngel* 3.0 *atan(b /1.8) )) , (distanceToThePixelFromCenterSpiral01));
|
||||||
|
float cutOutEdge = (1.0 - step(0.078, repeatingXCoordinat01)) * (1.0 - step( (repeatingXCoordinat01 * 0.55 ) -0.047+ yPos, coord.y));
|
||||||
|
|
||||||
|
float blendingFactor = (step(0.078, repeatingXCoordinat01) * (((1.0 -spiralOne) * spiralTwo) +( spiralThree * step(0.5, thirdSpiralAngel)))) + cutOutEdge;
|
||||||
|
|
||||||
|
|
||||||
|
colorToAdd = mix(PatternColor02, PatternColor01,clamp( 1.0 - blendingFactor, 0.0, 1.0));
|
||||||
|
|
||||||
|
|
||||||
|
float upDownEdges = (1.0 - step( lineWidthUnit * 4.5 + yPos, coord.y) )*
|
||||||
|
(step( -lineWidthUnit * 4.5 + yPos, coord.y));
|
||||||
|
colorToAdd = mix(colorToAdd, colorToAdd * 0.7, pow( distanceToCenter, 1.4) /1.0);
|
||||||
|
color = mix(colorToAdd, color, 1.0 - upDownEdges);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// Settomg up the UV coordinates
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.y;
|
||||||
|
|
||||||
|
vec3 backGround = vec3(0.0,0.0,0.1);
|
||||||
|
vec3 color01 = vec3(0.758 + sin(iTime * 0.8) / 4.0, + cos((iTime + TWO_PI /2.0) * 0.8), 0.031);
|
||||||
|
vec3 color02 = vec3(1.0, 0.6 + cos(iTime * 0.8), 0.1);
|
||||||
|
vec3 color03 = vec3(1.0, 0.9, 0.9);
|
||||||
|
|
||||||
|
float highlightRunning = 1.0 - smoothstep(0.01, 0.5, abs(
|
||||||
|
(fract(iTime / 4.0 ) * iResolution.x * 2.0/ iResolution.y) -0.5 - uv.x ));
|
||||||
|
vec3 colorToReturn = vec3(0.4, 0.8, 0.4);
|
||||||
|
|
||||||
|
float distanceToCenter = distance(uv, vec2(((iResolution.x/ iResolution.y))/2.0 ,0.5));
|
||||||
|
|
||||||
|
|
||||||
|
Patter01(colorToReturn, vec3(0.99, 0.0141, 0.2), vec3(0.1, 0.9, uv.x/5.0),0.9, vec2(uv.x + iTime * 0.2, uv.y), 0.2);
|
||||||
|
Patter02(colorToReturn, vec3(abs(2.0 * fract(iTime / 5.0) - 1.0 ) , abs(2.0 * fract(iTime / 5.0) - 1.0 )*1.2, 0.0312 ),vec3(0.7- abs(2.0 * fract(iTime / 5.0) - 1.0 )*0.5, 0.16, uv.x/5.0), 0.68,vec2(uv.x - iTime * 0.2, uv.y), 0.2);
|
||||||
|
Patter03(colorToReturn, vec3(0.91325 , 0.3213 + highlightRunning, 0.1 ), vec3( highlightRunning, 0.321, uv.x/7.0), 0.40, vec2(uv.x + iTime * 0.3, uv.y), 0.31);
|
||||||
|
|
||||||
|
Patter04(colorToReturn, vec3(0.11325 , 0.9213 + highlightRunning, 0.1 ), vec3(0.1, 0.121, uv.x/7.0), 0.1, vec2(uv.x - iTime * 0.1, uv.y), 0.2);
|
||||||
|
|
||||||
|
|
||||||
|
fragColor = PalletToRGB(color01, color02, color03, backGround, colorToReturn);
|
||||||
|
|
||||||
|
fragColor *= (1.0 -smoothstep(0.3, 1.2, distanceToCenter));
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/4l2fWR
|
80
hexagons.glsl
Normal file
80
hexagons.glsl
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
// Created by inigo quilez - iq/2014
|
||||||
|
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||||
|
|
||||||
|
#pragma map iChannel0=builtin:RGBA Noise Medium
|
||||||
|
|
||||||
|
// { 2d cell id, distance to border, distnace to center )
|
||||||
|
vec4 hexagon( vec2 p )
|
||||||
|
{
|
||||||
|
vec2 q = vec2( p.x*2.0*0.5773503, p.y + p.x*0.5773503 );
|
||||||
|
|
||||||
|
vec2 pi = floor(q);
|
||||||
|
vec2 pf = fract(q);
|
||||||
|
|
||||||
|
float v = mod(pi.x + pi.y, 3.0);
|
||||||
|
|
||||||
|
float ca = step(1.0,v);
|
||||||
|
float cb = step(2.0,v);
|
||||||
|
vec2 ma = step(pf.xy,pf.yx);
|
||||||
|
|
||||||
|
// distance to borders
|
||||||
|
float e = dot( ma, 1.0-pf.yx + ca*(pf.x+pf.y-1.0) + cb*(pf.yx-2.0*pf.xy) );
|
||||||
|
|
||||||
|
// distance to center
|
||||||
|
p = vec2( q.x + floor(0.5+p.y/1.5), 4.0*p.y/3.0 )*0.5 + 0.5;
|
||||||
|
float f = length( (fract(p) - 0.5)*vec2(1.0,0.85) );
|
||||||
|
|
||||||
|
return vec4( pi + ca - cb*ma, e, f );
|
||||||
|
}
|
||||||
|
|
||||||
|
float hash1( vec2 p ) { float n = dot(p,vec2(127.1,311.7) ); return fract(sin(n)*43758.5453); }
|
||||||
|
|
||||||
|
float noise( in vec3 x )
|
||||||
|
{
|
||||||
|
vec3 p = floor(x);
|
||||||
|
vec3 f = fract(x);
|
||||||
|
f = f*f*(3.0-2.0*f);
|
||||||
|
vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;
|
||||||
|
vec2 rg = textureLod( iChannel0, (uv+0.5)/256.0, 0.0 ).yx;
|
||||||
|
return mix( rg.x, rg.y, f.z );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy/iResolution.xy;
|
||||||
|
vec2 pos = (-iResolution.xy + 2.0*fragCoord.xy)/iResolution.y;
|
||||||
|
|
||||||
|
// distort
|
||||||
|
pos *= 1.0 + 0.3*length(pos);
|
||||||
|
|
||||||
|
// gray
|
||||||
|
vec4 h = hexagon(8.0*pos + 0.5*iTime);
|
||||||
|
float n = noise( vec3(0.3*h.xy+iTime*0.1,iTime) );
|
||||||
|
vec3 col = 0.15 + 0.15*hash1(h.xy+1.2)*vec3(1.0);
|
||||||
|
col *= smoothstep( 0.10, 0.11, h.z );
|
||||||
|
col *= smoothstep( 0.10, 0.11, h.w );
|
||||||
|
col *= 1.0 + 0.15*sin(40.0*h.z);
|
||||||
|
col *= 0.75 + 0.5*h.z*n;
|
||||||
|
|
||||||
|
|
||||||
|
// red
|
||||||
|
h = hexagon(6.0*pos + 0.6*iTime);
|
||||||
|
n = noise( vec3(0.3*h.xy+iTime*0.1,iTime) );
|
||||||
|
vec3 colb = 0.9 + 0.8*sin( hash1(h.xy)*1.5 + 2.0 + vec3(0.0,1.0,1.0) );
|
||||||
|
colb *= smoothstep( 0.10, 0.11, h.z );
|
||||||
|
colb *= 1.0 + 0.15*sin(40.0*h.z);
|
||||||
|
colb *= 0.75 + 0.5*h.z*n;
|
||||||
|
|
||||||
|
h = hexagon(6.0*(pos+0.1*vec2(-1.3,1.0)) + 0.6*iTime);
|
||||||
|
col *= 1.0-0.8*smoothstep(0.45,0.451,noise( vec3(0.3*h.xy+iTime*0.1,iTime) ));
|
||||||
|
|
||||||
|
col = mix( col, colb, smoothstep(0.45,0.451,n) );
|
||||||
|
|
||||||
|
|
||||||
|
col *= pow( 16.0*uv.x*(1.0-uv.x)*uv.y*(1.0-uv.y), 0.1 );
|
||||||
|
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/Xd2GR3
|
64
interstellar.glsl
Normal file
64
interstellar.glsl
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#pragma map iChannel0=builtin:RGBA Noise Medium
|
||||||
|
|
||||||
|
const float tau = 6.28318530717958647692;
|
||||||
|
|
||||||
|
// Gamma correction
|
||||||
|
#define GAMMA (2.2)
|
||||||
|
|
||||||
|
vec3 ToLinear( in vec3 col )
|
||||||
|
{
|
||||||
|
// simulate a monitor, converting colour values into light values
|
||||||
|
return pow( col, vec3(GAMMA) );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 ToGamma( in vec3 col )
|
||||||
|
{
|
||||||
|
// convert back into colour values, so the correct light will come out of the monitor
|
||||||
|
return pow( col, vec3(1.0/GAMMA) );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 Noise( in ivec2 x )
|
||||||
|
{
|
||||||
|
return texture( iChannel0, (vec2(x)+0.5)/256.0, -100.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 Rand( in int x )
|
||||||
|
{
|
||||||
|
vec2 uv;
|
||||||
|
uv.x = (float(x)+0.5)/256.0;
|
||||||
|
uv.y = (floor(uv.x)+0.5)/256.0;
|
||||||
|
return texture( iChannel0, uv, -100.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec3 ray;
|
||||||
|
ray.xy = 2.0*(fragCoord.xy-iResolution.xy*.5)/iResolution.x;
|
||||||
|
ray.z = 1.0;
|
||||||
|
|
||||||
|
float offset = iTime*.5;
|
||||||
|
float speed2 = (cos(offset)+1.0)*2.0;
|
||||||
|
float speed = speed2+.1;
|
||||||
|
offset += sin(offset)*.96;
|
||||||
|
offset *= 2.0;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 col = vec3(0);
|
||||||
|
|
||||||
|
vec3 stp = ray/max(abs(ray.x),abs(ray.y));
|
||||||
|
|
||||||
|
vec3 pos = 2.0*stp+.5;
|
||||||
|
for ( int i=0; i < 20; i++ )
|
||||||
|
{
|
||||||
|
float z = Noise(ivec2(pos.xy)).x;
|
||||||
|
z = fract(z-offset);
|
||||||
|
float d = 50.0*z-pos.z;
|
||||||
|
float w = pow(max(0.0,1.0-8.0*length(fract(pos.xy)-.5)),2.0);
|
||||||
|
vec3 c = max(vec3(0),vec3(1.0-abs(d+speed2*.5)/speed,1.0-abs(d)/speed,1.0-abs(d-speed2*.5)/speed));
|
||||||
|
col += 1.5*(1.0-z)*c*w;
|
||||||
|
pos += stp;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragColor = vec4(ToGamma(col),1.0);
|
||||||
|
}
|
104
mandala-elevator.glsl
Normal file
104
mandala-elevator.glsl
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
// Code by Flopine
|
||||||
|
// Thanks to wsmind and leon for teaching me!
|
||||||
|
|
||||||
|
#define PI 3.14
|
||||||
|
|
||||||
|
mat2 rot(float angle)
|
||||||
|
{
|
||||||
|
float c = cos(angle);
|
||||||
|
float s = sin(angle);
|
||||||
|
return mat2(c,s,-s,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 moda (vec2 p, float per)
|
||||||
|
{
|
||||||
|
float angle = atan(p.y,p.x);
|
||||||
|
float l = length(p);
|
||||||
|
angle = mod(angle-per/2.,per)-per/2.;
|
||||||
|
return vec2 (cos(angle),sin(angle))*l;
|
||||||
|
}
|
||||||
|
|
||||||
|
float cylY (vec3 p, float r)
|
||||||
|
{
|
||||||
|
return length(p.xz)-r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float cylZ (vec3 p, float r)
|
||||||
|
{
|
||||||
|
return length(p.xy)-r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float base (vec3 p)
|
||||||
|
{
|
||||||
|
p.xy *= rot(abs(p.z)-iTime);
|
||||||
|
p.xy = moda(p.xy,2.*PI/3.);
|
||||||
|
p.x -= 0.4;
|
||||||
|
|
||||||
|
return cylZ(p,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float prim(vec3 p)
|
||||||
|
{
|
||||||
|
p.xz = moda(p.xz, 2.*PI/7.);
|
||||||
|
p.x -= 4.;
|
||||||
|
return base(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
float elevator (vec3 p)
|
||||||
|
{
|
||||||
|
float per = 8.;
|
||||||
|
p.yz = mod (p.yz-per/2.,per)-per/2.;
|
||||||
|
float rep1 = prim(p);
|
||||||
|
|
||||||
|
float per2 = 15.;
|
||||||
|
p.yz *= rot(PI/2.);
|
||||||
|
p.x = mod (p.x-per2/2.,per2)-per2/2.;
|
||||||
|
float rep2 = prim(p);
|
||||||
|
|
||||||
|
return min(rep1,rep2);
|
||||||
|
}
|
||||||
|
|
||||||
|
float background (vec3 p)
|
||||||
|
{
|
||||||
|
float per = 5.;
|
||||||
|
p.yz *= rot(PI/2.);
|
||||||
|
p.x = mod (p.x-per/2.,per)-per/2.;
|
||||||
|
return prim(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF(vec3 p)
|
||||||
|
{
|
||||||
|
return min(elevator(p), background(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = 2.*(fragCoord.xy / iResolution.xy)-1.;
|
||||||
|
uv.x *= iResolution.x/iResolution.y;
|
||||||
|
|
||||||
|
vec3 p = vec3 (-.001,iTime,-3.);
|
||||||
|
vec3 dir = normalize(vec3(uv,1.));
|
||||||
|
|
||||||
|
float shad = 0.;
|
||||||
|
vec3 color = vec3 (0.);
|
||||||
|
|
||||||
|
for (int i=0; i<100;i++)
|
||||||
|
{
|
||||||
|
float d = elevator(p);
|
||||||
|
if (d<0.01)
|
||||||
|
{
|
||||||
|
shad = float(i)/80.;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else shad = .0;
|
||||||
|
p+=d*0.2*dir;
|
||||||
|
}
|
||||||
|
color = vec3(shad)*vec3(0.8,p.z,abs(p.x*0.5));
|
||||||
|
fragColor = vec4(color,1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/XtSBRK
|
512
mario-bros.glsl
Normal file
512
mario-bros.glsl
Normal file
|
@ -0,0 +1,512 @@
|
||||||
|
// Super Mario Bros. by HLorenzi
|
||||||
|
|
||||||
|
// If it does not run at 60 FPS,
|
||||||
|
// try pausing/turning off the music!
|
||||||
|
|
||||||
|
// Uncomment for totally random level!
|
||||||
|
// Just to show off Mario's dynamic movements :P
|
||||||
|
//#define TOTALLY_RANDOM_LEVEL 1
|
||||||
|
|
||||||
|
|
||||||
|
// Positions to start and end Mario simulation (relative to screen position)
|
||||||
|
// You can try changing these! (the difference between the two should be a multiple of 4)
|
||||||
|
// Put startX too close to endX, and Mario'll experience jittering!
|
||||||
|
#define startX 0.0
|
||||||
|
#define endX 80.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define RGB(r,g,b) vec4(float(r)/255.0,float(g)/255.0,float(b)/255.0,1.0)
|
||||||
|
|
||||||
|
#define SPRROW(x,a,b,c,d,e,f,g,h, i,j,k,l,m,n,o,p) (x <= 7 ? SPRROW_H(a,b,c,d,e,f,g,h) : SPRROW_H(i,j,k,l,m,n,o,p))
|
||||||
|
#define SPRROW_H(a,b,c,d,e,f,g,h) (a+4.0*(b+4.0*(c+4.0*(d+4.0*(e+4.0*(f+4.0*(g+4.0*(h))))))))
|
||||||
|
#define SECROW(x,a,b,c,d,e,f,g,h) (x <= 3 ? SECROW_H(a,b,c,d) : SECROW_H(e,f,g,h))
|
||||||
|
#define SECROW_H(a,b,c,d) (a+8.0*(b+8.0*(c+8.0*(d))))
|
||||||
|
#define SELECT(x,i) mod(floor(i/pow(4.0,float(x))),4.0)
|
||||||
|
#define SELECTSEC(x,i) mod(floor(i/pow(8.0,float(x))),8.0)
|
||||||
|
|
||||||
|
float rand(vec2 co)
|
||||||
|
{
|
||||||
|
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sprGround(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,1.,0.,0.,0.,0.,0.,0.,0., 0.,2.,1.,0.,0.,0.,0.,1.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,2.,1.,1.,1.,2.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,1.,2.,2.,2.,2.,1.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,0.,0.,0.,0.,2.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,1.,1.,1.,1.,2.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 6) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,2.,0.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 5) col = SPRROW(x,2.,2.,1.,1.,1.,1.,1.,1., 2.,0.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 4) col = SPRROW(x,0.,0.,2.,2.,1.,1.,1.,1., 2.,0.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,1.,0.,0.,2.,2.,2.,2., 0.,1.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,1.,1.,1.,0.,0.,0.,2., 0.,1.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,2., 0.,1.,1.,1.,1.,1.,2.,2.);
|
||||||
|
if (y == 0) col = SPRROW(x,1.,2.,2.,2.,2.,2.,2.,1., 0.,2.,2.,2.,2.,2.,2.,1.);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(247,214,181);
|
||||||
|
if (col == 1.0) return RGB(231,90,16);
|
||||||
|
return RGB(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sprQuestionBlock(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,3.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,3.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,1.,2.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,2.,1.,2.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,1.,1.,1.,1.,0.,0.,0., 0.,0.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,1.,1.,1.,0.,0.,2.,2., 2.,0.,0.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,1.,1.,1.,0.,0.,2.,1., 1.,0.,0.,2.,1.,1.,1.,2.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,1.,1.,1.,0.,0.,2.,1., 1.,0.,0.,2.,1.,1.,1.,2.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,1.,1.,1.,1.,2.,2.,1., 0.,0.,0.,2.,1.,1.,1.,2.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,0., 0.,2.,2.,2.,1.,1.,1.,2.);
|
||||||
|
if (y == 6) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,0., 0.,2.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 5) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 2.,2.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 4) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,0., 0.,0.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,0., 0.,2.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,1.,2.,1.,1.,1.,1.,1., 2.,2.,1.,1.,1.,2.,1.,2.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,2.);
|
||||||
|
if (y == 0) col = SPRROW(x,2.,2.,2.,2.,2.,2.,2.,2., 2.,2.,2.,2.,2.,2.,2.,2.);
|
||||||
|
|
||||||
|
if (y < 0 || y > 15) return RGB(107,140,255);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(231,90,16);
|
||||||
|
if (col == 1.0) return RGB(255,165,66);
|
||||||
|
if (col == 2.0) return RGB(0,0,0);
|
||||||
|
return RGB(107,140,255);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sprUsedBlock(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,3.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,3.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,1.,0.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,0.,1.,0.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 6) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 5) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 4) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,1.,0.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,0.,1.,0.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,1.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,1.,0.);
|
||||||
|
if (y == 0) col = SPRROW(x,3.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,3.);
|
||||||
|
|
||||||
|
if (y < 0 || y > 15) return RGB(107,140,255);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(0,0,0);
|
||||||
|
if (col == 1.0) return RGB(231,90,16);
|
||||||
|
return RGB(107,140,255);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sprMarioJump(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,0.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,2.,2.,2.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,0.,0.,0.,0.,0.,1.,1., 1.,1.,1.,0.,0.,2.,2.,2.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,0.,0.,0.,0.,1.,1.,1., 1.,1.,1.,1.,1.,1.,2.,2.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,0.,0.,0.,0.,3.,3.,3., 2.,2.,3.,2.,0.,3.,3.,3.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,0.,0.,0.,3.,2.,3.,2., 2.,2.,3.,2.,2.,3.,3.,3.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,0.,0.,0.,3.,2.,3.,3., 2.,2.,2.,3.,2.,2.,2.,3.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,0.,0.,0.,3.,3.,2.,2., 2.,2.,3.,3.,3.,3.,3.,0.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,0.,0.,0.,0.,0.,2.,2., 2.,2.,2.,2.,2.,3.,0.,0.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,0.,0.,3.,3.,3.,3.,3.,1., 3.,3.,3.,1.,3.,0.,0.,0.);
|
||||||
|
if (y == 6) col = SPRROW(x,0.,3.,3.,3.,3.,3.,3.,3., 1.,3.,3.,3.,1.,0.,0.,3.);
|
||||||
|
if (y == 5) col = SPRROW(x,2.,2.,3.,3.,3.,3.,3.,3., 1.,1.,1.,1.,1.,0.,0.,3.);
|
||||||
|
if (y == 4) col = SPRROW(x,2.,2.,2.,0.,1.,1.,3.,1., 1.,2.,1.,1.,2.,1.,3.,3.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,2.,0.,3.,1.,1.,1.,1., 1.,1.,1.,1.,1.,1.,3.,3.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,0.,3.,3.,3.,1.,1.,1., 1.,1.,1.,1.,1.,1.,3.,3.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,3.,3.,3.,1.,1.,1.,1., 1.,1.,1.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 0) col = SPRROW(x,0.,3.,0.,0.,1.,1.,1.,1., 0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(0,0,0);
|
||||||
|
if (col == 1.0) return RGB(177,52,37);
|
||||||
|
if (col == 2.0) return RGB(227,157,37);
|
||||||
|
if (col == 3.0) return RGB(106,107,4);
|
||||||
|
return RGB(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sprMarioWalk3(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,0.,0.,0.,0.,0.,1.,1.,1., 1.,1.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,0.,0.,0.,1.,1.,1.,1., 1.,1.,1.,1.,1.,0.,0.,0.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,0.,0.,0.,3.,3.,3.,2., 2.,3.,2.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,0.,0.,3.,2.,3.,2.,2., 2.,3.,2.,2.,2.,0.,0.,0.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,0.,0.,3.,2.,3.,3.,2., 2.,2.,3.,2.,2.,2.,0.,0.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,0.,0.,3.,3.,2.,2.,2., 2.,3.,3.,3.,3.,0.,0.,0.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,0.,0.,0.,0.,2.,2.,2., 2.,2.,2.,2.,0.,0.,0.,0.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,0.,3.,3.,3.,3.,1.,1., 3.,3.,0.,0.,0.,0.,0.,0.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,2.,2.,3.,3.,3.,3.,1.,1., 1.,3.,3.,3.,2.,2.,2.,0.);
|
||||||
|
if (y == 6) col = SPRROW(x,2.,2.,2.,0.,3.,3.,1.,2., 1.,1.,1.,3.,3.,2.,2.,0.);
|
||||||
|
if (y == 5) col = SPRROW(x,2.,2.,0.,0.,1.,1.,1.,1., 1.,1.,1.,0.,0.,3.,0.,0.);
|
||||||
|
if (y == 4) col = SPRROW(x,0.,0.,0.,1.,1.,1.,1.,1., 1.,1.,1.,1.,3.,3.,0.,0.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,0.,1.,1.,1.,1.,1.,1., 1.,1.,1.,1.,3.,3.,0.,0.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,3.,3.,1.,1.,1.,0.,0., 0.,1.,1.,1.,3.,3.,0.,0.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,3.,3.,3.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 0) col = SPRROW(x,0.,0.,3.,3.,3.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(0,0,0);
|
||||||
|
if (col == 1.0) return RGB(177,52,37);
|
||||||
|
if (col == 2.0) return RGB(227,157,37);
|
||||||
|
if (col == 3.0) return RGB(106,107,4);
|
||||||
|
return RGB(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec4 sprMarioWalk2(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,0.,0.,0.,0.,0.,1.,1.,1., 1.,1.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,0.,0.,0.,1.,1.,1.,1., 1.,1.,1.,1.,1.,0.,0.,0.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,0.,0.,0.,3.,3.,3.,2., 2.,3.,2.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,0.,0.,3.,2.,3.,2.,2., 2.,3.,2.,2.,2.,0.,0.,0.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,0.,0.,3.,2.,3.,3.,2., 2.,2.,3.,2.,2.,2.,0.,0.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,0.,0.,3.,3.,2.,2.,2., 2.,3.,3.,3.,3.,0.,0.,0.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,0.,0.,0.,0.,2.,2.,2., 2.,2.,2.,2.,0.,0.,0.,0.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,0.,0.,0.,3.,3.,1.,3., 3.,3.,0.,0.,0.,0.,0.,0.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,0.,0.,0.,3.,3.,3.,3.,1., 1.,3.,3.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 6) col = SPRROW(x,0.,0.,0.,3.,3.,3.,1.,1., 2.,1.,1.,2.,0.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SPRROW(x,0.,0.,0.,3.,3.,3.,3.,1., 1.,1.,1.,1.,0.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SPRROW(x,0.,0.,0.,1.,3.,3.,2.,2., 2.,1.,1.,1.,0.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,0.,0.,0.,1.,3.,2.,2., 1.,1.,1.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,0.,0.,0.,0.,1.,1.,1., 3.,3.,3.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,0.,0.,0.,0.,3.,3.,3., 3.,3.,3.,3.,0.,0.,0.,0.);
|
||||||
|
if (y == 0) col = SPRROW(x,0.,0.,0.,0.,0.,3.,3.,3., 3.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(0,0,0);
|
||||||
|
if (col == 1.0) return RGB(177,52,37);
|
||||||
|
if (col == 2.0) return RGB(227,157,37);
|
||||||
|
if (col == 3.0) return RGB(106,107,4);
|
||||||
|
return RGB(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec4 sprMarioWalk1(int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (y == 15) col = SPRROW(x,0.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 14) col = SPRROW(x,0.,0.,0.,0.,0.,0.,1.,1., 1.,1.,1.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 13) col = SPRROW(x,0.,0.,0.,0.,0.,1.,1.,1., 1.,1.,1.,1.,1.,1.,0.,0.);
|
||||||
|
if (y == 12) col = SPRROW(x,0.,0.,0.,0.,0.,3.,3.,3., 2.,2.,3.,2.,0.,0.,0.,0.);
|
||||||
|
if (y == 11) col = SPRROW(x,0.,0.,0.,0.,3.,2.,3.,2., 2.,2.,3.,2.,2.,2.,0.,0.);
|
||||||
|
if (y == 10) col = SPRROW(x,0.,0.,0.,0.,3.,2.,3.,3., 2.,2.,2.,3.,2.,2.,2.,0.);
|
||||||
|
if (y == 9) col = SPRROW(x,0.,0.,0.,0.,3.,3.,2.,2., 2.,2.,3.,3.,3.,3.,0.,0.);
|
||||||
|
if (y == 8) col = SPRROW(x,0.,0.,0.,0.,0.,0.,2.,2., 2.,2.,2.,2.,2.,0.,0.,0.);
|
||||||
|
|
||||||
|
if (y == 7) col = SPRROW(x,0.,0.,0.,0.,0.,3.,3.,3., 3.,1.,3.,0.,2.,0.,0.,0.);
|
||||||
|
if (y == 6) col = SPRROW(x,0.,0.,0.,0.,2.,3.,3.,3., 3.,3.,3.,2.,2.,2.,0.,0.);
|
||||||
|
if (y == 5) col = SPRROW(x,0.,0.,0.,2.,2.,1.,3.,3., 3.,3.,3.,2.,2.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SPRROW(x,0.,0.,0.,3.,3.,1.,1.,1., 1.,1.,1.,1.,0.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SPRROW(x,0.,0.,0.,3.,1.,1.,1.,1., 1.,1.,1.,1.,0.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SPRROW(x,0.,0.,3.,3.,1.,1.,1.,0., 1.,1.,1.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 1) col = SPRROW(x,0.,0.,3.,0.,0.,0.,0.,3., 3.,3.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 0) col = SPRROW(x,0.,0.,0.,0.,0.,0.,0.,3., 3.,3.,3.,0.,0.,0.,0.,0.);
|
||||||
|
|
||||||
|
col = SELECT(mod(float(x),8.0),col);
|
||||||
|
if (col == 0.0) return RGB(0,0,0);
|
||||||
|
if (col == 1.0) return RGB(177,52,37);
|
||||||
|
if (col == 2.0) return RGB(227,157,37);
|
||||||
|
if (col == 3.0) return RGB(106,107,4);
|
||||||
|
return RGB(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 getTile(int t, int x, int y)
|
||||||
|
{
|
||||||
|
if (t == 0) return RGB(107,140,255);
|
||||||
|
if (t == 1) return sprGround(x,y);
|
||||||
|
if (t == 2) return sprQuestionBlock(x,y);
|
||||||
|
if (t == 3) return sprUsedBlock(x,y);
|
||||||
|
|
||||||
|
return RGB(107,140,255);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSection(int s, int x, int y)
|
||||||
|
{
|
||||||
|
float col = 0.0;
|
||||||
|
if (s == 0) {
|
||||||
|
if (y == 6) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SECROW(x,0.,0.,3.,3.,3.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SECROW(x,0.,0.,2.,2.,2.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 1) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y <= 0) col = SECROW(x,1.,1.,1.,1.,1.,1.,1.,1.);
|
||||||
|
}
|
||||||
|
if (s == 1) {
|
||||||
|
if (y == 6) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SECROW(x,0.,0.,0.,0.,0.,1.,0.,0.);
|
||||||
|
if (y == 1) col = SECROW(x,0.,0.,0.,1.,1.,1.,0.,0.);
|
||||||
|
if (y <= 0) col = SECROW(x,1.,1.,1.,1.,1.,1.,1.,1.);
|
||||||
|
}
|
||||||
|
if (s == 2) {
|
||||||
|
if (y == 6) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SECROW(x,0.,0.,3.,0.,0.,3.,0.,0.);
|
||||||
|
if (y == 3) col = SECROW(x,0.,0.,2.,0.,0.,2.,0.,0.);
|
||||||
|
if (y == 2) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 1) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y <= 0) col = SECROW(x,1.,1.,1.,1.,1.,1.,1.,1.);
|
||||||
|
}
|
||||||
|
if (s == 3) {
|
||||||
|
if (y == 6) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SECROW(x,0.,0.,0.,1.,1.,0.,0.,0.);
|
||||||
|
if (y == 1) col = SECROW(x,0.,0.,0.,1.,1.,1.,0.,0.);
|
||||||
|
if (y <= 0) col = SECROW(x,1.,1.,1.,1.,1.,1.,1.,1.);
|
||||||
|
}
|
||||||
|
if (s == 4) {
|
||||||
|
if (y == 6) col = SECROW(x,0.,0.,0.,0.,3.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SECROW(x,0.,0.,0.,0.,2.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SECROW(x,0.,0.,0.,1.,1.,1.,0.,0.);
|
||||||
|
if (y == 1) col = SECROW(x,0.,0.,0.,1.,1.,1.,0.,0.);
|
||||||
|
if (y <= 0) col = SECROW(x,1.,1.,1.,1.,1.,1.,1.,1.);
|
||||||
|
}
|
||||||
|
if (s == 5) {
|
||||||
|
if (y == 6) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 5) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 4) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 3) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 2) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y == 1) col = SECROW(x,0.,0.,0.,0.,0.,0.,0.,0.);
|
||||||
|
if (y <= 0) col = SECROW(x,1.,1.,1.,0.,0.,1.,1.,1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return int(SELECTSEC(mod(float(x),4.0),col));
|
||||||
|
}
|
||||||
|
|
||||||
|
int getBlock(int x, int y)
|
||||||
|
{
|
||||||
|
#ifdef TOTALLY_RANDOM_LEVEL
|
||||||
|
int height = 1 + int(rand(vec2(int(float(x) / 3.0),2.3)) * 3.0);
|
||||||
|
return (y < height ? 1 : 0);
|
||||||
|
#else
|
||||||
|
if (y > 6) return 0;
|
||||||
|
|
||||||
|
int section = int(rand(vec2(int(float(x) / 8.0),3.0)) * 6.0);
|
||||||
|
int sectionX = int(mod(float(x), 8.0));
|
||||||
|
|
||||||
|
return getSection(section,sectionX,y - int(rand(vec2(section,2.0)) * 0.0));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSolid(int b)
|
||||||
|
{
|
||||||
|
return (b != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
const float gameSpeed = 60.0;
|
||||||
|
|
||||||
|
// Get the current game pixel
|
||||||
|
// (Each game pixel is two screen pixels)
|
||||||
|
// (or four, if the screen is larger)
|
||||||
|
float x = fragCoord.x / 2.0;
|
||||||
|
float y = fragCoord.y / 2.0;
|
||||||
|
if (iResolution.y >= 640.0) {
|
||||||
|
x /= 2.0;
|
||||||
|
y /= 2.0;
|
||||||
|
}
|
||||||
|
if (iResolution.y < 200.0) {
|
||||||
|
x *= 2.0;
|
||||||
|
y *= 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just move the screen up for half a block's size
|
||||||
|
y -= 8.0;
|
||||||
|
|
||||||
|
// Get the grid index of the block at this pixel,
|
||||||
|
// and of the block at the screen's leftmost position
|
||||||
|
int firstBlockX = int((iTime * gameSpeed) / 16.0);
|
||||||
|
int blockX = int((x + iTime * gameSpeed) / 16.0);
|
||||||
|
int blockY = int(y / 16.0);
|
||||||
|
|
||||||
|
// Ask for the block ID that exists in the current position
|
||||||
|
int block = getBlock(blockX,blockY);
|
||||||
|
|
||||||
|
// Get the fractional position inside current block
|
||||||
|
int subx = int(mod((x + iTime * gameSpeed),16.0));
|
||||||
|
int suby = int(mod(y,16.0));
|
||||||
|
|
||||||
|
// Animate block if it's a Question Block
|
||||||
|
if (block == 2) {
|
||||||
|
if (blockX - firstBlockX == 5) {
|
||||||
|
suby -= int(max(0.0,(sin(mod((iTime * gameSpeed / 16.0),1.0) * 3.141592 * 1.5) * 8.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((floor((x + iTime * gameSpeed) / 16.0) - (iTime * gameSpeed) / 16.0) < 4.25) block = 3;
|
||||||
|
// Animate block if it's on top of a Question Block
|
||||||
|
} else if (block == 3) {
|
||||||
|
block = 2;
|
||||||
|
suby += 16;
|
||||||
|
if (blockX - firstBlockX == 5) {
|
||||||
|
suby -= int(max(0.0,(sin(mod((iTime * gameSpeed / 16.0),1.0) * 3.141592 * 1.5) * 8.0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Get the final color for this pixel
|
||||||
|
// (Mario can override this later on)
|
||||||
|
fragColor = getTile(block,subx,suby);
|
||||||
|
|
||||||
|
|
||||||
|
// If this is the column where Mario stops simulating...
|
||||||
|
// (it's the only column he can appear in)
|
||||||
|
if (x >= endX && x < endX + 16.0) {
|
||||||
|
|
||||||
|
// Screen position in pixels:
|
||||||
|
// Every block is 16 pixels wide
|
||||||
|
float screenX = iTime * gameSpeed;
|
||||||
|
|
||||||
|
// Mario's starting position and speed
|
||||||
|
float marioX = screenX + startX;
|
||||||
|
float marioY = 16.0;
|
||||||
|
float marioXSpd = 4.0;
|
||||||
|
float marioYSpd = 0.0;
|
||||||
|
|
||||||
|
// Find out the first empty block in this column,
|
||||||
|
// starting from the bottom, as to put Mario on top of it
|
||||||
|
for(int i = 1; i < 4; i++) {
|
||||||
|
if (!isSolid(getBlock(int(marioX / 16.0), i))) {
|
||||||
|
marioY = float(i) * 16.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of steps to simulate;
|
||||||
|
// We'll simulate at 15 FPS and interpolate later,
|
||||||
|
// hence the division by 4.0
|
||||||
|
// (Mario should actually be walking 1 pixel every 1/60th of a second,
|
||||||
|
// but he'll be walking 4 pixels every 1/15th)
|
||||||
|
const int simSteps = int((endX - startX) / 4.0);
|
||||||
|
|
||||||
|
// Previous position, as to interpolate later, for high frame rates
|
||||||
|
float lastX = 0.0;
|
||||||
|
float lastY = 0.0;
|
||||||
|
|
||||||
|
// Start simulating
|
||||||
|
bool onGround = false;
|
||||||
|
for(int sim = 0; sim < simSteps; sim++) {
|
||||||
|
// Store the previous position
|
||||||
|
lastX = marioX;
|
||||||
|
lastY = marioY;
|
||||||
|
|
||||||
|
// If Mario is inside a block, move him up
|
||||||
|
// (This happens only at the start of the simulation,
|
||||||
|
// sometimes because he is heads-up with a wall and
|
||||||
|
// cannot make a jump properly)
|
||||||
|
onGround = false;
|
||||||
|
if (isSolid(getBlock(int(marioX / 16.0) + 1, int(marioY / 16.0)))) {
|
||||||
|
marioY = (floor(marioY / 16.0) * 16.0) + 16.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, pretty standard platforming code
|
||||||
|
|
||||||
|
// Apply gravity and move in the Y-axis
|
||||||
|
marioYSpd -= 2.5;
|
||||||
|
marioY += marioYSpd;
|
||||||
|
|
||||||
|
// If he is going up,
|
||||||
|
// and if there is a block above him,
|
||||||
|
// align him with the grid (as to avoid getting inside the block),
|
||||||
|
// and invert his YSpeed, as to fall quickly (because he bounced his head)
|
||||||
|
if (marioYSpd > 0.0) {
|
||||||
|
if (isSolid(getBlock(int(floor((marioX + 12.0) / 16.0)), int(floor((marioY + 15.9) / 16.0))))) {
|
||||||
|
marioYSpd *= -0.5;
|
||||||
|
marioY = (floor(marioY / 16.0) * 16.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If he is going down,
|
||||||
|
// and if there is a block beneath him,
|
||||||
|
// align him with the grid (as to land properly on top of the block),
|
||||||
|
// and mark him as onGround (to be able to perform a jump)
|
||||||
|
if (marioYSpd < 0.0) {
|
||||||
|
if (isSolid(getBlock(int(floor((marioX) / 16.0)), int(floor(marioY / 16.0)))) ||
|
||||||
|
isSolid(getBlock(int(floor((marioX + 15.9) / 16.0)), int(floor(marioY / 16.0))))) {
|
||||||
|
marioYSpd = 0.0;
|
||||||
|
marioY = (floor(marioY / 16.0) * 16.0) + 16.0;
|
||||||
|
onGround = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, move him in the X-axis
|
||||||
|
// I assume here he'll never hit a block horizontally
|
||||||
|
marioX += marioXSpd;
|
||||||
|
|
||||||
|
// Now, if he's onGround,
|
||||||
|
// and if there are blocks in front of him,
|
||||||
|
// or if there is a pit right next to him,
|
||||||
|
// set his YSpeed to jump
|
||||||
|
if (onGround) {
|
||||||
|
if (!isSolid(getBlock(int((marioX) / 16.0) + 1,0))) {
|
||||||
|
marioYSpd = 15.5;
|
||||||
|
} else if (isSolid(getBlock(int((marioX + 36.0) / 16.0), int((marioY + 24.0) / 16.0)))) {
|
||||||
|
marioYSpd = 15.5;
|
||||||
|
} else if (isSolid(getBlock(int((marioX) / 16.0) + 2, int((marioY + 8.0) / 16.0)))) {
|
||||||
|
marioYSpd = 12.5;
|
||||||
|
} else if (getBlock(int((marioX) / 16.0) + 1, int((marioY + 8.0) / 16.0) + 2) == 2) {
|
||||||
|
marioYSpd = 15.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interpolate Y-pos for smooth high-frame-rate movement
|
||||||
|
marioY = mix(lastY,marioY,mod(iTime * 15.0,1.0)) - 1.0;
|
||||||
|
|
||||||
|
// Finally, if he appears at this row, fetch a pixel from his sprites
|
||||||
|
if (y >= marioY && y < marioY + 16.0) {
|
||||||
|
vec4 spr = vec4(0,0,0,0);
|
||||||
|
if (onGround) {
|
||||||
|
// Which frame?
|
||||||
|
int f = int(mod(iTime * 10.0, 3.0));
|
||||||
|
if (f == 0) spr = sprMarioWalk1(int(x - (marioX - screenX)),int(y - marioY));
|
||||||
|
if (f == 1) spr = sprMarioWalk2(int(x - (marioX - screenX)),int(y - marioY));
|
||||||
|
if (f == 2) spr = sprMarioWalk3(int(x - (marioX - screenX)),int(y - marioY));
|
||||||
|
} else {
|
||||||
|
spr = sprMarioJump(int(x - (marioX - screenX)),int(y - marioY));
|
||||||
|
}
|
||||||
|
// Transparency check
|
||||||
|
if (spr.x != 0.0) fragColor = spr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/Msj3zD
|
71
pentagonal-tessellations.glsl
Normal file
71
pentagonal-tessellations.glsl
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// Created by Matthew Arcus, 2018
|
||||||
|
// Wythoff construction for dual snub quadrille tessellation
|
||||||
|
|
||||||
|
vec2 perp(vec2 r) {
|
||||||
|
return vec2(-r.y,r.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 getcol(int i) {
|
||||||
|
if (i == 0) return vec3(1,0,0);
|
||||||
|
if (i == 1) return vec3(0,1,0);
|
||||||
|
if (i == 2) return vec3(0,0,1);
|
||||||
|
if (i == 3) return vec3(1,1,0);
|
||||||
|
return vec3(1,1,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// segment function by FabriceNeyret2
|
||||||
|
float segment(vec2 p, vec2 a, vec2 b) {
|
||||||
|
vec2 pa = p - a;
|
||||||
|
vec2 ba = b - a;
|
||||||
|
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
|
||||||
|
float d = length(pa - ba * h);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
int imod(int n, int m) {
|
||||||
|
return n - n/m*m;
|
||||||
|
}
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
||||||
|
float scale = 0.8;
|
||||||
|
float lwidth = 0.025;
|
||||||
|
// Half the width of the AA line edge
|
||||||
|
float aawidth = 1.5*scale/iResolution.y;
|
||||||
|
fragCoord.y += iTime * 2;
|
||||||
|
vec2 q,p = (2.0*fragCoord.xy-iResolution.xy)/iResolution.y;
|
||||||
|
if (iMouse.x > 5.0) {
|
||||||
|
q = (iMouse.xy-25.0)/(iResolution.xy-50.0);
|
||||||
|
q = clamp(q,0.0,1.0);
|
||||||
|
} else {
|
||||||
|
// Just bouncing around
|
||||||
|
q = mod(0.3*iTime*vec2(1,1.618),2.0);
|
||||||
|
q = min(q,2.0-q);
|
||||||
|
}
|
||||||
|
p *= scale;
|
||||||
|
p = mod(p,2.0)-1.0; // Fold down to ±1 square
|
||||||
|
int parity = int((p.y < 0.0) != (p.x < 0.0)); // Reflection?
|
||||||
|
int col = 1+2*int(p.x < 0.0) + parity; // Quadrant
|
||||||
|
p = abs(p);
|
||||||
|
if (parity != 0) p.xy = p.yx;
|
||||||
|
// Lines from triangle vertices to Wythoff point
|
||||||
|
float d = 1e8;
|
||||||
|
d = min(d,segment(p,vec2(0,0),q));
|
||||||
|
d = min(d,segment(p,vec2(1,0),q));
|
||||||
|
d = min(d,segment(p,vec2(1,1),q));
|
||||||
|
d = min(d,segment(p,vec2(-q.y,q.x),vec2(q.y,-q.x)));
|
||||||
|
d = min(d,segment(p,vec2(-q.y,q.x),vec2(q.y,2.0-q.x)));
|
||||||
|
d = min(d,segment(p,vec2(2.0-q.y,q.x),vec2(q.y,2.0-q.x)));
|
||||||
|
// Color - what side of the lines are we?
|
||||||
|
float a = dot(p-q,perp(vec2(0,0)-q));
|
||||||
|
float b = dot(p-q,perp(vec2(1,0)-q));
|
||||||
|
float c = dot(p-q,perp(vec2(1,1)-q));
|
||||||
|
if (a > 0.0 && b < 0.0) col++;
|
||||||
|
if (c < 0.0 && b > 0.0) col--;
|
||||||
|
// How to write non-portable code: take the modulus of a negative number
|
||||||
|
vec3 ccol = getcol(imod(col,4));
|
||||||
|
ccol = mix(ccol,vec3(1),0.3);
|
||||||
|
ccol = mix(vec3(0.1),ccol,smoothstep(lwidth-aawidth,lwidth+aawidth,d));
|
||||||
|
fragColor = vec4(sqrt(ccol),1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/XlBBWG
|
97
plasma-triangle.glsl
Normal file
97
plasma-triangle.glsl
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
#pragma map iChannel0=builtin:RGBA Noise Medium
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
float pointRadius = 0.06;
|
||||||
|
float linkSize = 0.04;
|
||||||
|
float noiseStrength = 0.08; // range: 0-1
|
||||||
|
|
||||||
|
float minDimension = min(iResolution.x, iResolution.y);
|
||||||
|
vec2 bounds = vec2(iResolution.x / minDimension, iResolution.y / minDimension);
|
||||||
|
vec2 uv = fragCoord.xy / minDimension;
|
||||||
|
|
||||||
|
vec3 pointR = vec3(0.0, 0.0, 1.0);
|
||||||
|
vec3 pointG = vec3(0.0, 0.0, 1.0);
|
||||||
|
vec3 pointB = vec3(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
// Make the points orbit round the origin in 3 dimensions.
|
||||||
|
// Coefficients are arbitrary to give different behaviours.
|
||||||
|
// The Z coordinate should always be >0.0, as it's used directly to
|
||||||
|
// multiply the radius to give the impression of depth.
|
||||||
|
pointR.x += 0.32 * sin(1.32 * iTime);
|
||||||
|
pointR.y += 0.3 * sin(1.03 * iTime);
|
||||||
|
pointR.z += 0.4 * sin(1.32 * iTime);
|
||||||
|
|
||||||
|
pointG.x += 0.31 * sin(0.92 * iTime);
|
||||||
|
pointG.y += 0.29 * sin(0.99 * iTime);
|
||||||
|
pointG.z += 0.38 * sin(1.24 * iTime);
|
||||||
|
|
||||||
|
pointB.x += 0.33 * sin(1.245 * iTime);
|
||||||
|
pointB.y += 0.3 * sin(1.41 * iTime);
|
||||||
|
pointB.z += 0.41 * sin(1.11 * iTime);
|
||||||
|
|
||||||
|
// Centre the points in the display
|
||||||
|
vec2 midUV = vec2(bounds.x * 0.5, bounds.y * 0.5);
|
||||||
|
pointR.xy += midUV;
|
||||||
|
pointG.xy += midUV;
|
||||||
|
pointB.xy += midUV;
|
||||||
|
|
||||||
|
// Calculate the vectors from the current fragment to the coloured points
|
||||||
|
vec2 vecToR = pointR.xy - uv;
|
||||||
|
vec2 vecToG = pointG.xy - uv;
|
||||||
|
vec2 vecToB = pointB.xy - uv;
|
||||||
|
|
||||||
|
vec2 dirToR = normalize(vecToR.xy);
|
||||||
|
vec2 dirToG = normalize(vecToG.xy);
|
||||||
|
vec2 dirToB = normalize(vecToB.xy);
|
||||||
|
|
||||||
|
float distToR = length(vecToR);
|
||||||
|
float distToG = length(vecToG);
|
||||||
|
float distToB = length(vecToB);
|
||||||
|
|
||||||
|
// Calculate the dot product between vectors from the current fragment to each pair
|
||||||
|
// of adjacent coloured points. This helps us determine how close the current fragment
|
||||||
|
// is to a link between points.
|
||||||
|
float dotRG = dot(dirToR, dirToG);
|
||||||
|
float dotGB = dot(dirToG, dirToB);
|
||||||
|
float dotBR = dot(dirToB, dirToR);
|
||||||
|
|
||||||
|
// Start with a bright coloured dot around each point
|
||||||
|
fragColor.x = 1.0 - smoothstep(distToR, 0.0, pointRadius * pointR.z);
|
||||||
|
fragColor.y = 1.0 - smoothstep(distToG, 0.0, pointRadius * pointG.z);
|
||||||
|
fragColor.z = 1.0 - smoothstep(distToB, 0.0, pointRadius * pointB.z);
|
||||||
|
fragColor.w = 1.0;
|
||||||
|
|
||||||
|
// We want to show a coloured link between adjacent points.
|
||||||
|
// Determine the strength of each link at the current fragment.
|
||||||
|
// This tends towards 1.0 as the vectors to each point tend towards opposite directions.
|
||||||
|
float linkStrengthRG = 1.0 - smoothstep(dotRG, -1.01, -1.0 + (linkSize * pointR.z * pointG.z));
|
||||||
|
float linkStrengthGB = 1.0 - smoothstep(dotGB, -1.01, -1.0 + (linkSize * pointG.z * pointB.z));
|
||||||
|
float linkStrengthBR = 1.0 - smoothstep(dotBR, -1.01, -1.0 + (linkSize * pointB.z * pointR.z));
|
||||||
|
|
||||||
|
// If the current fragment is in a link, we need to know how much the
|
||||||
|
// linked points contribute of their colour.
|
||||||
|
float sumDistRG = distToR + distToG;
|
||||||
|
float sumDistGB = distToG + distToB;
|
||||||
|
float sumDistBR = distToB + distToR;
|
||||||
|
|
||||||
|
float contribRonRG = 1.0 - (distToR / sumDistRG);
|
||||||
|
float contribRonBR = 1.0 - (distToR / sumDistBR);
|
||||||
|
|
||||||
|
float contribGonRG = 1.0 - (distToG / sumDistRG);
|
||||||
|
float contribGonGB = 1.0 - (distToG / sumDistGB);
|
||||||
|
|
||||||
|
float contribBonGB = 1.0 - (distToB / sumDistGB);
|
||||||
|
float contribBonBR = 1.0 - (distToB / sumDistBR);
|
||||||
|
|
||||||
|
// Additively blend the link colours into the fragment.
|
||||||
|
fragColor.x += (linkStrengthRG * contribRonRG) + (linkStrengthBR * contribRonBR);
|
||||||
|
fragColor.y += (linkStrengthGB * contribGonGB) + (linkStrengthRG * contribGonRG);
|
||||||
|
fragColor.z += (linkStrengthBR * contribBonBR) + (linkStrengthGB * contribBonGB);
|
||||||
|
|
||||||
|
// Use an underlying texture to provide some noise
|
||||||
|
float noiseMin = 1.0 - noiseStrength;
|
||||||
|
fragColor.xyz *= (1.0 - noiseStrength) + (noiseStrength * texture(iChannel0, uv * 2.0).xyz);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/XdX3WN
|
109
positive-energy.glsl
Normal file
109
positive-energy.glsl
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
// The MIT License
|
||||||
|
// Copyright © 2013 Inigo Quilez
|
||||||
|
// 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.
|
||||||
|
// Title: "Wroclaw - my city", Author: Anna Nowacka
|
||||||
|
// This shader is prepared for the first Wroclaw Shader Competition
|
||||||
|
// organized by Faculty of Physics and Astronomy, Khronos Chapter and SIggraph Chapter from Wroclaw
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float length2( in vec2 p ) { return dot(p,p); }
|
||||||
|
|
||||||
|
const vec2 va = vec2( 0.0, 1.73-0.85 );
|
||||||
|
const vec2 vb = vec2( 1.0, 0.00-0.85 );
|
||||||
|
const vec2 vc = vec2( -1.0, 0.00-0.85 );
|
||||||
|
//const vec3 vd = vec3( 1.0, 0.0, 0.00-0.85 );
|
||||||
|
|
||||||
|
|
||||||
|
// return distance and address
|
||||||
|
vec2 map( vec2 p )
|
||||||
|
{
|
||||||
|
float a = 0.0;
|
||||||
|
vec2 c;
|
||||||
|
float dist, d, t;
|
||||||
|
for( int i=0; i<10; i++ )
|
||||||
|
{
|
||||||
|
d = length2(p-va); c = va; dist=d; t=0.0;
|
||||||
|
d = length2(p-vb); if (d < dist) { c = vb; dist=d; t=1.0; }
|
||||||
|
d = length2(p-vc); if (d < dist) { c = vc; dist=d; t=2.0; }
|
||||||
|
p = c + 2.0*(p - c);
|
||||||
|
a = t + a*2.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec2( length(p)/pow(2.0, 7.0), a/pow(3.0,7.0) );
|
||||||
|
}
|
||||||
|
|
||||||
|
float disk(vec2 r, vec2 center, float radius) {
|
||||||
|
return 2.0 - smoothstep( radius-0.5, radius+0.5, length(r-center));
|
||||||
|
}
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
vec2 uv = (2.0*fragCoord.xy - iResolution.xy)/iResolution.y;
|
||||||
|
|
||||||
|
vec2 r = map( uv*cos(0.3*iTime));
|
||||||
|
|
||||||
|
vec3 col = 0.3 + 0.5*sin( 3.1416*r.y +vec3(0.0,5.5,5.0) )+0.4*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x )+0.5+0.5*tan(iTime);
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
//vec2 m = vec2(1.5);
|
||||||
|
//float an = 3.2 + 0.5*iTime - 6.2831*(m.x-0.5);
|
||||||
|
|
||||||
|
if(iTime > 15.0)
|
||||||
|
{vec3 col = 0.3 + 0.5*sin( 3.1416*r.y + vec3(0.0,5.5,5.0) )+0.4*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x +0.50*tan(iTime)-0.5);
|
||||||
|
fragColor = vec4( col, 1.0 );}
|
||||||
|
|
||||||
|
if(iTime > 31.0)
|
||||||
|
{vec2 uv = (2.0*fragCoord.xy - iResolution.xy)/iResolution.y;
|
||||||
|
|
||||||
|
vec2 r = map( uv*cos(0.3*iTime));
|
||||||
|
|
||||||
|
vec3 col = 0.5 + 0.5*sin( 3.1416*r.y + vec3(0.0,5.5,5.0) )+0.4*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x )+0.5*sin(iTime);
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
}
|
||||||
|
if(iTime > 51.0)
|
||||||
|
{vec2 uv = (1.0*fragCoord.xy - iResolution.xy)/iResolution.y;
|
||||||
|
|
||||||
|
vec2 r = map( uv*cos(0.3*iTime));
|
||||||
|
|
||||||
|
vec3 col = 0.5 + 0.5*sin( 3.1416*r.y + vec3(0.0,5.5,5.0) )+0.4*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x )+0.5*(1.00/(cos(iTime)))+1.00;
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iTime > 74.0)
|
||||||
|
{vec3 col = 1.0 + 0.5*sin( 3.1416*r.y + vec3(0.0,5.5,5.0) )+0.4*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x )+0.5*(1.00/(cos(iTime)))+1.00;
|
||||||
|
fragColor = vec4( col, 1.0 );
|
||||||
|
|
||||||
|
}
|
||||||
|
if (iTime > 89.0)
|
||||||
|
{vec3 col = 1.0 + 0.5*sin( 3.1416*r.y + vec3(0.0,5.5,5.0) )+0.4*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x )+0.5*(1.00/(cos(iTime)))+1.00;
|
||||||
|
fragColor = floor(vec4( col, 1.0 ));
|
||||||
|
}
|
||||||
|
if (iTime > 100.0)
|
||||||
|
{
|
||||||
|
vec2 uv = (2.0*fragCoord.xy - iResolution.xy)/iResolution.y;
|
||||||
|
|
||||||
|
vec2 r = map( uv*sin(cos(0.3*iTime)));
|
||||||
|
vec3 col = 1.0 + 0.5*tan( 3.1416*r.y + vec3(0.0,5.5,5.0) )+0.5*sin(iTime);
|
||||||
|
col *= 1.0 - smoothstep( 0.0, 0.02, r.x )+0.5*tan(iTime)+1.00;
|
||||||
|
fragColor =(log(vec4( col, 2.0 )));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iTime > 120.0)
|
||||||
|
{
|
||||||
|
col = vec3(0.0);
|
||||||
|
fragColor = vec4(col, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// https://www.shadertoy.com/view/lllBWn
|
229
raytracing.glsl
Normal file
229
raytracing.glsl
Normal file
|
@ -0,0 +1,229 @@
|
||||||
|
|
||||||
|
// line light test WIP
|
||||||
|
|
||||||
|
// original: http://glslsandbox.com/e#43990.0
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
|
||||||
|
|
||||||
|
//float t=2.6;
|
||||||
|
float t=time;
|
||||||
|
|
||||||
|
vec3 lightpos1 = vec3(-1.*cos(t),-.5+0.25*cos(t),sin(t));
|
||||||
|
vec3 lightpos2 = vec3(1.*cos(t),-.5+0.25*cos(t),-sin(t));
|
||||||
|
|
||||||
|
|
||||||
|
//vec3 lightpos1 = vec3(-2.8,10.+10.8*sin(time+0.),0.);
|
||||||
|
//vec3 lightpos2 = vec3(2.5,10.+10.8*sin(time),0.);
|
||||||
|
|
||||||
|
vec3 hsv2rgb(vec3 c)
|
||||||
|
{
|
||||||
|
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||||
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||||
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 rotatey(in vec3 p, float ang)
|
||||||
|
{
|
||||||
|
return vec3(p.x*cos(ang)-p.z*sin(ang), p.y, p.x*sin(ang)+p.z*cos(ang));
|
||||||
|
}
|
||||||
|
vec3 rotatex(in vec3 p, float ang)
|
||||||
|
{
|
||||||
|
return vec3(p.x, p.y*cos(ang)-p.z*sin(ang), p.y*sin(ang)+p.z*cos(ang));
|
||||||
|
}
|
||||||
|
vec3 rotatez(in vec3 p, float ang)
|
||||||
|
{
|
||||||
|
return vec3(p.x*cos(ang)-p.y*sin(ang), p.x*sin(ang)+p.y*cos(ang), p.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 plane(in vec3 p, in vec3 n, float d, float obj)
|
||||||
|
{
|
||||||
|
n = normalize(n);
|
||||||
|
return vec2(dot(p,n) + d, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 rbox(in vec3 p, in vec3 pos, in vec3 ang, float obj)
|
||||||
|
{
|
||||||
|
vec3 b = vec3(0.3,0.3,0.3);
|
||||||
|
p -= pos;
|
||||||
|
p = rotatey(p, ang.y*time);
|
||||||
|
p = rotatex(p, ang.x*time);
|
||||||
|
p = rotatez(p, ang.z*time);
|
||||||
|
return vec2(length(max(abs(p)-b,0.0)) - 0.1, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 sdCapsule( vec3 p, vec3 a, vec3 b, float r, float obj )
|
||||||
|
{
|
||||||
|
vec3 pa = p - a, ba = b - a;
|
||||||
|
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
|
||||||
|
return vec2(length( pa - ba*h ) - r, obj);
|
||||||
|
}
|
||||||
|
vec2 sph(in vec3 p, float r, float obj)
|
||||||
|
{
|
||||||
|
return vec2(length(p) - r, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 min2(vec2 o1, vec2 o2)
|
||||||
|
{
|
||||||
|
if (o1.x < o2.x)
|
||||||
|
return o1;
|
||||||
|
else
|
||||||
|
return o2;
|
||||||
|
}
|
||||||
|
vec2 scene(in vec3 p)
|
||||||
|
{
|
||||||
|
vec2 d = plane(p, vec3(0,1.0,0), 0.9, 0.0);
|
||||||
|
d = min2(d, plane(p, vec3(0,0.0,1.0), 1.3, 0.0));
|
||||||
|
d = min2(d, sdCapsule(p, lightpos1,lightpos2,0.1,6.));
|
||||||
|
d = min2(d, sph(p-vec3(1.),1.,0.0));
|
||||||
|
|
||||||
|
d = min2(d, sph(p-vec3(-0.,1.,0.),1.,0.0));
|
||||||
|
|
||||||
|
d = min2(d, sph(p-vec3(-2.,1.,-1.),1.,0.0));
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 get_normal(in vec3 p)
|
||||||
|
{
|
||||||
|
vec3 eps = vec3(0.0001, 0, 0);
|
||||||
|
float nx = scene(p + eps.xyy).x - scene(p - eps.xyy).x;
|
||||||
|
float ny = scene(p + eps.yxy).x - scene(p - eps.yxy).x;
|
||||||
|
float nz = scene(p + eps.yyx).x - scene(p - eps.yyx).x;
|
||||||
|
return normalize(vec3(nx,ny,nz));
|
||||||
|
}
|
||||||
|
|
||||||
|
float softshadow(in vec3 ro, in vec3 rd)
|
||||||
|
{
|
||||||
|
vec3 pos = ro;
|
||||||
|
float shade = 0.0;
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
vec2 d = scene(pos);
|
||||||
|
pos += rd*d.x;
|
||||||
|
shade += (1.0 - shade)*clamp(d.x, 0.0, 0.90);
|
||||||
|
}
|
||||||
|
return shade;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ao(in vec3 ro, in vec3 rd)
|
||||||
|
{
|
||||||
|
vec3 pos = ro;
|
||||||
|
float shade = 1.0;
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
vec2 d = scene(pos);
|
||||||
|
pos += rd*d.x;
|
||||||
|
shade -= d.x*pow(2.0, 0.5*float(i));
|
||||||
|
}
|
||||||
|
return shade;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 linelight( vec3 rd, vec3 pos, vec3 lp1, vec3 lp2 )
|
||||||
|
{
|
||||||
|
|
||||||
|
lp2-=lp1;
|
||||||
|
vec3 line = normalize(lp2);
|
||||||
|
vec3 rp = cross(line,rd);
|
||||||
|
rp = cross(rp,rd);
|
||||||
|
|
||||||
|
|
||||||
|
float dlp = dot(line,rp);
|
||||||
|
|
||||||
|
float ld = dot(pos-lp1,rp)/dlp;
|
||||||
|
|
||||||
|
float len = length(lp2);
|
||||||
|
|
||||||
|
ld = clamp(ld, 0.,len);
|
||||||
|
|
||||||
|
|
||||||
|
vec3 hit = lp1+ld*line;
|
||||||
|
|
||||||
|
float bri= ld/len;
|
||||||
|
return vec4(hit,bri);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 linelightd( vec3 pos, vec3 lp1, vec3 lp2 )
|
||||||
|
{
|
||||||
|
vec3 p1=(lp1-pos);
|
||||||
|
vec3 p2=(lp2-pos);
|
||||||
|
|
||||||
|
vec3 halfv = normalize(normalize(p1)+normalize(p2));
|
||||||
|
|
||||||
|
float d1 = dot(halfv,p1);
|
||||||
|
float d2 = dot(halfv,p2);
|
||||||
|
|
||||||
|
float e1 = max(d1,d2);
|
||||||
|
float e2 = min(d1,d2);
|
||||||
|
|
||||||
|
//need to fix
|
||||||
|
vec3 hit = pos+halfv*pow(e1-0.5*(e1-e2),2.);
|
||||||
|
|
||||||
|
float bri= 1.;
|
||||||
|
return vec4(hit,bri);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
|
||||||
|
vec2 p = 2.0* ( gl_FragCoord.xy / resolution.xy ) - 1.0;
|
||||||
|
|
||||||
|
p.x *= resolution.x/resolution.y;
|
||||||
|
p /= max(resolution.x, resolution.y) / 60.0;
|
||||||
|
|
||||||
|
vec3 color = vec3(0.0);
|
||||||
|
vec3 contrib = vec3(0.0);
|
||||||
|
vec3 ro = vec3(0.0,0,2.0);
|
||||||
|
vec3 rd = normalize(vec3(p.x,p.y,-1.0));
|
||||||
|
|
||||||
|
|
||||||
|
vec3 pos = ro;
|
||||||
|
float dist = 0.0;
|
||||||
|
vec2 d;
|
||||||
|
//pos+=rd*2.;
|
||||||
|
for (int i = 0; i < 64; i++) {
|
||||||
|
|
||||||
|
d = scene(pos);
|
||||||
|
pos += rd*d.x*1.0;
|
||||||
|
dist += d.x*1.0;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (dist < 100.0 && d.x < 0.001) {
|
||||||
|
vec3 n = get_normal(pos);
|
||||||
|
|
||||||
|
vec3 rp = cross(n,rd);
|
||||||
|
|
||||||
|
vec3 ref = reflect(rd,n);
|
||||||
|
|
||||||
|
//spec
|
||||||
|
vec4 lineLight = linelight(ref,pos,lightpos1,lightpos2);
|
||||||
|
vec3 ls = lineLight.xyz-pos;
|
||||||
|
float bris = .5/sqrt(length(ls));
|
||||||
|
bris*=lineLight.a;
|
||||||
|
ls = normalize(ls);
|
||||||
|
|
||||||
|
//diffuse
|
||||||
|
lineLight = linelightd(pos,lightpos1,lightpos2);
|
||||||
|
vec3 ld = lineLight.xyz-pos;
|
||||||
|
float brid= .2/sqrt(length(ld));
|
||||||
|
brid*=lineLight.a;
|
||||||
|
ld = normalize(ld);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vec3 r = reflect(rd, n);
|
||||||
|
float diff = clamp(dot(n, ld), 0.0, 1.0);
|
||||||
|
float shade = smoothstep(0.0, 1.0, 1.0 - ao(pos+0.01*n, 0.5*n));
|
||||||
|
float spec = pow(clamp(dot(r, ls), 0.0, 1.0), 109.0);
|
||||||
|
float shadow = 0.;//clamp(softshadow(pos+0.01*n, l), -1.0, 1.0);
|
||||||
|
if (d.y > 0.5 && d.y < 1.5) color += diff*vec3(1,1,1)*brid;
|
||||||
|
else if(d.y > 5.5)
|
||||||
|
color = vec3(1,1,1);
|
||||||
|
else
|
||||||
|
color += diff*vec3(0.5,1,1)*brid*1. + spec*vec3(1,1,1)*hsv2rgb(vec3(bris,0.5,1.));
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = vec4(pow(color,vec3(1./2.2)), 1.0);
|
||||||
|
}
|
BIN
res/ascii.png
BIN
res/ascii.png
Binary file not shown.
Before Width: | Height: | Size: 1.3 MiB |
47
sines.glsl
Normal file
47
sines.glsl
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// Guyver
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform float lowFreq;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 SUN_1 = vec3(0.0,0.5,1.0);
|
||||||
|
vec3 SUN_2 = vec3(1.0,0.0,0.0);
|
||||||
|
vec3 SUN_3 = vec3(0.1,1.0,0.753);
|
||||||
|
vec3 SUN_4 = vec3(0.6,0.8,0.0);
|
||||||
|
|
||||||
|
|
||||||
|
float sigmoid(float x)
|
||||||
|
{
|
||||||
|
return 1.5/(1. + exp2(-x)) - 1.;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void main( void )
|
||||||
|
{
|
||||||
|
vec2 position = gl_FragCoord.xy * 4.0;
|
||||||
|
vec2 aspect = vec2(resolution/resolution );
|
||||||
|
position -= 0.5*resolution;
|
||||||
|
vec2 position2 = 0.5 + (position-0.5)/resolution*3.;
|
||||||
|
position *= .05;
|
||||||
|
position2 *= .05;
|
||||||
|
float filter = sigmoid(pow(2.,7.5)*(length((position/resolution + 0.5)*aspect) - 0.015))*0.5 +0.5 +lowFreq*lowFreq;
|
||||||
|
position = mix(position, position2, filter) - 0.5;
|
||||||
|
|
||||||
|
vec3 color = vec3(0.);
|
||||||
|
float angle = atan(position.y,position.x);
|
||||||
|
float d = length(position);
|
||||||
|
float t = time * .5;
|
||||||
|
color += 0.08/length(vec2(.05,2.0*position.y+sin(position.x*10.+t*-6.)))*SUN_3;
|
||||||
|
color += 0.07/length(vec2(.06,4.0*position.y+sin(position.x*10.+t*-2.)))*SUN_1; // I'm sure there's an easier way to do this, this just happened to look nice and blurry.
|
||||||
|
color += 0.06/length(vec2(.07,8.0*position.y+sin(position.x*10.+t*2.)))*SUN_2;
|
||||||
|
color += 0.05/length(vec2(.08,16.0*position.y+sin(position.x*10.+t*6.)))*SUN_3;
|
||||||
|
color += 0.04/length(vec2(.09,32.0*position.y+sin(position.x*10.+t*10.)))*SUN_4;
|
||||||
|
|
||||||
|
gl_FragColor = vec4(color, 1.0);
|
||||||
|
}
|
||||||
|
|
49
spasm.glsl
Normal file
49
spasm.glsl
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//by @Flexi23, @DanielPettersso, @mrdoob
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#endif
|
||||||
|
#define pi2_inv 0.159154943091895335768883763372
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
//uniform vec2 mouse;
|
||||||
|
|
||||||
|
// extra changes by @xprogram & @Harley
|
||||||
|
|
||||||
|
float border(vec2 uv, float thickness){
|
||||||
|
uv = fract(uv - vec2(0.5));
|
||||||
|
uv = min(uv, vec2(1.)-uv)*2.;
|
||||||
|
return clamp(max(uv.x,uv.y)-1.+thickness,0.,1.)/thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
// complex multiplication
|
||||||
|
vec2 mul(vec2 a, vec2 b){
|
||||||
|
return vec2( a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 div(vec2 numerator, vec2 denominator){
|
||||||
|
return vec2( numerator.x*denominator.x + numerator.y*denominator.y,
|
||||||
|
numerator.y*denominator.x - numerator.x*denominator.y)/
|
||||||
|
vec2(denominator.x*denominator.x + denominator.y*denominator.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 spiralzoom(vec2 domain, vec2 center, float n, float spiral_factor, float zoom_factor, vec2 pos){
|
||||||
|
vec2 uv = domain - center * 1.0;
|
||||||
|
float d = length(uv);
|
||||||
|
return vec2( atan(uv.y, uv.x)*n*pi2_inv + log(d)*spiral_factor*cos(time), -log(d)*zoom_factor) + pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
vec2 uv = gl_FragCoord.xy / max(resolution.x, resolution.y);
|
||||||
|
|
||||||
|
vec2 p1 = vec2(0.25+cos(time*.9)*0.1, 0.3-tan(time*.5)*cos(time));
|
||||||
|
vec2 p2 = vec2(0.75+tan(time)*.1, 0.7-cos(time)*.5);
|
||||||
|
|
||||||
|
vec2 moebius = div(uv-p2, uv-p1);
|
||||||
|
|
||||||
|
vec2 spiral_uv = spiralzoom(moebius,vec2(-0.2),1.,1.6,1.8,-vec2(0.5,0.5)*time*.6);
|
||||||
|
vec2 spiral_uv2 = spiralzoom(moebius,vec2(-0.2),1.,1.6,1.8,-vec2(0.5,0.5)*time*.9);
|
||||||
|
vec2 spiral_uv3 = spiralzoom(moebius,vec2(-0.2),1.,1.6,1.8,-vec2(0.5,0.5)*time*.7);
|
||||||
|
gl_FragColor = vec4(border(spiral_uv,0.3), border(spiral_uv2,0.1) ,border(spiral_uv3,0.9),1.);
|
||||||
|
|
||||||
|
}
|
52
surfpos-test.glsl
Normal file
52
surfpos-test.glsl
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#extension GL_OES_standard_derivatives : enable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
varying vec2 surfacePosition;
|
||||||
|
|
||||||
|
#define mouse vec2(.5 + 0.1*cos(time*3.+surfacePosition.x*4.+cos(time*3.+surfacePosition.x*4.)), 0.)
|
||||||
|
|
||||||
|
// afl_ext 2017
|
||||||
|
|
||||||
|
#define EULER 2.7182818284590452353602874
|
||||||
|
#define IEULER 0.367879
|
||||||
|
|
||||||
|
#define time mouse.x
|
||||||
|
float wave(vec2 uv, vec2 emitter, float speed, float phase, float timeshift){
|
||||||
|
float dst = distance(uv, emitter);
|
||||||
|
return pow(EULER, sin(dst * phase - (time + timeshift) * speed));
|
||||||
|
}
|
||||||
|
vec2 wavedrag(vec2 uv, vec2 emitter){
|
||||||
|
return normalize(uv - emitter);
|
||||||
|
}
|
||||||
|
float getwaves(vec2 position){
|
||||||
|
float iter = 0.0;
|
||||||
|
float phase = 6.0;
|
||||||
|
float speed = 2.0;
|
||||||
|
float weight = 1.0;
|
||||||
|
float w = 0.0;
|
||||||
|
float ws = 0.0;
|
||||||
|
float iwaterspeed = 6.0;
|
||||||
|
for(int i=0;i<24;i++){
|
||||||
|
vec2 p = vec2(sin(iter), cos(iter)) * 300.0;
|
||||||
|
float res = wave(position, p, speed, phase, 0.0) * IEULER;
|
||||||
|
float res2 = wave(position, p, speed, phase, 0.006) * IEULER;
|
||||||
|
position -= wavedrag(position, p) * (res - res2) * weight * 5.0 * iwaterspeed;
|
||||||
|
w += res * weight;
|
||||||
|
iter += 12.0;
|
||||||
|
ws += weight;
|
||||||
|
weight = mix(weight, 0.0, 0.12);
|
||||||
|
phase *= 1.2;
|
||||||
|
speed = pow(speed, 1.014);
|
||||||
|
}
|
||||||
|
return w / ws;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
float w = getwaves(surfacePosition);
|
||||||
|
gl_FragColor = vec4( 1.0 - w*vec4(.88-w*.25,1.2,1.3,0.)*1.5 );
|
||||||
|
}
|
281
toriigate.glsl
Normal file
281
toriigate.glsl
Normal file
|
@ -0,0 +1,281 @@
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#extension GL_OES_standard_derivatives : enable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
|
||||||
|
// consts
|
||||||
|
const float EPS = 1e-4;
|
||||||
|
const float OFFSET = EPS * 10.0;
|
||||||
|
const float PI = 3.14159;
|
||||||
|
const float INF = 1e+10;
|
||||||
|
|
||||||
|
const vec3 lightDir = vec3( -0.48666426339228763, 0.8111071056538127, -0.3244428422615251 );
|
||||||
|
const vec3 backgroundColor = vec3( 0.0 );
|
||||||
|
const vec3 gateColor = vec3( 1.0, 0.1, 0.1 );
|
||||||
|
|
||||||
|
const float totalTime = 75.0;
|
||||||
|
|
||||||
|
// globals
|
||||||
|
vec3 cPos, cDir;
|
||||||
|
float normalizedGlobalTime = 0.0;
|
||||||
|
//vec3 illuminationColor;
|
||||||
|
|
||||||
|
struct Intersect {
|
||||||
|
bool isHit;
|
||||||
|
|
||||||
|
vec3 position;
|
||||||
|
float distance;
|
||||||
|
vec3 normal;
|
||||||
|
|
||||||
|
int material;
|
||||||
|
vec3 color;
|
||||||
|
};
|
||||||
|
|
||||||
|
const int BASIC_MATERIAL = 0;
|
||||||
|
const int MIRROR_MATERIAL = 1;
|
||||||
|
|
||||||
|
|
||||||
|
// distance functions
|
||||||
|
vec3 opRep( vec3 p, float interval ) {
|
||||||
|
return mod( p, interval ) - 0.5 * interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 opRep( vec2 p, float interval ) {
|
||||||
|
return mod( p, interval ) - 0.5 * interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
float opRep( float x, float interval ) {
|
||||||
|
return mod( x, interval ) - 0.5 * interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
float sphereDist( vec3 p, vec3 c, float r ) {
|
||||||
|
return length( p - c ) - r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float sdCappedCylinder( vec3 p, vec2 h ) {
|
||||||
|
vec2 d = abs(vec2(length(p.xz),p.y)) - h;
|
||||||
|
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
float udBox( vec3 p, vec3 b )
|
||||||
|
{
|
||||||
|
return length(max(abs(p)-b,0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
float udFloor( vec3 p ){
|
||||||
|
float t1 = 1.0;
|
||||||
|
float t2 = 3.0;
|
||||||
|
float d = -0.5;
|
||||||
|
for( float i = 0.0; i < 3.0; i++ ) {
|
||||||
|
float f = pow( 2.0, i );
|
||||||
|
d += 0.1 / f * ( sin( f * t1 * p.x + t2 * time ) + sin( f * t1 * p.z + t2 * time ) );
|
||||||
|
}
|
||||||
|
return dot(p,vec3(0.0,1.0,0.0)) - d;
|
||||||
|
}
|
||||||
|
|
||||||
|
float dGate( vec3 p ) {
|
||||||
|
p.y -= 1.3 * 0.5;
|
||||||
|
|
||||||
|
float r = 0.05;
|
||||||
|
float left = sdCappedCylinder( p - vec3( -1.0, 0.0, 0.0 ), vec2(r, 1.3));
|
||||||
|
float right = sdCappedCylinder( p - vec3( 1.0, 0.0, 0.0 ), vec2(r, 1.3));
|
||||||
|
|
||||||
|
float ty = 0.02 * p.x * p.x;
|
||||||
|
float tx = 0.5 * ( p.y - 1.3 );
|
||||||
|
float katsura = udBox( p - vec3( 0.0, 1.3 + ty, 0.0 ), vec3( 1.7 + tx, r * 2.0 + ty, r ) );
|
||||||
|
|
||||||
|
float kan = udBox( p - vec3( 0.0, 0.7, 0.0 ), vec3( 1.3, r, r ) );
|
||||||
|
float gakuduka = udBox( p - vec3( 0.0, 1.0, 0.0), vec3( r, 0.3, r ) );
|
||||||
|
|
||||||
|
return min( min( left, right ), min( gakuduka, min( katsura, kan ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
float dRepGate( vec3 p ) {
|
||||||
|
if ( normalizedGlobalTime <= 0.5 ) {
|
||||||
|
p.z = opRep( p.z, 1.0 + 20.0 * cos( PI * normalizedGlobalTime ) );
|
||||||
|
} else {
|
||||||
|
p.xz = opRep( p.xz, 10.0 );
|
||||||
|
}
|
||||||
|
return dGate( p );
|
||||||
|
}
|
||||||
|
|
||||||
|
float sceneDistance( vec3 p ) {
|
||||||
|
return udFloor( p );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// color functions
|
||||||
|
vec3 hsv2rgb( vec3 c ) {
|
||||||
|
|
||||||
|
vec4 K = vec4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );
|
||||||
|
vec3 p = abs( fract( c.xxx + K.xyz ) * 6.0 - K.www );
|
||||||
|
return c.z * mix( K.xxx, clamp( p - K.xxx, 0.0, 1.0 ), c.y );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Intersect minIntersect( Intersect a, Intersect b ) {
|
||||||
|
if ( a.distance < b.distance ) {
|
||||||
|
return a;
|
||||||
|
} else {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Intersect sceneIntersect( vec3 p ) {
|
||||||
|
|
||||||
|
Intersect a;
|
||||||
|
a.distance = udFloor( p );
|
||||||
|
a.material = MIRROR_MATERIAL;
|
||||||
|
// return minIntersect( a, b );
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 getNormal( vec3 p ) {
|
||||||
|
vec2 e = vec2( 1.0, -1.0 ) * 0.001;
|
||||||
|
return normalize(
|
||||||
|
e.xyy * sceneDistance( p + e.xyy ) + e.yyx * sceneDistance( p + e.yyx ) +
|
||||||
|
e.yxy * sceneDistance( p + e.yxy ) + e.xxx * sceneDistance( p + e.xxx ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
float getShadow( vec3 ro, vec3 rd ) {
|
||||||
|
|
||||||
|
float h = 0.0;
|
||||||
|
float c = 0.0;
|
||||||
|
float r = 1.0;
|
||||||
|
float shadowCoef = 0.5;
|
||||||
|
|
||||||
|
for ( float t = 0.0; t < 50.0; t++ ) {
|
||||||
|
|
||||||
|
h = sceneDistance( ro + rd * c );
|
||||||
|
|
||||||
|
if ( h < EPS ) return shadowCoef;
|
||||||
|
|
||||||
|
r = min( r, h * 16.0 / c );
|
||||||
|
c += h;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1.0 - shadowCoef + r * shadowCoef;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Intersect getRayColor( vec3 origin, vec3 ray ) {
|
||||||
|
|
||||||
|
// marching loop
|
||||||
|
float d, minDist, trueDepth;
|
||||||
|
float distance = 0.0;
|
||||||
|
vec3 p = origin;
|
||||||
|
int count = 0;
|
||||||
|
Intersect nearest;
|
||||||
|
|
||||||
|
// first pass (water)
|
||||||
|
for ( int i = 0; i < 120; i++ ){
|
||||||
|
|
||||||
|
d = sceneDistance( p );
|
||||||
|
distance += d;
|
||||||
|
p = origin + distance * ray;
|
||||||
|
|
||||||
|
count = i;
|
||||||
|
if ( abs(d) < EPS ) break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( abs(d) < EPS ) {
|
||||||
|
|
||||||
|
nearest = sceneIntersect( p );
|
||||||
|
nearest.position = p;
|
||||||
|
nearest.normal = getNormal(p);
|
||||||
|
nearest.distance = distance;
|
||||||
|
float diffuse = clamp( dot( lightDir, nearest.normal ), 0.1, 1.0 );
|
||||||
|
float specular = pow( clamp( dot( reflect( lightDir, nearest.normal ), ray ), 0.0, 1.0 ), 6.0 );
|
||||||
|
//float shadow = getShadow( p + nearest.normal * OFFSET, lightDir );
|
||||||
|
|
||||||
|
if ( nearest.material == BASIC_MATERIAL ) {
|
||||||
|
} else if ( nearest.material == MIRROR_MATERIAL ) {
|
||||||
|
nearest.color = vec3( 0.5, 0.7, 0.8 ) * diffuse + vec3( 1.0 ) * specular;
|
||||||
|
}
|
||||||
|
|
||||||
|
nearest.isHit = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
nearest.color = backgroundColor;
|
||||||
|
nearest.isHit = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
nearest.color = clamp( nearest.color - 0.1 * nearest.distance, 0.0, 1.0 );
|
||||||
|
|
||||||
|
// second pass (gates)
|
||||||
|
p = origin;
|
||||||
|
distance = 0.0;
|
||||||
|
minDist = INF;
|
||||||
|
for ( int i = 0; i < 20; i++ ){
|
||||||
|
d = dRepGate( p );
|
||||||
|
minDist = min(d, minDist);
|
||||||
|
/*if ( d < minDist ) {
|
||||||
|
minDist = d;
|
||||||
|
trueDepth = distance;
|
||||||
|
}*/
|
||||||
|
distance += d;
|
||||||
|
p = origin + distance * ray;
|
||||||
|
if ( i == 9 && normalizedGlobalTime <= 0.5 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( abs(d) < EPS ) {
|
||||||
|
nearest.color += gateColor;
|
||||||
|
} else {
|
||||||
|
nearest.color += gateColor * clamp( 0.05 / minDist, 0.0, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return nearest;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void main( void ) {
|
||||||
|
normalizedGlobalTime = mod( time / totalTime, 1.0 );
|
||||||
|
|
||||||
|
// fragment position
|
||||||
|
vec2 p = ( gl_FragCoord.xy * 2.0 - resolution.xy ) / min( resolution.x, resolution.y );
|
||||||
|
|
||||||
|
// camera and ray
|
||||||
|
if ( normalizedGlobalTime < 0.7 ) {
|
||||||
|
cPos = vec3( 0.0, 0.6 + 0.4 * cos( time ), 3.0 * time );
|
||||||
|
cDir = normalize( vec3( 0.0, -0.1, 1.0 ) );
|
||||||
|
} else {
|
||||||
|
cPos = vec3( 0.0, 0.6 + 0.4 * cos( time ) + 50.0 * ( normalizedGlobalTime - 0.7 ), 3.0 * time );
|
||||||
|
cDir = normalize( vec3( 0.0, -0.1 - ( normalizedGlobalTime - 0.7 ), 1.0 ) );
|
||||||
|
}
|
||||||
|
vec3 cSide = normalize( cross( cDir, vec3( 0.0, 1.0 ,0.0 ) ) );
|
||||||
|
vec3 cUp = normalize( cross( cSide, cDir ) );
|
||||||
|
float targetDepth = 1.3;
|
||||||
|
vec3 ray = normalize( cSide * p.x + cUp * p.y + cDir * targetDepth );
|
||||||
|
|
||||||
|
// Illumination Color
|
||||||
|
// illuminationColor = hsv2rgb( vec3( time * 0.02 + 0.6, 1.0, 1.0 ) );
|
||||||
|
|
||||||
|
vec3 color = vec3( 0.0 );
|
||||||
|
float alpha = 1.0;
|
||||||
|
Intersect nearest;
|
||||||
|
|
||||||
|
for ( int i = 0; i < 3; i++ ) {
|
||||||
|
|
||||||
|
nearest = getRayColor( cPos, ray );
|
||||||
|
|
||||||
|
color += alpha * nearest.color;
|
||||||
|
alpha *= 0.5;
|
||||||
|
ray = normalize( reflect( ray, nearest.normal ) );
|
||||||
|
cPos = nearest.position + nearest.normal * OFFSET;
|
||||||
|
|
||||||
|
if ( !nearest.isHit || nearest.material != MIRROR_MATERIAL ) break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = vec4(color, 1.0);
|
||||||
|
|
||||||
|
}
|
51
warp.glsl
Normal file
51
warp.glsl
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
|
||||||
|
// StarTrip
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
uniform sampler2D backbuffer;
|
||||||
|
#define speed (resolution.x / 10.)
|
||||||
|
#define k2PI (2.*3.14159265359)
|
||||||
|
#define kStarDensity .011
|
||||||
|
#define kMotionBlur 0.4
|
||||||
|
#define kNumAngles 90. + sin(time)*30.
|
||||||
|
|
||||||
|
void main( void )
|
||||||
|
{
|
||||||
|
vec2 position = ( gl_FragCoord.xy - resolution.xy*.5 ) / resolution.x;
|
||||||
|
float A = atan(position.y,position.x);
|
||||||
|
float angle0 = A / k2PI;
|
||||||
|
float angle = fract(angle0 + .002*time);
|
||||||
|
float rad = .3*length(position);
|
||||||
|
float angleFract = fract(angle*kNumAngles);
|
||||||
|
float angleStep = floor(angle*kNumAngles);
|
||||||
|
float angleToRandZ = 10.*fract(angleStep*fract(angleStep*.7535)*45.1);
|
||||||
|
float angleSquareDist = fract(angleStep*fract(angleStep*.82657)*13.724);
|
||||||
|
float t = speed * time - angleToRandZ;
|
||||||
|
float angleDist = (angleSquareDist+0.1);
|
||||||
|
float adist = angleDist/rad*kStarDensity;
|
||||||
|
float dist = abs(fract((t*.1+adist))-.5);
|
||||||
|
float white1 = max(0.,1.0 - dist * 100.0 / (kMotionBlur*speed+adist));
|
||||||
|
float white2 = max(0.,(.5-.5*cos(k2PI * angleFract))*1./max(0.6,2.*adist*angleDist));
|
||||||
|
float white = white1*white2;
|
||||||
|
vec3 color;
|
||||||
|
color.r = .03*white1 + white*(0.3 + 5.0*angleDist);
|
||||||
|
color.b = white*(0.1 + .5*angleToRandZ);
|
||||||
|
color.g = 0.2*white;
|
||||||
|
|
||||||
|
float nebD1 = 1.0/rad + 4.5*(1.0 + sin(1.1 + 3.0*A + 0.71*cos(2.0*A)));
|
||||||
|
float nebD2 = 1.0/rad + 3.7*(1.0 + sin(3.7 + 2.0*A + 0.46*sin(3.0*A)));
|
||||||
|
float R1 = 1.0 * rad * (1.0 + sin(0.3+3.0*A + 2.4 * cos(0.2+3.0*A)*sin(2.1+0.42*(nebD1+speed*time)) + sin(2.0*6.283*position.x) ));
|
||||||
|
float R2 = 1.0 * rad * (1.0 + sin(1.1+4.0*A + 3.2 * cos(0.7+4.0*A)*sin(1.7+0.27*(nebD2+speed*time)) + cos(3.0*6.283*position.y) ));
|
||||||
|
float P1 = 0.5 + .5*sin(5.7*position.x+.22*(speed*time));
|
||||||
|
float P2 = 0.5 + .5*sin(4.44*position.y+.17*(speed*time)) ;
|
||||||
|
color.r += 0.6*R1 + 0.3*R2 + 0.1*P1*P2 ;
|
||||||
|
color.b += 0.3*R1 + 0.8*R2 + .1*P2*R1;
|
||||||
|
color.g += 1.1*R1*R2*P2;
|
||||||
|
gl_FragColor = vec4( (color.grb+ vec3(texture2D(backbuffer, (gl_FragCoord.xy / resolution.xy))))/1.1, 1.0);
|
||||||
|
}
|
335
wormhole.glsl
Normal file
335
wormhole.glsl
Normal file
|
@ -0,0 +1,335 @@
|
||||||
|
// WORMHOLE - watch for a little while
|
||||||
|
// better version.
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
uniform float time;
|
||||||
|
uniform vec2 mouse;
|
||||||
|
uniform vec2 resolution;
|
||||||
|
|
||||||
|
|
||||||
|
#define iterations 9
|
||||||
|
#define formuparam2 0.79
|
||||||
|
|
||||||
|
#define volsteps 9
|
||||||
|
#define stepsize 0.190
|
||||||
|
|
||||||
|
#define zoom 0.500
|
||||||
|
#define tile 0.85
|
||||||
|
#define speed2 0.30
|
||||||
|
|
||||||
|
#define brightness (0.02 * (1.5 - 0.5*sus_sin(0.5*time)))
|
||||||
|
#define darkmatter 0.400
|
||||||
|
#define distfading 0.560
|
||||||
|
#define saturation 0.800
|
||||||
|
|
||||||
|
|
||||||
|
#define transverseSpeed zoom*.005
|
||||||
|
//#define cloud (0.31 * (1.5 - 0.5*sus_sin(0.5*time)))
|
||||||
|
|
||||||
|
|
||||||
|
#define cloud 0.3
|
||||||
|
#define power1 0.5
|
||||||
|
#define power2 -2.0
|
||||||
|
|
||||||
|
|
||||||
|
#define pi 3.141592653589
|
||||||
|
|
||||||
|
float triangle(float x, float a)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
float output2 = 2.0*abs( 2.0* ( (x/a) - floor( (x/a) + 0.5) ) ) - 1.0;
|
||||||
|
return output2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float trapezoid(float x, float a)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
float output2 = 2.0*abs( 2.0* ( (x/a) - floor( (x/a) + 0.5) ) ) - 1.0;
|
||||||
|
|
||||||
|
float output3 = 2.0*clamp(output2, -1., 1.);
|
||||||
|
|
||||||
|
return output2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float sus_sin(float x)
|
||||||
|
{
|
||||||
|
float x1 = x + (3.0*pi/2.0);
|
||||||
|
float output1 = abs(sin(x1));
|
||||||
|
float output2 = (clamp((1.0/(sin(pi/10.0))) * sin((1.0/5.0)*x1),-1.0,1.0));
|
||||||
|
|
||||||
|
float output3 = max(output1,abs(output2));
|
||||||
|
|
||||||
|
return output3 * sign(output2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float smooth_stair(float x, float period, float strechiness, float shift)
|
||||||
|
{
|
||||||
|
|
||||||
|
float output1 = ( (1.0/(1.0 + exp(-1.0*mod(((1.0*(strechiness*(x)-shift ))),strechiness*period) + (strechiness*period / 2.0) ))) + (floor(((strechiness*(x)-shift))/(strechiness*period))) );
|
||||||
|
|
||||||
|
return output1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float field(in vec3 p) {
|
||||||
|
|
||||||
|
float strength = 17. + .03 * log(1.e-6 + fract(sin(time) * 4373.11));
|
||||||
|
float accum = 0.;
|
||||||
|
float prev = 0.;
|
||||||
|
float tw = 0.;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
float mag = dot(p, p);
|
||||||
|
p = abs(p) / mag + vec3(-.5, -.8 + 0.1*sin(time*0.7 + 2.0), -1.1+0.3*cos(time*0.3));
|
||||||
|
float w = exp(-float(i) / 7.);
|
||||||
|
accum += w * exp(-strength * pow(abs(mag - prev), 2.3));
|
||||||
|
tw += w;
|
||||||
|
prev = mag;
|
||||||
|
}
|
||||||
|
return max(0., 5. * accum / tw - .7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
//mouse rotation
|
||||||
|
float a_xz = 0.9;
|
||||||
|
float a_yz = -.6;
|
||||||
|
float a_xy = 0.9 + time*0.01;
|
||||||
|
|
||||||
|
|
||||||
|
mat2 rot_xz = mat2(cos(a_xz),sin(a_xz),-sin(a_xz),cos(a_xz));
|
||||||
|
|
||||||
|
mat2 rot_yz = mat2(cos(a_yz),sin(a_yz),-sin(a_yz),cos(a_yz));
|
||||||
|
|
||||||
|
mat2 rot_xy = mat2(cos(a_xy),sin(a_xy),-sin(a_xy),cos(a_xy));
|
||||||
|
|
||||||
|
|
||||||
|
vec2 uv2 = 2. * gl_FragCoord.xy / resolution.xy - 1.;
|
||||||
|
vec2 uvs = uv2 * resolution.xy / max(resolution.x, resolution.y);
|
||||||
|
|
||||||
|
|
||||||
|
vec3 from=vec3(0.0, 0.0,0.0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uvs *= -3.0*rot_xy;
|
||||||
|
|
||||||
|
vec2 from_change = 1.0*vec2((mouse.x-0.5), (mouse.y-0.5));
|
||||||
|
|
||||||
|
from_change *= +3.0*rot_xy;
|
||||||
|
|
||||||
|
|
||||||
|
from.xy += from_change;
|
||||||
|
|
||||||
|
// from.x -= 5.0*(mouse.x-0.5);
|
||||||
|
// from.y -= 5.0*(mouse.y-0.5);
|
||||||
|
|
||||||
|
|
||||||
|
float time2 = time;
|
||||||
|
|
||||||
|
float speed = speed2;
|
||||||
|
|
||||||
|
|
||||||
|
//speed = 0.005 * cos(time2*0.02 + 3.1415926/4.0);
|
||||||
|
|
||||||
|
speed = -0.003 * cos((cos(0.02*time)));
|
||||||
|
|
||||||
|
//speed = -0.001* clamp((0.5 - 2.*cos(0.05*time)),0.,1.);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//speed = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
float formuparam = formuparam2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// any ideas on how to make this wrap without the discontinuity?
|
||||||
|
|
||||||
|
//float a = (atan(uvs.y,uvs.x));
|
||||||
|
float a = abs(atan(uvs.y,uvs.x));
|
||||||
|
float r = pow( pow(uvs.x*uvs.x,1.3) + pow(uvs.y*uvs.y,1.3), 1.0/(6.) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//vec2 uv = vec2( clamp((0.5 + 3.*cos(0.02*time)),0.,1.)*uvs.x + clamp((0.5 - 3.*cos(0.02*time)),0.,1.)*(0.3)/pow(r,1.), clamp((0.5 + 3.*cos(0.02*time)),0.,1.)*uvs.y + clamp((0.5 - 3.*cos(0.02*time)),0.,1.)*(1.*a/3.1415927) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vec2 uv = vec2( ((0.5 + 0.5*sus_sin(0.5*time)))*uvs.x + ((0.5 - 0.5*sus_sin(0.5*time)))*(0.3)/pow(r,1.), ((0.5 + 0.5*sus_sin(0.5*time)))*uvs.y + ((0.5 - 0.5*sus_sin(0.5*time)))*(1.*a/3.1415927) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// uv = uvs;
|
||||||
|
|
||||||
|
//uv *= rot_xy;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float v2 =1.0;
|
||||||
|
|
||||||
|
vec3 dir=vec3(uv*zoom,1.);
|
||||||
|
|
||||||
|
|
||||||
|
from.y -= 20.0;
|
||||||
|
//from.y -= 1.5*smooth_stair(time, 10.0*pi, 2.0, -5.0);
|
||||||
|
|
||||||
|
//from.x -= 50.0*(0.5 - 3.*cos(0.02*time));
|
||||||
|
|
||||||
|
//from.x -= time*.3*(0.5 - 0.5*sus_sin(0.5*time));
|
||||||
|
|
||||||
|
vec3 forward = vec3(0.,0.,1.);
|
||||||
|
|
||||||
|
|
||||||
|
from.x += transverseSpeed*(1.0)*cos(0.01*time);
|
||||||
|
from.y += transverseSpeed*(1.0)*sin(0.01*time);
|
||||||
|
|
||||||
|
from.z += 0.003*time;
|
||||||
|
|
||||||
|
//from.x -= 0.2*(0.1 - 0.1*sus_sin(0.1*time))*time;
|
||||||
|
|
||||||
|
|
||||||
|
dir.xy*=rot_xy;
|
||||||
|
forward.xy *= rot_xy;
|
||||||
|
|
||||||
|
dir.xz*=rot_xz;
|
||||||
|
forward.xz *= rot_xz;
|
||||||
|
|
||||||
|
|
||||||
|
dir.yz*= rot_yz;
|
||||||
|
forward.yz *= rot_yz;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from.xy*=-rot_xy;
|
||||||
|
from.xz*=rot_xz;
|
||||||
|
from.yz*= rot_yz;
|
||||||
|
|
||||||
|
|
||||||
|
//zoom
|
||||||
|
float zooom = (time2-3311.)*speed;
|
||||||
|
from += forward* zooom;
|
||||||
|
float sampleShift = mod( zooom, stepsize );
|
||||||
|
|
||||||
|
float zoffset = -sampleShift;
|
||||||
|
sampleShift /= stepsize; // make from 0 to 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//volumetric rendering
|
||||||
|
float s=0.24;
|
||||||
|
float s3 = s + stepsize/2.0;
|
||||||
|
vec3 v=vec3(0.);
|
||||||
|
float t3 = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 backCol2 = vec3(0.);
|
||||||
|
for (int r=0; r<volsteps; r++) {
|
||||||
|
vec3 p2=from+(s+zoffset)*dir;// + vec3(0.,0.,zoffset);
|
||||||
|
vec3 p3=from+(s3+zoffset)*dir;// + vec3(0.,0.,zoffset);
|
||||||
|
|
||||||
|
p2 = abs(vec3(tile)-mod(p2,vec3(tile*2.))); // tiling fold
|
||||||
|
p3 = abs(vec3(tile)-mod(p3,vec3(tile*2.))); // tiling fold
|
||||||
|
|
||||||
|
#ifdef cloud
|
||||||
|
t3 = field(p3);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float pa,a=pa=0.;
|
||||||
|
for (int i=0; i<iterations; i++) {
|
||||||
|
p2=abs(p2)/dot(p2,p2)-formuparam; // the magic formula
|
||||||
|
//p=abs(p)/max(dot(p,p),0.005)-formuparam; // another interesting way to reduce noise
|
||||||
|
float D = abs(length(p2)-pa); // absolute sum of average change
|
||||||
|
a += i > 7 ? min( 12., D) : D;
|
||||||
|
pa=length(p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//float dm=max(0.,darkmatter-a*a*.001); //dark matter
|
||||||
|
a*=a*a; // add contrast
|
||||||
|
//if (r>3) fade*=1.-dm; // dark matter, don't render near
|
||||||
|
// brightens stuff up a bit
|
||||||
|
float s1 = s+zoffset;
|
||||||
|
// need closed form expression for this, now that we shift samples
|
||||||
|
float fade = pow(distfading,max(0.,float(r)-sampleShift));
|
||||||
|
|
||||||
|
|
||||||
|
//t3 += fade;
|
||||||
|
|
||||||
|
v+=fade;
|
||||||
|
//backCol2 -= fade;
|
||||||
|
|
||||||
|
// fade out samples as they approach the camera
|
||||||
|
if( r == 0 )
|
||||||
|
fade *= (1. - (sampleShift));
|
||||||
|
// fade in samples as they approach from the distance
|
||||||
|
if( r == volsteps-1 )
|
||||||
|
fade *= sampleShift;
|
||||||
|
v+=vec3(s1,s1*s1,s1*s1*s1*s1)*a*brightness*fade; // coloring based on distance
|
||||||
|
|
||||||
|
backCol2 += mix(.4, 1., v2) * vec3(1.8 * t3 * t3 * t3, 1.4 * t3 * t3, t3) * fade;
|
||||||
|
|
||||||
|
|
||||||
|
s+=stepsize;
|
||||||
|
s3 += stepsize;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
v=mix(vec3(length(v)),v,saturation); //color adjust
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vec4 forCol2 = vec4(v*.01,1.);
|
||||||
|
|
||||||
|
#ifdef cloud
|
||||||
|
backCol2 *= cloud;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
backCol2.b *= 1.8;
|
||||||
|
|
||||||
|
backCol2.r *= 0.05;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
backCol2.b = 0.5*mix(backCol2.g, backCol2.b, 0.8);
|
||||||
|
backCol2.g = 0.0;
|
||||||
|
|
||||||
|
backCol2.bg = mix(backCol2.gb, backCol2.bg, 0.5*(cos(time*0.01) + 1.0));
|
||||||
|
|
||||||
|
vec4 newCol = (forCol2 + vec4(backCol2, 1.0)) * pow(r,1.5*((0.5 - 0.5*sus_sin(0.5*time))));
|
||||||
|
|
||||||
|
//gl_FragColor = forCol2 + vec4(backCol2, 1.0);
|
||||||
|
gl_FragColor = newCol;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue