Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Set x,y position coordinates to be used to extract data from one plane of our data cube
- //remember, z we handle as a 1 layer of our cube which is composed of a stack of x-y planes.
- const oneLayerVertices = new Float32Array(size * size * 2);
- count = 0;
- for (var j = 0; j < (size); j++) {
- for (var i = 0; i < (size); i++) {
- oneLayerVertices[count] = i;
- count++;
- oneLayerVertices[count] = j;
- count++;
- //oneLayerVertices[count] = 0;
- //count++;
- //oneLayerVertices[count] = 0;
- //count++;
- }
- }
- const bufferInfo = twgl.createBufferInfoFromArrays(gl, {
- position: {
- numComponents: 2,
- data: oneLayerVertices,
- },
- });
- gl.useProgram(computeProgramInfo.program);
- twgl.setBuffersAndAttributes(gl, computeProgramInfo, bufferInfo);
- gl.viewport(0, 0, size, size); //remember size = 4
- outFramebuffers.forEach((fb, ndx) => {
- gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
- gl.drawBuffers([
- gl.COLOR_ATTACHMENT0,
- gl.COLOR_ATTACHMENT1,
- gl.COLOR_ATTACHMENT2,
- gl.COLOR_ATTACHMENT3
- ]);
- const baseLayerTexCoord = (ndx * numLayersPerFramebuffer);
- console.log("My baseLayerTexCoord is "+baseLayerTexCoord);
- twgl.setUniforms(computeProgramInfo, {
- baseLayerTexCoord,
- u_kernel: [
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 1,
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0,
- ],
- u_position: inPos,
- u_velocity: inVel,
- loopCounter: loopCounter,
- numLayersPerFramebuffer: numLayersPerFramebuffer
- });
- gl.drawArrays(gl.POINTS, 0, (16));
- });
- const compute_vs = `#version 300 es
- precision highp float;
- in vec4 position;
- void main() {
- gl_Position = position;
- }
- `;
- const compute_fs = `#version 300 es
- precision highp float;
- out vec4 ourOutput[4];
- void main() {
- ourOutput[0] = vec4(0,1,0,1);
- ourOutput[1] = vec4(0,1,0,1);
- ourOutput[2] = vec4(0,1,0,1);
- ourOutput[3] = vec4(0,1,0,1);
- }
- `;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement