Created
November 9, 2017 13:50
-
-
Save fand/8976fd524883770c1cf66553f1c6d847 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*{ | |
"pixelRatio": 0.5, | |
"vertexCount": 1000, | |
"vertexMode": "TRI_FAN", | |
"PASSES": [{ | |
"TARGET": "renderBuffer", | |
"vs": "./particle.vert", | |
}, { | |
}], | |
}*/ | |
precision mediump float; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform int PASSINDEX; | |
uniform sampler2D renderBuffer; | |
uniform sampler2D backbuffer; | |
varying vec4 v_color; | |
mat2 mm2(in float a){float c = cos(a), s = sin(a);return mat2(c,s,-s,c);} | |
mat2 m2 = mat2(0.95534, 0.29552, -0.29552, 0.95534); | |
float tri(in float x){return clamp(abs(fract(x)-.5),0.01,0.49);} | |
vec2 tri2(in vec2 p){return vec2(tri(p.x)+tri(p.y),tri(p.y+tri(p.x)));} | |
float triNoise2d(in vec2 p, float spd) | |
{ | |
float z=1.8; | |
float z2=2.5; | |
float rz = 0.; | |
p *= mm2(p.x*0.06); | |
vec2 bp = p; | |
for (float i=0.; i<5.; i++ ) | |
{ | |
vec2 dg = tri2(bp*1.85)*.75; | |
dg *= mm2(time*spd); | |
p -= dg/z2; | |
bp *= 1.3; | |
z2 *= .45; | |
z *= .42; | |
p *= 1.21 + (rz-1.0)*.02; | |
rz += tri(p.x+tri(p.y))*z; | |
p*= -m2; | |
} | |
return clamp(1./pow(rz*29., 1.3),0.,.55); | |
} | |
void main() { | |
vec2 p = (gl_FragCoord.xy * 2. - resolution) / min(resolution.x, resolution.y); | |
vec2 uv = gl_FragCoord.xy / resolution; | |
// p = fract(abs(p)); | |
// float t = fract(time * .1) * .8 + .2; | |
// float t = .7; | |
// uv = abs(mod(uv - .5, t * 2.) - t); | |
// float d = .001; | |
// p = abs(p); | |
// uv.y = (uv.y - .5) * .5 + .5; | |
uv = (uv - .5) * 1.2 + .5; | |
// uv = (uv - .25) * (uv - .255) + .5; | |
gl_FragColor = vec4(1); | |
gl_FragColor.r = texture2D(renderBuffer, uv).g * .9; | |
gl_FragColor += texture2D(backbuffer, uv).r * .3; | |
// gl_FragColor.b = .8; | |
gl_FragColor.gb = 1.3 - triNoise2d(uv, time *.02)*.0 - texture2D(backbuffer, uv + .01).gr; | |
gl_FragColor.g = .7 - texture2D(renderBuffer, uv + .02).r;// * .2; | |
gl_FragColor /= .7 - triNoise2d(uv * 3.2, time *.01); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*{ | |
"pixelRatio": 0.5, | |
"vertexCount": 3000, | |
"vertexMode": "TRIANGLES", | |
}*/ | |
precision mediump float; | |
attribute float vertexId; | |
uniform float vertexCount; | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
varying vec4 v_color; | |
mat2 mm2(in float a){float c = cos(a), s = sin(a);return mat2(c,s,-s,c);} | |
mat2 m2 = mat2(0.95534, 0.29552, -0.29552, 0.95534); | |
float tri(in float x){return clamp(abs(fract(x)-.5),0.01,0.49);} | |
vec2 tri2(in vec2 p){return vec2(tri(p.x)+tri(p.y),tri(p.y+tri(p.x)));} | |
float triNoise2d(in vec2 p, float spd) | |
{ | |
float z=1.8; | |
float z2=2.5; | |
float rz = 0.; | |
p *= mm2(p.x*0.06); | |
vec2 bp = p; | |
for (float i=0.; i<5.; i++ ) | |
{ | |
vec2 dg = tri2(bp*1.85)*.75; | |
dg *= mm2(time*spd); | |
p -= dg/z2; | |
bp *= 1.3; | |
z2 *= .45; | |
z *= .42; | |
p *= 1.21 + (rz-1.0)*.02; | |
rz += tri(p.x+tri(p.y))*z; | |
p*= -m2; | |
} | |
return clamp(1./pow(rz*29., 1.3),0.,.55); | |
} | |
void main() { | |
float t = time * .1; | |
float i = vertexId * .2 + sin(vertexId) * 1.; | |
vec3 pos = vec3( | |
sin(t + vertexId + i * .1) * sin(t * 1.21 + i) *.8, | |
cos(t + vertexId) * cos(t * 2.19 + i) *.6, | |
0// cos(t + i) * sin(t + vertexId * .22) | |
) *.8; | |
pos.x += triNoise2d(pos.xy, time *.001) * .5; | |
pos.y += triNoise2d(pos.xy, time * .001) *.4; | |
gl_Position = vec4(pos.x, pos.y * resolution.x / resolution.y, pos.z * .1, 1); | |
gl_PointSize = .4 / max(abs(pos.z), .1); | |
v_color = vec4( | |
fract(pos.x + i), | |
fract(pos.y + i), | |
fract(pos.z + i), | |
1 | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment