diff --git a/frontend/src/ShaderBackground.tsx b/frontend/src/ShaderBackground.tsx index d476a74..832fa19 100644 --- a/frontend/src/ShaderBackground.tsx +++ b/frontend/src/ShaderBackground.tsx @@ -927,6 +927,61 @@ export function ShaderBackground() { ) return; + const posBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer); + gl.bufferData( + gl.ARRAY_BUFFER, + new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), + gl.STATIC_DRAW + ); + + { + gl.useProgram(buffer_1_program); + const posAttrLocation = gl.getAttribLocation( + buffer_1_program, + "a_position" + ); + gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(posAttrLocation); + } + + { + gl.useProgram(buffer_2_program); + const posAttrLocation = gl.getAttribLocation( + buffer_2_program, + "a_position" + ); + gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(posAttrLocation); + } + + { + gl.useProgram(buffer_3_program); + const posAttrLocation = gl.getAttribLocation( + buffer_3_program, + "a_position" + ); + gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(posAttrLocation); + } + + { + gl.useProgram(buffer_4_program); + const posAttrLocation = gl.getAttribLocation( + buffer_4_program, + "a_position" + ); + gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(posAttrLocation); + } + + { + gl.useProgram(finalProgram); + const posAttrLocation = gl.getAttribLocation(finalProgram, "a_position"); + gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(posAttrLocation); + } + function setResolution( program: WebGLProgram, canvas: HTMLCanvasElement, @@ -1034,14 +1089,6 @@ export function ShaderBackground() { console.log("Framebuffer is unknown"); } - const posBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer); - gl.bufferData( - gl.ARRAY_BUFFER, - new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), - gl.STATIC_DRAW - ); - const ichannel0_location_buffer_1 = gl.getUniformLocation( buffer_1_program as WebGLProgram, "iChannel0"