Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement from Evvvvil #1

Open
totetmatt opened this issue Jul 7, 2023 · 0 comments
Open

Enhancement from Evvvvil #1

totetmatt opened this issue Jul 7, 2023 · 0 comments

Comments

@totetmatt
Copy link
Owner

s=Date.now();
r=()=>{
  g.viewport(0,0,V.width=V.clientWidth,V.height=V.clientHeight);
  g.uniform3fv(g.getUniformLocation(p,"r"),[V.clientWidth,V.clientHeight,(Date.now()-s)/4e3,]);
  g.drawArrays(g.TRIANGLES,0,6);
  window.requestAnimationFrame(r);
}
g=(V=document.getElementById("a")).getContext("webgl2");
V.style.width=V.style.height="100%";
p = g.createProgram();
g.shaderSource(o = g.createShader(g.VERTEX_SHADER), `#version 300 es
in vec4 p;void main(){gl_Position=p;}`);
g.compileShader(o);
g.attachShader(p, o);
g.shaderSource(o = g.createShader(g.FRAGMENT_SHADER), `#version 300 es
precision highp float;out vec4 x;uniform vec3 r;void main(){vec3 p;for(float i=0.,m,e,g=i;i++<99.;p=g*normalize(vec3((gl_FragCoord.xy-.5*r.xy)/r.y,x.a=1.)),p.xy=(p.xy+sin(r.z+(p.z+=1.+r.z))*.2)*mat2(cos(m=p.z*.7),-sin(m),sin(m),cos(m)),p.y=-abs(p.y)+.5,p.x-=r.z*.1,x.xyz+=vec3(1.,.3,.2)*.05/exp(i*i*e)+vec3(0.,.7,.8)*exp(-abs(g+=e=max(5e-3/(p.z-r.z),.8*max(-abs(dot(asin(sin(p*5.)),asin(cos(p.yzx*5.)))/18.)+.1-sin(p.z)*.02,p.y)))*.7)/100.);}`);
g.compileShader(o);
g.attachShader(p,o);
g.linkProgram(p);
g.bindBuffer(g.ARRAY_BUFFER, g.createBuffer());
g.bufferData(
  g.ARRAY_BUFFER,
  new Float32Array([-1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1]),
  g.STATIC_DRAW
);
g.bindVertexArray(g.createVertexArray()),
  g.enableVertexAttribArray(g.getAttribLocation(p, "p"));
g.vertexAttribPointer(g.getAttribLocation(p, "p"), 2, g.FLOAT, !1, 0, 0);
g.useProgram(p);
r();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant