git ssb

0+

substack / °ŗÅñġ€Ŧəá



Commit cf2cf2ffcdd1c1043fccc11c88b6c7845a2467cc

starbgdither

substack committed on 5/16/2017, 11:53:27 AM
Parent: 367b3cab0e2d3493dd1a93d8ccaa06843d98f0a8

Files changed

main.jschanged
package.jsonchanged
main.jsView
@@ -10,42 +10,86 @@
1010 var fbtex = regl.texture()
1111 var draw = {
1212 grid: createGrid(regl,30),
1313 gridbg: createGridBg(regl,30),
14 + bg: createBg(regl),
1415 fb: feedback(regl, `
1516 vec3 sample (vec2 uv, sampler2D tex) {
16- return 0.995*texture2D(tex, (0.99*(2.0*uv-1.0)+1.0)*0.5).rgb;
17 + float px = 256.0;
18 + vec2 puv = floor(uv*px)/px+0.5/px;
19 + vec3 c = 0.99*texture2D(tex, (0.993*(2.0*puv-1.0)+1.0)*0.5).rgb;
20 + float d = 32.0;
21 + return floor(c*d)/d;
1722 }
1823 `)
1924 }
20-var rmat = []
25 +var rmat = [], last = 0
2126 regl.frame(function (context) {
2227 regl.clear({ color: [0,0,0,1], depth: true })
2328 draw.fb({ texture: fbtex })
29 + draw.bg()
2430 mat4.identity(rmat)
25- mat4.rotateY(rmat,rmat,context.time*0.1)
31 + mat4.rotateY(rmat,rmat,context.time*0.05)
2632 camera(function () {
2733 draw.grid({ rmat: rmat })
2834 draw.gridbg({ rmat: rmat })
2935 fbtex({ copy: true, mag: 'linear', min: 'linear' })
3036 })
3137 })
3238
39 +function createBg (regl) {
40 + return regl({
41 + frag: glsl`
42 + precision highp float;
43 + #pragma glslify: snoise = require('glsl-noise/simplex/3d')
44 + uniform float time;
45 + varying vec2 vpos;
46 + void main () {
47 + float d = 256.0;
48 + vec2 p = floor(vpos*d)/d+0.5/d;
49 + float x = pow(snoise(vec3(p*64.0,time*0.5))*0.5+0.5,16.0);
50 + gl_FragColor = vec4(x,x,x,x);
51 + }
52 + `,
53 + vert: glsl`
54 + precision highp float;
55 + attribute vec2 position;
56 + varying vec2 vpos;
57 + void main () {
58 + vpos = position;
59 + gl_Position = vec4(position,0,1);
60 + }
61 + `,
62 + attributes: {
63 + position: [-4,0,4,4,4,-4]
64 + },
65 + uniforms: {
66 + time: regl.context('time')
67 + },
68 + primitive: 'triangles',
69 + elements: [0,1,2],
70 + depth: { enable: false, mask: false },
71 + blend: { enable: true, func: {
72 + src: 'src alpha', dst: 'one minus src alpha' } }
73 + })
74 +}
75 +
3376 function createGridBg (regl,size) {
3477 var mesh = grid(size,size)
3578 return regl({
3679 frag: glsl`
3780 precision highp float;
3881 #pragma glslify: snoise = require('glsl-noise/simplex/4d')
3982 #pragma glslify: hsl2rgb = require('glsl-hsl2rgb')
83 + #pragma glslify: dither = require('glsl-dither/8x8')
4084 uniform float time;
4185 varying vec3 vpos;
4286 void main () {
4387 float h = snoise(vec4(vpos*0.2,time*0.1))*0.5+0.5;
4488 float s = 1.0;
45- float l = pow(snoise(vec4(vpos*0.1,time*0.2))*0.5+0.5,4.0);
46- gl_FragColor = vec4(hsl2rgb(h*0.3+0.6,s,l),1);
47- //gl_FragColor = vec4(0.5,0,1,1);
89 + float l = pow(snoise(vec4(vpos*0.1,time*0.2))*0.5+0.5,4.0)
90 + + pow(snoise(vec4(vpos,time*0.5))*0.5+0.5,4.0);
91 + gl_FragColor = vec4(dither(gl_FragCoord.xy,hsl2rgb(h*0.3+0.6,s,l)),1);
4892 }
4993 `,
5094 vert: glsl`
5195 precision highp float;
@@ -65,9 +109,9 @@
65109 ) / ${size.toFixed(1)};
66110 return (p*2.0-1.0)*8.0;
67111 }
68112 void main () {
69- vpos = displace(position) - vec3(0,0.01,0);
113 + vpos = displace(position) - vec3(0,0.05,0);
70114 gl_Position = projection * view * rmat * vec4(vpos,1);
71115 }
72116 `,
73117 attributes: {
@@ -92,12 +136,11 @@
92136 varying vec3 vpos;
93137 void main () {
94138 float h = snoise(vec4(vpos,time))*0.5+0.5;
95139 float s = snoise(vec4(vpos,time*0.5))*0.5+0.5;
96- float l = pow(snoise(vec4(vpos*0.1,time*2.0))*0.5+0.5,8.0)
97- + pow(snoise(vec4(vpos,time*0.5))*0.5+0.5,8.0);
98- gl_FragColor = vec4(hsl2rgb(h*0.3+0.6,s,l),1);
99- //gl_FragColor = vec4(0.5,0,1,1);
140 + float l = pow(snoise(vec4(vpos*0.1,time*0.5))*0.5+0.5,8.0)
141 + + pow(snoise(vec4(vpos,time*0.5))*0.5+0.5,2.0);
142 + gl_FragColor = vec4(hsl2rgb(h*0.3+0.6,s,1.0-l),1);
100143 }
101144 `,
102145 vert: glsl`
103146 precision highp float;
package.jsonView
@@ -1,8 +1,9 @@
11 {
22 "dependencies": {
33 "conway-hart": "^0.1.0",
44 "gl-mat4": "^1.1.4",
5 + "glsl-dither": "^1.0.1",
56 "glsl-hsl2rgb": "^1.1.0",
67 "glsl-noise": "0.0.0",
78 "glslify": "^6.0.2",
89 "grid-mesh": "^0.1.0",

Built with git-ssb-web