This file contains hidden or 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
| <canvas id="CNVS" width="256" height="256"></canvas> | |
| <script> | |
| var cx=CNVS.getContext("webgl");cx.enable(0x0c11); | |
| var data=new Uint8Array(256*256*4),fbuf=new Uint8Array(256*256*4); | |
| for(j=0;j<256;j++)for(i=0;i<256;i++){ | |
| data[(j*256+i)*4+0]=i; | |
| data[(j*256+i)*4+1]=j; | |
| data[(j*256+i)*4+2]=(i*i+j*j<65536)?0xff:0; | |
| data[(j*256+i)*4+3]=0xff; | |
| } |
This file contains hidden or 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
| <canvas id="CNVS" width="512" height="512"></canvas> | |
| <img hidden src="KimiruHamiru.png" id="IMGS" width="256" height="256"> | |
| <script> | |
| var cx=CNVS.getContext("webgl",{preserveDrawingBuffer:true}); | |
| cx.enable(0x0c11); | |
| var fbuf=new Uint8Array(512*512*4); | |
| var tx=cx.createTexture();cx.bindTexture(cx.TEXTURE_2D, tx); | |
| var drawFrag=false, wait=0; | |
| function load(){ | |
| cx.pixelStorei(cx.UNPACK_FLIP_Y_WEBGL,true); |
This file contains hidden or 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
| <meta charset="utf-8"><br/> | |
| <canvas id="CNVS" width="256" height="160"></canvas><hr/> | |
| <input id="SLID" type="range" max="50"> | |
| <script> | |
| const width=256, height=160; // Image size | |
| const bignum=1e5; | |
| function vec3(x=0,y=0,z=0){this.x=x, this.y=y, this.z=z;} | |
| add=function(a,b){return new vec3(a.x+b.x, a.y+b.y, a.z+b.z);} | |
| sub=function(a,b){return new vec3(a.x-b.x, a.y-b.y, a.z-b.z);} |
This file contains hidden or 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
| <meta charset="utf-8"><br/> | |
| <canvas id="CNVS"></canvas><hr/> | |
| <script> | |
| const vsrc=`attribute vec4 p;void main(){gl_PointSize=64.;gl_Position=p;}`; | |
| const fsrc=`precision mediump float; | |
| struct Ray{ vec3 o, d;}; | |
| struct Sph{ vec3 o; float r;}; | |
| const float width=120., height=80.; | |
| float intersect(Sph sph, Ray ray, float tmin, float tmax){ | |
| vec3 op=sph.o-ray.o; |
This file contains hidden or 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
| <meta charset="utf-8"><br/> | |
| <canvas id="CNVS"></canvas><hr/> | |
| <script> | |
| const vsrc=`attribute vec4 p;void main(){gl_PointSize=64.;gl_Position=p;}`; | |
| const fsrc=`precision mediump float; | |
| struct Ray{ vec3 o, d;}; | |
| struct Sph{ vec3 o; float r;}; | |
| const float width=120., height=80.; | |
| float intersect(Sph sph, Ray ray, float tmin, float tmax){ | |
| vec3 op=sph.o-ray.o; |
This file contains hidden or 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
| <meta charset="utf-8"><br/> | |
| <canvas id="CNVS"></canvas><hr/> | |
| <input id="CAM" type="range" step="0.02" min="0" max="6.3"> | |
| <script> | |
| const vsrc=`attribute vec4 p;void main(){gl_Position=p;}`; | |
| const fsrc=`precision mediump float; | |
| struct Ray{ vec3 o, d;}; | |
| struct Sph{ vec3 o; float r; vec3 ref; vec3 le;}; | |
| const float width=120., height=80.; | |
| float intersect(Sph sph, Ray ray, float tmin, float tmax){ |
This file contains hidden or 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
| <meta charset="utf-8"><br/> | |
| <canvas id="CNVS" width="300" height="200"></canvas><hr/> | |
| <input id="SELE" type="range" max="3"> | |
| <script src="drawer.js"></script> | |
| <script> | |
| // drawするとdataの中身をcanvasに表示するだけ。 | |
| function getCxPg(flags={}){ | |
| const vsrc=`attribute vec4 p;void main(){gl_Position=p;}`; | |
| const fsrc= | |
| `precision highp float; |
This file contains hidden or 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
| <h1>vertices</h1> | |
| <input id="SLID" type="range" min="1" max="25" value="10"><input id="TEXT"> | |
| <canvas id="CNVS" width="1024" height="1024"></canvas><hr/> | |
| <script> | |
| const vs=`attribute vec4 a;uniform float vt; | |
| void main(){ | |
| gl_PointSize=1.0; | |
| float th=vt*a.z/2.0; | |
| gl_Position=a; | |
| gl_Position.xy*=mat2(cos(th),-sin(th),sin(th),cos(th)); |
This file contains hidden or 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
| <meta charset="utf-8"><br/> | |
| <input id="SPP" type="range" min="0" max="8" value="2"><input id="SPPT"><br/> | |
| <input id="DPP" type="range" min="1" max="7" value="2"><input id="DPPT"><br/> | |
| <canvas id="CNVS"></canvas><hr/> | |
| <script> | |
| const vsrc=`attribute vec4 p;void main(){gl_Position=p;}`; | |
| const fsrc0c=`precision highp float; | |
| struct Ray{ vec3 o, d;}; | |
| struct Sph{ vec3 o; float r; vec3 ref; vec3 le; int m;float ior;}; | |
| const float PI=3.14; |
This file contains hidden or 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
| <h1>WebGLTexture</h1> | |
| <hr/><canvas id="CNVS" width="256px" height="256px"></canvas><hr/> | |
| <script> | |
| var cx=CNVS.getContext("webgl"); | |
| var data=new Uint8Array(256*256*4);for(var i=0; i<256*256*4; i++)data[i]=Math.random()*0xff; | |
| with(cx){ | |
| var tx=createTexture(); | |
| var fb=createFramebuffer(); | |
| bindTexture(TEXTURE_2D, tx); | |
| texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST); |